Shadows are an important aspect of our perception of a scene. Without shadows, objects seem to "float" above the ground, because we can't relate the position of the objects and the ground. | |
No Shadows |
Decal shadows: draw something
dark (usually an alpha-blended textured quad) on the ground plane beneath each object.
|
|
Decal Shadows |
Projected shadows: squish
actual world geometry down onto ground plane, and draw it dark.
|
|
Projected Shadows |
Projected shadows with stencil: like projected shadows, but avoids drawing the same part of the ground twice by first rendering the geometry to the stencil buffer, then drawing where the stencil is set. | ||
Stencil buffer |
Projected w/ Stencil Shadows |
Shadow maps: render world from
point of view of light source, storing the depth to the topmost (and only lit) object.
When rendering, check the depth to the light source: if on top of the
shadow map, you're lit, if beneath, you're in the dark.
Here's a nice tutorial on shadow mapping from CMU, with more pictures. |
|
|||||
Shadow Map Shadows |
Shadow Volume Silhouettes |
Shadow Volume Stencil Buffer Totals |
Shadow Volume Shadows |
I've also written a little global illumination system based on a
conetracing-like idea, but for polygons. The shadows look great, but they're about the limit
of scene complexity the system can handle at reasonable speed!
"Sun" light: small orange light source |
Sun and sky together |
"Sky" light: big blue source |