- Home /
What does the "alpha is transparency" setting actually do?
I know this seems very obvious, so please hear me out.
Most transparent shaders read the alpha value of textures to determine cutoff or translucency when drawing to the screen. This data is already a part of the texture, so what does this import setting actually accomplish?
If I import a texture with a proper alpha channel, I have to check this import toggle for my transparent shaders to make use of it. I understand there are cases where having the alpha channel represent other 0...1 data would be useful, but wouldn't that alternate usage take place in the shader logic?
So, what's the intended purpose behind giving us this option at all? And what actually happens to my texture's alpha channel when it's not checked? How does the shader know, one way or the other? I use it 100% of the time, IIRC.
Answer by LukaKotar · Oct 29, 2014 at 12:17 AM
Release notes for Unity 4.2 state: "Texture importer now has "Alpha is Transparency" setting, which does color dilation to fix edge artifacts on semitransparent textures. It is enabled by default for GUI textures."
It also shows a nice transparent thumbnail in the project view when checked. You should enable it for textures you want to use as transparent. For textures just simply needing the alpha channel, you don't need to check that option. For example, Unity's default specular shaders use the alpha channel to map out the specular (specular map).
"color dilation to fix edge artifacts" -- okay, I'll buy that. $$anonymous$$y apologies for not thinking to check the release notes.
I'm still unclear on what actually happens behind the scenes to a texture's alpha channel when the option is unchecked (it's as if the alpha channel were full white, like the alpha channel is overridden), but this was just a curiosity, after all.
I don't know what exactly it does behind the scenes, but it seems to fix the semi-transparent outlines of textures. Doing a bit of testing, there is an (unintentional) outline visible when I don't check that option:
I really appreciate your time and investigation!
I recall that before this option was available, I never had a problem with the artifacts depicted on the left. And in my experience, I've never encountered a need to not enable the option, which left me wondering why it exists to begin with.
I'll just accept "some internal howd'yado" and be content to click it each time I import something. :)