Advertisement
Guest User

Untitled

a guest
Jul 27th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Sprites/Solid Colour"
  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.  
  10.     SubShader
  11.     {
  12.         Tags
  13.         {
  14.             "Queue"="Transparent"
  15.             "IgnoreProjector"="True"
  16.             "RenderType"="Transparent"
  17.             "PreviewType"="Plane"
  18.             "CanUseSpriteAtlas"="True"
  19.         }
  20.  
  21.         Cull Off
  22.         Lighting Off
  23.         ZWrite Off
  24.         Blend One OneMinusSrcAlpha
  25.  
  26.         Pass
  27.         {
  28.         CGPROGRAM
  29.             #pragma vertex vert
  30.             #pragma fragment frag
  31.             #pragma multi_compile _ PIXELSNAP_ON
  32.             #include "UnityCG.cginc"
  33.            
  34.             struct appdata_t
  35.             {
  36.                 float4 vertex   : POSITION;
  37.                 float4 color    : COLOR;
  38.                 float2 texcoord : TEXCOORD0;
  39.             };
  40.  
  41.             struct v2f
  42.             {
  43.                 float4 vertex   : SV_POSITION;
  44.                 fixed4 color    : COLOR;
  45.                 float2 texcoord  : TEXCOORD0;
  46.             };
  47.            
  48.             fixed4 _Color;
  49.  
  50.             v2f vert(appdata_t IN)
  51.             {
  52.                 v2f OUT;
  53.                 OUT.vertex = UnityObjectToClipPos(IN.vertex);
  54.                 OUT.texcoord = IN.texcoord;
  55.                 OUT.color = IN.color * _Color;
  56.                 #ifdef PIXELSNAP_ON
  57.                 OUT.vertex = UnityPixelSnap (OUT.vertex);
  58.                 #endif
  59.  
  60.                 return OUT;
  61.             }
  62.  
  63.             sampler2D _MainTex;
  64.             sampler2D _AlphaTex;
  65.             float _AlphaSplitEnabled;
  66.  
  67.             fixed4 SampleSpriteTexture (float2 uv)
  68.             {
  69.                 fixed4 color = tex2D (_MainTex, uv);
  70.  
  71. #if UNITY_TEXTURE_ALPHASPLIT_ALLOWED
  72.                 if (_AlphaSplitEnabled)
  73.                     color.a = tex2D (_AlphaTex, uv).r;
  74. #endif //UNITY_TEXTURE_ALPHASPLIT_ALLOWED
  75.  
  76.                 return color;
  77.             }
  78.  
  79.             fixed4 frag(v2f IN) : SV_Target
  80.             {
  81.                 fixed4 c = SampleSpriteTexture (IN.texcoord) * IN.color;
  82.                 if (c.a > 0) c.rgb = IN.color;
  83.                 c.rgb *= c.a;
  84.                 return c;
  85.             }
  86.         ENDCG
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement