Multipass Lighting

Typical graphics hardware is limited to 8 OpenGL light sources being used at one time.

We can get around this limit by rendering the scene multiple times, and combining the results.

Normally, when multiple light sources are used, their contributions to objects' colors are simply added together. Adding together separate renderings will have the same effect.

In this case, we draw the scene several times, using glDepthFunc(GL_EQUAL) as in the previous example.

The blending function glBlendFunc(GL_ONE, GL_ONE) will add the multiple renderings together.

(Watch out for the global ambient light level - turn it off using glLightModelfv, so that it isn't added in multiple times.)

Example: multilight.cpp



next