Shader "Hidden/TextureCombinerShader" { SubShader { Tags { "RenderType"="Opaque" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag // make fog work #pragma multi_compile_fog #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _TextureR; sampler2D _TextureG; sampler2D _TextureB; sampler2D _TextureA; half4 _TexturesGiven; half4 _InvertedTextures; float _DefaultValue; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } fixed4 frag (v2f i) : SV_Target { // sample the textures fixed4 colR = tex2D(_TextureR, i.uv); fixed4 colG = tex2D(_TextureG, i.uv); fixed4 colB = tex2D(_TextureB, i.uv); fixed4 colA = tex2D(_TextureA, i.uv); fixed R = abs(_InvertedTextures.x - colR.r * colR.a); fixed G = abs(_InvertedTextures.y - colG.r * colG.a); fixed B = abs(_InvertedTextures.z - colB.r * colB.a); fixed A = abs(_InvertedTextures.w - colA.r * colA.a); fixed4 texCol = fixed4(R,G,B,A); fixed4 col = lerp(texCol, _DefaultValue , (1 - _TexturesGiven)); return col; } ENDCG } } }