Colors Math & CG Shaders

A while ago I ran into one of those rare problems with very little traction / accurate information on StackOverflow. So I went through the motions to find a solution and document it as best I could.

Months later my response started heating up, and I felt this would be a great opportunity to do a brain dump.

Question: Is white the best base color to start with when planning to shade sprites?

Unity colors have 4 float values typical of many color formats RGBA, corresponding to the individual percentage color values Red, Green, Blue and the Alpha transparency channel.

Also as mentioned above the default "Tint" applied by Unity is a multiplicative shader Photoshop calls this effect "Multiply" and the process is literally multiplying the color values in the pixels of your sprite with the color value selected.

The problem with this is, a Multiplicative color math shader will ALWAYS produce the same hue (if you "multiply" by white) or darker / muddied color if you multiply by anything else. I came across the situation where I wanted the exact opposite effect in a blacksmithing type situation.

Heated metal should have the appearance of being brighter and looking Hot. But the product of Multiplying Gray Metal by Yellow will always produce a darker hue:

multiplicative shader by Yellow

Instead, I chose to solve this problem by rewriting Unity's default Tint (Multiply) Shader to instead be an Additive Shader. The results were more along the lines of what I was looking for:

additive shader

But what about Alpha?

The one MAJOR requirements difference between an additive and multiplicative shader is dealing with transparency.

fixed4 frag(v2f IN) : SV_Target {    
    fixed4 c = tex2D(_MainTex, IN.texcoord);
    if ( c.a >= 0.1 ){
        c = c + IN.color;
    c.rgb *= c.a;
    return c;

In the additive shader, I set a 10% cut off to maintain the relative alpha of pixels with low opacity. You don't have to worry about this sort of thing on a multiplicative shader due to the nature of that math.

Please find a full Gist to source of my rewritten Sprites-Additive.shader if anyone is interested.

Here is a good reference on color terminology and modes: