- Home /
Why additive particle shader with transparent and non-transparent textures in linear color space look differently?
I have a project that uses Linear Color Space instead of the default Gamma Color Space. I've made an image in Photoshop and saved it with (no background) and without (black background) transparency. Then I've created new material using shader "Particles/Additive". I've noticed, that material with transparent texture looks much different than the one with black background (see screenshots below).
(with non-transparent texture:)
(with transparent texture)
Materials with both the textures look identically in Gamma Color Space. But I need exactly Linear Color Space. I'd like the material with the transparent texture to look as material with non-transparent texture does.
Do anybody have an idea ohw to achieve this and why it renders as it currently does?
Answer by Remy_Unity · Apr 25, 2018 at 07:57 AM
I did the test, and I think what you see is happening because your texture are imported as sRGB textures:
You must know that the alpha channel is always stored in linear. So, if the textures are sRGB it's normal to have a difference in the two renders, because the additive blending is done this way : finalColor = backgroundColor + tint * textureRGB*textureAlpha.
On the one without alpha you only have white pixels with a linear alpha, and without alpha you have RGB values in gamma space and a "white" alpha.
You now have two solutions : use the version without alpha if possible, or author your texture with alpha to compensate this linear/gamma difference.
This can be done by blending a black layer with the inverse of the alpha as a mask, and at about 50%. Here's my layout in photoshop:
@Remy_Unity, thanks for response, it's helpful and informative! I've tried your solution and it works, but in this case I need to create absolutely new texture that is partially alpha and partially with black background. I prefer to leave my textures clear.
Finally I've made my own shader for additive blending. The shader simply does pow(alpha, 1.5) - and I have the look I expected before. Yes, it's more expensive in context of GPU computations, but on the other hand I don't need to replace all my transparent textures with new ones.
You could also keep your texture clear and apply a linear to gamma correction to the alpha channel in your authoring app.
If you're working with photoshop I recommand you to get the free plugin SuperPNG http://www.fnordware.com/superpng/ to be able to author easilly the alpha channel (like you would when exporting TGA files).
Use "Image/Adjustments/Exposure" and set the "Gamma Correction" to 0.45 (=1/2.2).
Your answer
Follow this Question
Related Questions
How to fix transparent rendering problem 3 Answers
Transparency from light shader 1 Answer
Transparent material on iPhone Android 3 Answers