Shadows and Reflections

breve's visualization engine offers support for both shadows and reflections. These graphical effects not only make a simulation look better, they also enhance the benefits of visualization as an aid to understanding and discovery of simulation behaviors.

Reflections and shadows are quite simple to set up. For reflections, there is a single technique; for shadows, there are two techniques to choose from. These techniques are outlined below.

Setting Up Reflections

The first step to setting up shadows or reflections is to set up lighting as described in the previous section (the section called “Lighting”). The next step is to pick the "floor" object to "catch" the reflections. The reflection-catching object must be a stationary object with one face pointing upwards on the Y-plane. Any unrotated rectangular solid should work just fine. You can specify the ground object using the Stationary.tz method catch-shadows. In spite of its name, this method is used to specify the ground floor for both shadows and reflections.

The final step in displaying reflections is to enable them, using the Control.tz method enable-reflections.

Reflections can be turned off later using the Control.tz method disable-reflections.

Simple Shadows

The first variety of shadows available in breve renders shadows onto a single ground plane, just as reflections are. This technique allows all objects, including bitmapped objects, to cast shadows onto the ground plane.

To setup these simple shadows, you'll need to set up the lighting and "shadow-catcher" plane as described in the previous section (the section called “Setting Up Reflections”). Once the lighting and ground plane are configured, simple shadows can be enabled using the Control.tz method enable-shadows, and later disabled using disable-shadows.

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 (the section called “Using Terrains With Physical Simulation”)—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.