Rendering Pipeline: Viewing: Geometry Processing Rendering Pixel Processing
Rendering Pipeline: Viewing: Geometry Processing Rendering Pixel Processing
For each pixel in the viewport, what is the nearest object in the scene?
(provided the object isn’t transparent)
Thus, we need to determine the visible surfaces.
Definition
Given a set of 3-D objects and a view specification (camera),
determine which lines or surfaces of the object are visible
canonical house
VSD algorithms
• We can broadly classify VSD algorithms according to whether they deal with
object definitions or with their projected images. Former is called object-
space methods and latter called image-space methods.
-Create drawing order, each poly overwriting the previous ones, that guarantees
correct visibility at any pixel resolution
-Strategy is to work back to front; find a way to sort polygons by depth (z), then draw
them in that order.
-do a rough sort of the polygons by the largest (farthest) z-coordinate in each poly
-scan-convert the most distant polygon first, then work forward towards the
viewpoint (“painters’ algorithm”)
-We can either do a complete sort and then scan-convert, or we can paint as we go.
Depth Buffer Method
• A commonly used image-space approach for VSD.
• Compares surface depth values throughout the scene for each pixel position
on the projection plane.
127127127127127127127255 127127127127127127127255
127127127127127127255255 127127127127127127255255
127127127127127255255255 127127127127127255255255
127127127127255255255255 63 63 127127127255255255255
+
127127127255255255255255 63 63 = 63 63 127255255255255255
127127255255255255255255 63 63 63 63 63 63 255255255255255
127255255255255255255255 63 63 63 63 63 63 63 63 255255255255
255255255255255255255255 63 63 63 63 63 63 63 63 63 63 255255255
void zBuffer()
{ int x, y;
for ( y = 0; y < YMAX; y++)
for ( x = 0; x < XMAX; x++) {
WritePixel (x, y, BACKGROUND_VALUE);
WriteZ (x, y, 1);
}
for each polygon
for each pixel in polygon’s projection {
double pz = polygon’s Z-value at pixel (x, y);
if ( pz < ReadZ (x, y) ) {
/* New point is closer to front of view */
WritePixel (x, y, polygon’s color at pixel (x, y));
WriteZ (x, y, pz);
}
}
}
Z-Buffer Applet:
http://www.cs.technion.ac.il/~cs234325/Homepage/Applets/applets/zbuffer/
GermanApplet.html
– Once we have za and zb for each edge, can incrementally calculate zp as
we scan
– Simplicity lends itself well to hardware implementations: FAST
• used by all graphics cards
– Polygons do not have to be compared in any particular order: no
presorting in z necessary.
– Only consider one polygon at a time
• brute force, but it is fast!
– Z-buffer can be stored w/ an image; allows you to correctly
composite multiple images (easy!) w/o having to merge models
(hard!)
• great for incremental addition to a complex scene
– Can be used for non-polygonal surfaces, CSGs, and any z =
f(x,y)
– In some systems, user can provide region to z-buffer, thus saving
computation time.
– Also, z-buffer can be performed for a small region and moved
around to finish the entire viewport
A-Buffer
• A drawback of the depth-buffer is that it identifies only one visible surface at
each pixel position. i.e. it deals with only opaque surfaces.
-Ray casting is based on geometric optics, which trace the paths of light rays.
-It is a special case of ray-tracing algorithms that trace multiple ray paths
to pick up global reflection and refraction contributions from multiple objects
In the scene.
-Consider the line of sight from a pixel position on the view plane through
the scene, we can determine which objects in the scene (if any) intersect.
-After calculating all ray-surface intersections, we identify the visible surface
as the one whose intersection point is closest to the pixel.
-It works with any primitive; we can write intersection tests for.
- But it is slow