Code:
Shader"Effect/RotateEffect"
{
Properties
{
_MainTex?("MainTex",2D)?="white"{}
_Rotate?("Rotation",float)?=0
}
SubShader
{
Tags{"Queue"="Geometry"}
Pass
{
Tags{"LightMode"="ForwardBase"}
ZWriteOff
CGPROGRAM
#pragmavertexvert
#pragmafragmentfrag
#include"UnityCG.cginc"
#define?PI3.14159265358979
sampler2D_MainTex;
float_Rot;
structa2v
{
float4vertex:?POSITION;
float3texcoord:TEXCOORD0;
};
structv2f
{
float4pos?:?SV_POSITION;
float2uv?:TEXCOORD0;
};
v2f?vert?(a2v?v)
{
v2f?o;
o.pos?=mul(UNITY_MATRIX_MVP,?v.vertex);
o.uv?=?v.texcoord;
returno;
}
fixed4frag?(v2f?i)?:?SV_Target
{
floatdistance=sqrt((i.uv.x?-0.5)*(i.uv.x?-0.5)?+(i.uv.y?-0.5)*(i.uv.y?-0.5));
_Rot?*=distance;
floatangle?=step(i.uv.x,0.5)*PI+atan((i.uv.y?-0.5)/(i.uv.x?-0.5))?+?_Rot;
i.uv.x?=0.5+distance*cos(angle);
i.uv.y?=0.5+distance*sin(angle);
fixed4c?=tex2D(_MainTex,?i.uv);
returnc;
}
ENDCG
}
}
FallBack"Default"
}