Shadowing. . .

What is the easiest way to put shadows into a program? What about making fog? Thanks!

Hi,

Basic fog can be enabled with glEnable(GL_FOG) and adjusted with glFog* commands.

Unfortunately there’s no easy way to get shadows. Two algorithms are well suited for realtime purposes, stencil shadows and shadow maps (search). Both are about as easy to implement, but they both their own drawbacks, so which one you should choose depends on the application. There are also more limited algorithms, but personally I don’t find them any easier than the “good” ones.

-Ilkka

Originally posted by Nelah:
What is the easiest way to put shadows into a program? What about making fog? Thanks!

To do basic fog you just enabled it, like enabling smooth shading. Very easy as others have said.

Shadows… OpenGL doesn’t do shadows. At least not real shadows. As others have said there are basically two ways. Neither works correctly 100% of the time.

Stencil shadows seem a bit more flexable, but are IMHO much more difficult to implement correctly for all cases. They fortunatly only require a stencil buffer to work (TNT era hardware had this)

Shadows maps are IMHO much much much easier to implement. If your app already has a function to DrawScene() then shadow maps are super easy. You just call draw your object/scene to the shadow map and then draw your scene like normal, but with the shadow map applied.

Both solutions involve you doing work to compute the shadow rather than letting OpenGL just turn shadows on.
http://developer.nvidia.com/view.asp?IO=ogl_rtt_shadow http://developer.nvidia.com/view.asp?IO=Shadow_Map