description.
Functions were written to render lines and polygons that overlap correctly depending on their distance from the viewer in 3D space, using depth information at each vertex that could be the output of a perspective projection algorithm.
the inverse Z buffer algorithm.
As we intend to build an integrated 3D graphics system using perspective projection, and as inverse depth values interpolate linearly in perspective-projected images, we created a buffer with an entry for each pixel in the image being rendered that stores the inverse of the depth value of the object in the image that has been rendered at that pixel that is closest to the viewer. Each time an object is rendered in the image, for each pixel being set, the inverse of the depth of the object at that pixel is taken and compared to the inverse depth stored in the buffer. If the inverse of the depth at that pixel of the object being rendered is greater than the inverse depth stored in the buffer, meaning that the object being rendered is closer to the viewer at that pixel than any other object that has been rendered at that pixel previously, then the setting of that pixel to the color of the object being rendered proceeds, and the inverse depth value in the buffer is updated to the inverse of the depth of the object being plotted at that pixel. Otherwise, nothing happens, because the object being rendered is, at that pixel, behind some other object that has previously been rendered. The pixel retains its previous color and the inverse depth buffer maintains the inverse depth value of the older and closer object at that pixel.
- If we were using parallel projection, then depth would vary directly in proportion to changes in X and Y location, since parallel projection is simply ``flattening'' objects.
- In addition to a function for drawing polygons that correctly overlap, we also implemented a function to draw lines that intersect objects correctly in 3D space, which is demonstrated in the images below.
- Stay tuned to see if these functions get integrated into an exciting, fantastic 3D modeling system!
images.
Demonstration of Line Drawing.
The required image of triangles with radial lines added at a depth of 12.5, at its normal size and four times larger in each dimension.
Tetrahedra Through the Looking Glass.
Oooh, an animation. Frame and solid tetrahedra sliding through a transparent surface. Note that we don't have an a-buffer for transparency, there's just one transparent rectangle that's the last thing drawn in each frame. Also note that the data for this image did not come from a perspective projection algorithm, but from a sketch on graph paper.
|