You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1 KiB

Shader "Myshader/RotateImg"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Color("Color",Color) = (1,1,1,1)
_RotationSpeed("RotationSpeed",Range(0,10)) = 1
[Toggle(_IsClockWise)]_IsClockWise("IsClockWise",float) = 1
}
SubShader
{
Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "Ignoreprojector" = "true"}
Pass
{
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct a2v
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _Color;
half _RotationSpeed;
bool _IsClockWise;
v2f vert (a2v v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv,_MainTex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float2 uv=i.uv.xy -float2(0.5,0.5);
if(_IsClockWise){
uv = float2(uv.x*cos(_RotationSpeed * _Time.y) - uv.y*sin(_RotationSpeed*_Time.y),uv.x*sin(_RotationSpeed * _Time.y) + uv.y*cos(_RotationSpeed*_Time.y));
}
else{
uv = float2(uv.x*cos(_RotationSpeed * _Time.y) + uv.y*sin(_RotationSpeed*_Time.y),uv.x*sin(_RotationSpeed * _Time.y) - uv.y*cos(_RotationSpeed*_Time.y));
}
uv += float2(0.5,0.5);
fixed4 col=tex2D(_MainTex,uv) * _Color;
return col;
}
ENDCG
}
}
}