0
Not a bug

Alpha Channels Breaks Shader

Superdenny 10 years ago updated by Freya Holmér (Developer) 10 years ago 4
Every time I try to use an Alpha Channel from a Diffuse or Normal map, the output turns pink and I get a console full of errors.
It shouldn't happen with a diffuse map, but you can't use the alpha channels on texture nodes marked as normal maps. How does your node tree look?
I actually managed to fix the issue with the diffuse texture.  Just curious, why don't alpha channels work with normal maps? Is there a way around that without having to create another texture?
When the textures are added into Unity, and are marked as normal map, Unity will pack it into a new texture, where it does this:

R -> G
G -> A
B -> -
A -> -

It puts the red channel in the green channel of the new texture.
It puts the green channel in the alpha channel of the new texture.
It dumps the data in B and A.

When it's in the shader, the normal is unpacked using G and A, and then it reconstructs the Z (B) channel of the normal map. Unity does this to increase the precision and quality of the normal maps, but the data in the alpha channel is lost in the process.

You can do your own normal map unpacking. If you add a Texture 2D node, and use a texture that isn't marked as a normal map in the texture import setting, and don't mark it as a normal map in the Texture 2D node either, you can unpack RGB using the Remap node (R + LMB), set it to [ 0 to 1 ] -> [ -1 to 1 ], and then plug it into the normal input. With this approach, you're saving the alpha channel as well :)

Hope that answered your question!
That definitely answered my question! Thanks for that, I really appreciate the help