Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. Shader "Custom/SpriteSkewShader"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
  6. _Color ("Tint", Color) = (1,1,1,1)
  7. [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
  8.  
  9. _Skew ("Skew", Vector) = (0, 0, 0, 0)
  10. }
  11. SubShader
  12. {
  13. Tags
  14. {
  15. "Queue"="Transparent"
  16. "IgnoreProjector"="True"
  17. "RenderType"="Transparent"
  18. "PreviewType"="Plane"
  19. "CanUseSpriteAtlas"="True"
  20. }
  21. Cull Off
  22. Lighting Off
  23. ZWrite Off
  24. Fog { Mode Off }
  25. Blend One OneMinusSrcAlpha
  26. Pass
  27. {
  28. CGPROGRAM
  29. #pragma vertex vert
  30. #pragma fragment frag
  31. #pragma multi_compile DUMMY PIXELSNAP_ON
  32. #include "UnityCG.cginc"
  33.  
  34. struct appdata_t
  35. {
  36. float4 vertex : POSITION;
  37. float4 color : COLOR;
  38. float4 texcoord : TEXCOORD0;
  39. };
  40. struct v2f
  41. {
  42. float4 vertex : SV_POSITION;
  43. fixed4 color : COLOR;
  44. half4 texcoord : TEXCOORD0;
  45. };
  46.  
  47. sampler2D _MainTex;
  48. fixed4 _Color;
  49. half4 _Skew;
  50.  
  51. v2f vert(appdata_t IN)
  52. {
  53. v2f OUT;
  54. OUT.texcoord = IN.texcoord;
  55. OUT.color = IN.color * _Color;
  56.  
  57. OUT.vertex = UnityObjectToClipPos(IN.vertex+IN.texcoord.yxzw*_Skew);
  58.  
  59. #ifdef PIXELSNAP_ON
  60. OUT.vertex = UnityPixelSnap (OUT.vertex);
  61. #endif
  62.  
  63. return OUT;
  64. }
  65.  
  66. fixed4 frag(v2f IN) : SV_Target
  67. {
  68. fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
  69. c.rgb *= c.a;
  70. return c;
  71. }
  72.  
  73. ENDCG
  74. }
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement