I decided to use this assignment to take a shader based approach to my course project. My course project has the lofty goal of re-lighting and shadowing pre-rendered scenes with interactive objects.
My shader based approach is to pre-render the scene into a backdrop (or skybox, if done 6 times) and in addition to the color textures have position/depth (and possibly normal, etc.) textures. This allows composting (depth values are preserved), but also allows one to shadow the background if contribution from each light is maintained separately.
To do this we need: color map of scene from ambient contribution, color map of scene with each lights contribution and self shadowed. Finally we need a position or depth map. Note that this requires that the positions of lights be known in advance (dynamic shadowing, but not re-lighting). Some representation of the geometry seems to be necessary to perform re-lighting and maintain self-shadowing.
The aforementioned design is fairly vague and lofty. In reality I was able to get a scene rendering into a framebuffer object and then render that as a quad (one face of a skybox) using a shader to calculate color and depth values from the store textures.
I was then able to render new geometry over the plane and have it correctly depth tested as if the pre-rendered geometry was there. (Note: there is still something wrong in my calculation because the new geometry does not show up at quite the depth I expect.)
Anyway, here's the horrendously anti-climatic screenshot. Very low work/impressiveness ratio. The green ground plane and the red teapots were pre-rendered into the backdrop. The blue teapot was composited later, but appropriately occludes some objects and is occluded by others.
Everything was a problem. I was foolish enough to try this under Linux. The drivers are immature and tools are non-existent. Framebuffer objects and shaders are both finicky. I was never able to get it to run on my notebook (ATI X300) and it took a lot of tweaking to get it to run on my desktop (nVidia Geforce 6800). The biggest problems were floating point textures, framebuffer objects, and the shaders (specifically setting gl_FragDepth).
I also had strange behavior when disabling texturing AND disabling my shaders was not enough to keep it from attempting to texture my objects with whatever my shaders were previously accessing.
source code