I am currently working on writing a shader for combination lighting. The idea behind it is to apply directional light, point light, and spot light in a single pass. I believe I can do this by:

  • Calculate the color after directional light is applied.
  • Calculate the color after the point light is applied.
  • Calculate the color after the spot light is applied.
  • Return the final color of the pixel.

I believe this will allow me to have multiple point and spot lights that effect the pixel currently being handled by the pixel shader.

I believe the math for this will be:

return directional + pointLight + spot;

However, my concern is that this will create just a solid white object and I am unsure as to how to prevent that. Maybe each portion is normalized to a specific percentage of full intensity and the result would be:

directional = calcDirectional() * 0.3f;
pointLight = calcPoint() * 0.3f;
spot = calcSpot() * 0.3f;
return direction + pointLight + spot;

But again, I am not 100% sure on this.

What is the proper way to additively calculate colors in this scenario?


1 Answer 1


You just add the contributions from each light source. No normalization or reweighting required.

Think about light in the real world. If I shine a flashlight onto an object, it doesn't darken the light from the sun bouncing off of it. All I can do is light the object up more - pour on more photons, and more photons bounce off.

If you find your objects get too bright doing it this way, then you need to either...

  • move to an HDR system and tonemap the resulting out-of-range colours back down into your device's representable range at the end (games that have a high contrast and simulated eye adaptation between dark interiors and bright exteriors often work this way), or

  • reduce the intensity of your lights / make their falloff sharper so you get less total light landing on the object.


You must log in to answer this question.