Hello, I have some basic question about transparent surface shader.
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
fixed4 t = _Time;
o.Albedo = c.rgb * c.a;
o.Alpha = c.a;
}
Why do we need to multiply c.rgb with c.a for o.Albedo? If I remove the * c.a, why does the supposed to be transparent pixel became white? Isn’t there already o.Alpha = c.a?
Why if I put o.Alpha = 0 some pixels are still visible?
If Unity picks premultiplied, it could explain why it turns white. You could try this theory if you change that line to alpha:fade as shown below:
#pragma surface surf BlinnPhong alpha:fade
I just got curious before posting and gave it a try. Here is a screenshot of not doing albedo*alpha with the different alpha modes. Is this what you’re seeing too?
As a side note, the shader is using the BlinnPhong lighting model, but does not provide gloss and specular properties in the surface shader. But this might be just because it’s an example.