- Home /
Transparent zones being rendered as black
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!
Actually, I've figured out. I've added all the texN. and replaced the value "1" at line 38 by the equation.
Answer by sparkzbarca · Jan 01, 2018 at 07:16 AM
Click on the imported inspector in the unity editor, like the actual png or whatever not it attached to anythign, the raw texture. under import settings in the inspector is a checkbox for
"Alpha is transparent"
probably need to check that box.
No I did that already hahaha. Let me edit the post so people can see better what is happening.
Your answer
Follow this Question
Related Questions
Unlit Transparent Cutout shader that can switch between two textures 0 Answers
Transparent Cutout Shader - max transparency distance? 1 Answer
Transparent/Cutout shader not working on Mac 0 Answers
Shader Depth Mask - Shadows with cutouts 2 Answers
Cutout + Specularmask-shader error: "Material doesn't have a color property" 0 Answers