12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
-
- Shader "WNWL/Particles/SpriteOrderAnim"
- {
- Properties
- {
- _Color("Color Tint",Color) = (1,1,1,1)
- _MainTex("main tex" ,2D) = ""{}
- _Row("行",Int) = 1
- _Column("列",Int) = 1
- _Speed("speed",Range(0,10)) = 1
- [Enum(UnityEngine.Rendering.BlendMode)] _DstBlend("Dst Blend Mode", float) = 1
- }
-
- SubShader
- {
- Tags{ "RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" }
- Pass
- {
- Blend SrcAlpha [_DstBlend]
- Cull Off Lighting Off ZWrite off
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- struct v2f
- {
- float4 pos:POSITION;
- float2 uv:TEXCOORD0;
- };
- half4 _Color;
- sampler2D _MainTex;
- float4 _MainTex_ST;
- int _Row;
- int _Column;
- float _Speed;
- v2f vert(appdata_base v)
- {
- v2f o;
- o.pos = UnityObjectToClipPos(v.vertex);
- o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
- return o;
- }
- fixed4 frag(v2f IN) :COLOR
- {
- float2 uv = IN.uv;
- float cellX = uv.x / _Column;
- float cellY = uv.y / _Row;
-
- int count = _Row * _Column;
-
- int SpriteIndex = fmod(_Time.w*_Speed,count);
-
- int SpriteRowIndx = (SpriteIndex / _Column);
-
- int SpriteColumnIndex = fmod(SpriteIndex,_Column);
-
- SpriteRowIndx = (_Row - 1) - fmod(SpriteRowIndx,_Row);
-
- uv.x = cellX + SpriteColumnIndex*1.0 / _Column;
- uv.y = cellY + SpriteRowIndx*1.0 / _Row;
- half4 c = tex2D(_MainTex,uv);
- c.rgb *= _Color;
- return c;
- }
- ENDCG
- }
- }
- FallBack "Diffuse"
- }
|