# Clamp light before modulating w/ albedo?

## Recommended Posts

jaafit    116
Should I clamp my light value (diffuse + ambient) before modulating it with albedo? Same question in HLSL: Is it
output.color0 *= saturate(diffuse + ambient);
or
output.color0 *= (diffuse + ambient);


I notice that if I don't saturate, the color contrast increases but the color hues are often wrong. For instance, let's say I have a diffuse of 1.0, ambient of 0.25 and two colors on my object, one being grey (0.5,0.5,0.5) and the other being red (1.0,0.1,0.1). If I clamp (diffuse + ambient), the multiplicand becomes 1.0 and the colors stay the same. The end result looks too dark. If I don't clamp (diffuse + ambient), the multiplicand becomes 1.25 and the grey becomes lighter gray while the red becomes pink. The end result is brighter; gray becoming light-gray is good but red becoming pink looks odd. [Edited by - jaafit on August 13, 2008 6:21:12 PM]

##### Share on other sites
There is no "right way".. do what looks best to you.

However, you really should saturate the added parts in my opinion, and then brighten up the result..like:

output.color0 *= saturate(diffuse + ambient);
output.color0 = saturate(output.color0*2);

this way you may get better hues but brighter.. I think this is equivalent to the multiply2X fixed function command in D3D.

##### Share on other sites
ViLiO    1326
You could also use an exposure function to bring your colour values back into range instead of just clamping/saturating them.

Regards,
ViLiO