Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
- Shader "Custom/Sprite Color Swap"
- {
- Properties
- {
- _MainTex("Sprite", 2D) = "white" {}
- _Color("Color", Color) = (1,0,1,1)
- _IgnoreColorA("Ignore Color A", Color) = (1,0,1,1)
- _IgnoreColorB("Ignore Color B", Color) = (1,0,1,1)
- _IgnoreColorC("Ignore Color C", Color) = (1,0,1,1)
- }
- SubShader
- {
- Tags
- {
- "RenderType" = "Opaque"
- "Queue" = "Transparent+1"
- }
- Pass
- {
- ZWrite Off
- Blend SrcAlpha OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma multi_compile DUMMY PIXELSNAP_ON
- sampler2D _MainTex;
- float4 _Color;
- float4 _IgnoreColorA;
- float4 _IgnoreColorB;
- float4 _IgnoreColorC;
- struct Vertex
- {
- float4 vertex : POSITION;
- float2 uv_MainTex : TEXCOORD0;
- float2 uv2 : TEXCOORD1;
- };
- struct Fragment
- {
- float4 vertex : POSITION;
- float2 uv_MainTex : TEXCOORD0;
- float2 uv2 : TEXCOORD1;
- };
- Fragment vert(Vertex v)
- {
- Fragment o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.uv_MainTex = v.uv_MainTex;
- o.uv2 = v.uv2;
- return o;
- }
- float4 frag(Fragment IN) : COLOR
- {
- half4 c = tex2D(_MainTex, IN.uv_MainTex);
- if (c.r == _IgnoreColorA.r && c.g == _IgnoreColorA.g && c.b == _IgnoreColorA.b)
- {
- return c;
- }
- else if (c.r == _IgnoreColorB.r && c.g == _IgnoreColorB.g && c.b == _IgnoreColorB.b)
- {
- return c;
- }
- else if (c.r == _IgnoreColorC.r && c.g == _IgnoreColorC.g && c.b == _IgnoreColorC.b)
- {
- return c;
- }
- else if (c.a == 0)
- {
- return c;
- }
- else
- {
- return _Color;
- }
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement