TwirlEffect.shader 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Hidden/Twirt Effect Shader" {
  3. Properties {
  4. _MainTex ("Base (RGB)", 2D) = "white" {}
  5. }
  6. SubShader {
  7. Pass {
  8. ZTest Always Cull Off ZWrite Off
  9. Fog { Mode off }
  10. CGPROGRAM
  11. #pragma vertex vert
  12. #pragma fragment frag
  13. #pragma fragmentoption ARB_precision_hint_fastest
  14. #include "UnityCG.cginc"
  15. uniform sampler2D _MainTex;
  16. uniform float4 _MainTex_TexelSize;
  17. uniform float4 _CenterRadius;
  18. uniform float4x4 _RotationMatrix;
  19. struct v2f {
  20. float4 pos : POSITION;
  21. float2 uv : TEXCOORD0;
  22. };
  23. v2f vert( appdata_img v )
  24. {
  25. v2f o;
  26. o.pos = UnityObjectToClipPos (v.vertex);
  27. o.uv = v.texcoord - _CenterRadius.xy;
  28. return o;
  29. }
  30. float4 frag (v2f i) : COLOR
  31. {
  32. float2 offset = i.uv;
  33. float2 distortedOffset = MultiplyUV (_RotationMatrix, offset.xy);
  34. float2 tmp = offset / _CenterRadius.zw;
  35. float t = min (1, length(tmp));
  36. offset = lerp (distortedOffset, offset, t);
  37. offset += _CenterRadius.xy;
  38. return tex2D(_MainTex, offset);
  39. }
  40. ENDCG
  41. }
  42. }
  43. Fallback off
  44. }