Buffer Transform Matrix

To implement “automatic” shadows, one could add a few stages to the OpenGL pipeline. Suppose we render to an aux buffer, complete with color and depth (and stencil for effects). Then, without pulling the pixels back across the bus to the cpu, that buffer is transformed by a projection matrix and redisplayed in the front or back buffer. This fits with immediate mode, because only the values of the aux buffer are used, no scene info is required.

For shadows, we render the scene with ambient light to the back buffer. Then we glEnable the aux buffer stage and set the aux projection matrix to represent the transform from the light point of view to the camera view. Change the projection and model-view matrix to represent the light point of view and render as if one were doing a shadow map. The pixels accumulate in the aux buffer and are depth culled from the light’s point of view. When we glDisable the aux stage, those pixels are transfered to the back buffer, but transformed by the aux projection matrix, and culled by the normal depth buffer. Using blending of GL_ONE, GL_ONE, we have just lit our scene. For multiple lights use multiple passes with blending.

For ease of use, it would be possible to build in the function which calclates the transform matrix between two cameras (or the light and camera).