Layering your renders
Performance wise, adding more triangles is not always the best solution. Each vertex of a triangle will be projected and the triangles need to be drawn on your screen. More triangles means more work for the CPU to render. An alternative to adding more triangles is to use viewport layers. Viewport layers are nested and extended sprites of a viewport. Essentially, these layers work the same as layers in programs such as Photoshop and Flash. In Photoshop, each layer can hold a single element or a composition of elements. With layers in Papervision3D, we can do the same. We can, for example, render a chair on one layer and a table on another. The order of each layer can either be defined manually or automatically, using the algorithms provided by Papervision3D.
To demonstrate each approach, we'll reuse the animated mill that was introduced in Chapter 8, External Models, and place it on a ground surface, which will immediately reveal serious z-sorting problems. Let's first...