0
Not a bug

Black decal with transparency not working

Brian Robbins 10 years ago updated by Freya Holmér (Developer) 10 years ago 4
I have a black decal with transparency stored as a 24-bit PNG.  The image is a Unity asset with the 
"Alpha Is Transparency" checked.  I was using the decal with the basic Unity shaders.  I just recently discovered the power of creating custom shaders and found Shader Forge as a fun way to create shaders.

Using the Texture Asset node I see the preview of the black decal correctly.  When I connect the Texture Asset to a Texture 2D node I see nothing but black in the preview.  Connecting the RGB output connector to something, for example diffuse, results in a pure black output.  

Attempting to select the decal in the Texture 2D node without the Asset node creates the same result.  It appears that the Texture 2D node is not handling the transparency correctly.
Under review
Transparency is not included in the RGB channels - transparency is in its own channel, the A channel.

In order to use transparency, you need to either use the A channel in the alpha clip input (for cutout transparency) or in the Alpha input (for partial transparency)
You are correct a in that 24-bit PNG file that has transparency is technically stored as a 32-bit file.  The alpha information is stored in the extra eight bit channel.  I also see what you are saying about directing the A output to the Alpha input and the RGB channel to Diffuse input works.   

I have years of experience in other tools such as Blender's node editor and only have hours of experience using Shader Forge.  The output node in Blender is implied as RGB or RGBA if alpha available.  Forgive me for assuming the same thing here and not fully realizing the difference.  I can understand how the input channels of the "Main" node expect a more explicit split.

This still don't explain my main concern that caused my confusion in the first place.  The Textured 2D preview is showing nothing but black.  Texture Asset shows the preview correctly.  If I connect the output of the Texture Asset to the Texture 2D input and no operation was performed between the nodes, I expect to see the exact same preview.  Likewise if I load the exact same asset directly in to the Texture 2D node I would expect to see the image with the transparency.
It's just the node preview that's showing up like that. I guess the issue is two fold:

1. The Texture2D node cannot simply always apply the alpha channel to all textures, as you often use the alpha channel for something other than transparency, such as specular masking, etc.
2. In this case, SF should apply the alpha to the node preview, if and only if you've marked the node to use the alpha as transparency. However, last time I tried this, it returned incorrect values, so it was unreliable.