Situation:
my transparent shader is using:
Blend SrcAlpha OneMinusSrcAlpha
BlendOp Add
I have another material that is using Standard shader. It is behind the transparent material. If I enable emission on the 2nd material, and I set the transparent material’s alpha channel > 1, then color of the 2nd material is inverted: (e.g purple → yellow)
Why it happens:
The reason this happens, is because the blending equation for the transparent shader is:
finalValue = sourceFactor * sourceValue operation destinationFactor * destinationValue
(see: Unity - Manual: Blend command in ShaderLab reference)
The destinationValue
is the value already in the destination buffer, which contains the purple object, because it is in the Geometry queue, and the transparent material is in Transparent queue.
When alpha channel > 1, the destinationValue is multiplied by a negative value, causing it to invert.
What I don’t understand:
If I disable the 2nd material’s emission, and I only use Albedo, the transparent material doesn’t invert the color anymore for alpha > 1.
Is the albedo not in destinationValue for some reason?
Video:
It first shows how the color isn’t inverted for when no emission is used, and how it is inverted when I turn emission on: