Hello, I have a custom shader. It is actually just a bunch of textures that scrolls along the mesh and they add their color to other textures when they pass by each other.
The problem is all the empty space that isn’t being covered by a texture is being rendered as black but should be being rendered as transparent.
I have tried clipping the tex2D’s .a but I can’t get to work… my intention is to transform that black render into any color I’d like or simply transparent. Help!
Here’s the end of my code:
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _Tex1);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the textures
fixed4 tex1 = tex2D(_Tex1, i.uv + float2(((_Time.y) * _SpeedX1), (_Time.y) * _SpeedY1));
clip(tex1.a - _CutoutThresh);
fixed4 tex2 = tex2D(_Tex2, i.uv + float2(((_Time.y) * _SpeedX2), (_Time.y) * _SpeedY2));
clip(tex2.a - _CutoutThresh);
fixed4 tex3 = tex2D(_Tex3, i.uv + float2(((_Time.y) * _SpeedX3), (_Time.y) * _SpeedY3));
clip(tex3.a - _CutoutThresh);
fixed4 tex4 = tex2D(_Tex4, i.uv + float2(((_Time.y) * _SpeedX4), (_Time.y) * _SpeedY4));
clip(tex4.a - _CutoutThresh);
fixed4 tex5 = tex2D(_Tex5, i.uv + float2(((_Time.y) * _SpeedX5), (_Time.y) * _SpeedY5));
clip(tex5.a - _CutoutThresh);
fixed4 tex6 = tex2D(_Tex6, i.uv + float2(((_Time.y) * _SpeedX6), (_Time.y) * _SpeedY6));
clip(tex6.a - _CutoutThresh);
fixed4 tex7 = tex2D(_Tex7, i.uv + float2(((_Time.y) * _SpeedX1), (_Time.y) * _SpeedY7));
clip(tex7.a - _CutoutThresh);
fixed3 finaltex = (tex1 * tex1.a) + (tex2 * tex2.a) + (tex3 * tex3.a) + (tex4 * tex4.a) + (tex5 * tex5.a) + (tex6 * tex6.a) + (tex7 * tex7.a);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, finaltex);
return fixed4(finaltex, 1);
}
ENDCG
}
}
}
Thanks!