A common problem with a software 3D rendering is deciding the order in which triangles are drawn. Why is this important? It’s important because those triangles furthest from the camera need to be drawn first, so those closer to the camera can draw over the top of them.
Imagine you were painting a house standing alone in a field against a mountain backdrop. The first thing you would paint is the sky, and then the mountains. This would give you a backdrop. To this scene you would paint the field, and those trees behind the house. Then you would paint the house, followed by the trees in front of the house. This is just common sense: those objects closest to the viewer should be painted last, and therefore painted over the more distant objects. Imagine if you painted the house first and the mountains last – you would paint the mountains right over the house and not see the house at all.
Rendering a 3D scene is very similar to painting. In the same way that the more distant mountains are painted first and then the house is painted over the top of that image, the most distant polygons that make up the scene should be rendered before those closer to the camera.
It seems like a simple concept right? But what about polygons that intersect? Look at the highlighted area in the image below.
Here we have a vertical plane intersecting a horizontal plane. Who is behind who? The answer is that the planes are both in front and behind each other at the same time. And as you can see, the standard Papervision renderer does not handle this situation very well. This is because Papervision assigns a single value to each polygon which represents it’s depth in the scene. Obviously this single value can not represent the fact that a polygon can be both behind and in front of another at the same time, leading to the situation in the screenshot: one polygon is calculated to be behind (or in front), and is rendered as such.
Now take a look at this screenshot.
Notice the difference? The horizontal plane now intersects the vertical plane as you would expect. This is thanks to the QuadrantRenderEngine: a new renderer in Papervision that will split intersecting polygons so they are drawn properly. You’ll also notice that, in addition to the polygons intersecting properly, that the vertical plane has also been split up into several smaller polygons. This is necessary for the rendering process, but these additional polygons have the drawback of incurring a performance cost.
In the demo application you can switch between the basic and Quadrant rendering engines by toggling the checkbox in the top left hand corner of the screen. It makes it easy to see the difference that the Quadrant rendering engine makes.