Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cartesian to polar CG screen shader
- CGPROGRAM
- uniform float _CenterX;
- uniform float _CenterY;
- uniform float _Angle;
- uniform float _AngleOffset;
- uniform sampler2D _MainTex;
- float4 frag (v2f i) : COLOR
- {
- // normalised screen-space pixel coords are taken from the input struct v2f
- float2 uv = i.uvOrig;
- // the angle between the centre point and the pixel coordinate is calculated
- float angle = atan2(uv.x - _CenterX, uv.y + _CenterY);
- // the distance between the centre point and the pixel coordinate is calculated
- float radius = sqrt(pow(uv.x - _CenterX, 2) + pow(uv.y + _CenterY, 2));
- // the pixel coordinates are reassigned
- uv.x = angle / _Angle + _AngleOffset;
- uv.y = radius - _CenterY;
- return tex2D(_MainTex, uv);
- }
- ENDCG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement