SkinningModule-GUITextureClip.shader 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Shader "Hidden/SkinningModule-GUITextureClip"
  2. {
  3. Properties {
  4. _MainTex ("Texture", Any) = "white" {}
  5. _Opacity ("Opacity", Float) = 1
  6. _VertexColorBlend ("VertexColorBlend", Float) = 0
  7. _Color ("Tint", Color) = (1,1,1,1)
  8. }
  9. CGINCLUDE
  10. #pragma vertex vert
  11. #pragma fragment frag
  12. #pragma target 2.0
  13. #include "UnityCG.cginc"
  14. struct appdata_t {
  15. float4 vertex : POSITION;
  16. fixed4 color : COLOR;
  17. float2 texcoord : TEXCOORD0;
  18. UNITY_VERTEX_INPUT_INSTANCE_ID
  19. };
  20. struct v2f {
  21. float4 vertex : SV_POSITION;
  22. fixed4 color : COLOR;
  23. float2 texcoord : TEXCOORD0;
  24. float2 clipUV : TEXCOORD1;
  25. UNITY_VERTEX_OUTPUT_STEREO
  26. };
  27. sampler2D _MainTex;
  28. sampler2D _GUIClipTexture;
  29. uniform float4 _MainTex_ST;
  30. fixed4 _Color;
  31. uniform fixed _Opacity;
  32. uniform fixed _VertexColorBlend;
  33. uniform float4x4 unity_GUIClipTextureMatrix;
  34. uniform bool _AdjustLinearForGamma;
  35. v2f vert (appdata_t v)
  36. {
  37. v2f o;
  38. UNITY_SETUP_INSTANCE_ID(v);
  39. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
  40. o.vertex = UnityObjectToClipPos(v.vertex);
  41. float3 eyePos = UnityObjectToViewPos(v.vertex);
  42. o.clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
  43. o.color = v.color;
  44. o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
  45. return o;
  46. }
  47. fixed4 frag (v2f i) : SV_Target
  48. {
  49. fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
  50. if (_AdjustLinearForGamma)
  51. col.rgb = LinearToGammaSpace(col.rgb);
  52. col = lerp(col, i.color, _VertexColorBlend);
  53. col.a *= tex2D(_GUIClipTexture, i.clipUV).a * _Opacity;
  54. return col;
  55. }
  56. ENDCG
  57. SubShader {
  58. Tags { "ForceSupported" = "True" }
  59. Lighting Off
  60. Blend SrcAlpha OneMinusSrcAlpha, One One
  61. Cull Off
  62. ZWrite Off
  63. ZTest Always
  64. Pass {
  65. CGPROGRAM
  66. ENDCG
  67. }
  68. }
  69. SubShader {
  70. Tags { "ForceSupported" = "True" }
  71. Lighting Off
  72. Blend SrcAlpha OneMinusSrcAlpha
  73. Cull Off
  74. ZWrite Off
  75. ZTest Always
  76. Pass {
  77. CGPROGRAM
  78. ENDCG
  79. }
  80. }
  81. }