Graphics Reference
In-Depth Information
Shapes as simple as a sphere fall into this category. In that case, ray casting seems
like a very good strategy because you can simply replace ray-triangle intersec-
tion with ray-sphere intersection. Any micro-optimization of a rasterizer must be
evaluated compared to the question, “What if we could render one nontriangu-
lar shape, instead of thousands of small triangles?” At some point, the constants
make working with more abstract models like spheres and spline surfaces more
preferable than working with many triangles.
When we consider sampling visibility in not just space, but also exposure
time and lens position, individual triangles become six-dimensional, nonpolyhe-
dral shapes. While algorithms for rasterizing these have recently been developed,
they are certainly more complicated than ray-sampling strategies. We've seen that
small changes, such as inverting the order of two nested loops, can yield signifi-
cant algorithmic implications. There are many such changes that one can make to
visibility sampling strategies, and many that have been made previously. It is prob-
ably best to begin a renderer by considering the desired balance of performance
and code manageability, the size of the triangles and target image, and the sam-
pling patterns desired. One can then begin with the simplest visibility algorithm
appropriate for those goals, and subsequently experiment with variations.
Many of these variations have already been tried and are discussed in the liter-
ature. Only a few of these are cited here. Appel presented the first significant 3D
visibility solution of ray casting in 1968. Nearly half a century later, new sampling
algorithms appear regularly in top publication venues and the industry is hard at
work designing new hardware for visibility sampling. This means that the best
strategies may still await discovery, so some of the variations you try should be of
your own design!
15.10 Exercises
Exercise 15.1: Generalize the Image and DepthBuffer implementations into
different instances of a single, templated buffer class.
Exercise 15.2: Use the equations from Section 7.8.2 to extend your ray tracer
to also intersect spheres. A sphere does not define a barycentric coordinate frame
or vertex normals. How will you compute the normal to the sphere?
Exercise 15.3: Expand the barycentric weight computation that is abstracted
in the bary2D function so that it appears explicitly within the per-pixel loop. Then
lift the computation of expressions that are constant along a row or column out-
side the corresponding loop. Your resultant code should contain a single division
operation within the inner loop.
Exercise 15.4: Characterize the asymptotic performance of each algorithm
described in Section 15.6. Under what circumstances would each algorithm be
preferred, according to this analysis?
Exercise 15.5: Consider the “1D rasterization” problem of coloring the pixel
centers (say, at integer locations) covered by a line segment lying on the real num-
ber line.
1. What is the longest a segment can be while covering no pixel centers?
Draw the number line and it should be obvious.
2.
If we rasterize by snapping vertices at real locations to the nearest inte-
ger locations, how does that affect your answer to the previous question?
 
 
Search WWH ::




Custom Search