Preview_RotatorNode.shader 818 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Shader "Hidden/RotatorNode"
  2. {
  3. Properties
  4. {
  5. _A ("_UVs", 2D) = "white" {}
  6. _B ("_Anchor", 2D) = "white" {}
  7. _C ("_RotTimeTex", 2D) = "white" {}
  8. }
  9. SubShader
  10. {
  11. Pass
  12. {
  13. CGPROGRAM
  14. #pragma vertex vert_img
  15. #pragma fragment frag
  16. #include "UnityCG.cginc"
  17. #include "Preview.cginc"
  18. sampler2D _A;
  19. sampler2D _B;
  20. sampler2D _C;
  21. float _UsingEditor;
  22. float _EditorTime;
  23. float4 frag(v2f_img i) : SV_Target
  24. {
  25. float multiplier = tex2D ( _C, i.uv ).r;
  26. float time = _EditorTime*multiplier;
  27. if ( _UsingEditor == 0 )
  28. {
  29. time = multiplier;
  30. }
  31. float cosT = cos( time );
  32. float sinT = sin( time );
  33. float2 a = tex2D( _B, i.uv ).rg;
  34. return float4( mul( tex2D( _A, i.uv ).xy - a, float2x2( cosT, -sinT, sinT, cosT ) ) + a, 0, 1 );
  35. }
  36. ENDCG
  37. }
  38. }
  39. }