Shader "QShader/FrameAmination_One"{
Properties{
_MainTex("Animation Texture",2D) = "white"{}
_BaseColor("BaseColor",Color) = (1.0,1.0,1.0,1.0)
_XCount("XCount",Int) = 1
_YCount("YCount",Int) = 1
_Speed("Speed",Range(1,100)) = 30
}
SubShader{
Tags{"Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent"}
pass {
Tags{"LightMode" = "Always"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#include "Lighting.cginc"
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#pragma vertex Vertex
#pragma fragment Fragment
sampler2D _MainTex;
fixed4 _BaseColor;
int _XCount;
int _YCount;
float _Speed;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f Vertex(appdata_base v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
return o;
}
fixed4 Fragment(v2f i) :SV_TARGET{
float time = floor(_Time.y * _Speed);
float ypos = floor(time / _XCount);
float xpos = time - ypos * _XCount;
i.uv.x = (i.uv.x + xpos) / _XCount;
i.uv.y = 1 - (ypos + 1 - i.uv.y) / _YCount;
fixed4 c = tex2D(_MainTex,i.uv);
return c * _BaseColor;
}
ENDCG
}
}
}