Better Shadows With Shadow Volumes

Shadow volumes offer an improvement over the simple shadows described above. Shadow volumes can be used to cast shadows over any object, not just flat planes. In addition, shadow volumes will cast shadows over all objects in the simulation, not only on a single "ground" object. This means that with shadow volumes, all objects cast shadows on all other objects.

Because shadow volumes can be drawn onto non-flat objects, shadow volumes are the only way to draw shadow onto terrains ([link])—simple shadows will not work.

There are, of course, a few disadvantages with this approach. One problem is that shadow volumes cannot correctly draw shadows for bitmapped objects. Bitmapped objects will get shadowed as spheres when using shadow volumes. Another issue is that shadow volumes are often slower than simple shadows. The exact performance hit depends on the number and complexity of objects in your simulation, but is often negligible. The final disadvantage of shadow volumes is that they are more prone to visual artifacts than simple shadows.

In spite of these disadvantages, shadow volumes offer far more realistic shadows than the simple shadows described above. Unless it's important to render accurate shadows of bitmapped objects, shadow volumes are recommended over simple shadows. To use shadow volumes, you'll need to enable lighting, and then enable the shadows using the Control.tz method enable-shadow-volumes. Shadow volumes can be disabled using disable-shadows-volumes.