I'm playing around with specular lights and now in doubt if I should multiply the specular term for directional and point lights, by the color of the light. If I understand correctly, then:
- for non-metals, specular highlights are 99% of the time 'white'
- for metals, the specular highlights are mostly the color the material itself
With this in mind my first thought would be to have 2 different shaders.
But I might have found a reasonable solution with relatively high performance benefits, where I need only single float for the specular component instead of float3's (what I would need when I multiply them all with the lightcolor).
- calculate specular terms for directional lights and point lights (single floats, no specific color)
- in calculation the final pixel color I do:
return float4((saturate(AmbientColInt + (MatDiff * (diffuseDir + diffusePoint)) + (MatSpec * (specularDir + specularPoint)) + MatEmi) * textureColor.rgb), textureColor.a);
Where I basically use the specular material value that determines the color of the highlights.
Say for glass I set it to 1.0 / 1.0 / 1.0 and for metal, to the actual color of the metal.
The only down side here is that I don't let the specular highlights be dependent of the actual light colors (IF it's a down side..).
What do you think?