i
i
i
i
i
i
i
i
13.3. Constructive Solid Geometry 309
This brings up a very important point: the ray direction b must not be re-
stricted to a unit-length vector, or none of the infrastructure above works. For this
reason, it is useful not to restrict ray directions to unit vectors.
13.3 Constructive Solid Geometry
One nice thing about ray tracing is that any geometric primitive whose intersection
with a 3D line can be computed can be seamlessly added to a ray tracer. It turns
out to also be straightforward to add constructive solid geometry (CSG) to a ray
tracer (Roth, 1982). The basic idea of CSG is to use set operations to combine
solid shapes. These basic operations are shown in Figure 13.6. The operations
can be viewed as set operations. For example, we can consider C the set of all
points in the circle and S the set of all points in the square. The intersection
Figure 13.6. The ba-
sic CSG operations on a 2D
circle and square.
operation C ∩ S is the set of all points that are both members of C and S.The
other operations are analogous.
Although one can do CSG directly on the model, if all that is desired is an
image, we do not need to explicitly change the model. Instead, we perform the set
operations directly on the rays as they interact with a model. To make this natural,
we find all the intersections of a ray with a model rather than just the closest. For
example, a ray a + tb might hit a sphere at t =1and t =2. In the context
of CSG, we think of this as the ray being inside the sphere for t ∈ [1, 2].We
can compute these “inside intervals” for all of the surfaces and do set operations
on those intervals (recall Section 2.1.2). This is illustrated in Figure 13.7, where
the hit intervals are processed to indicate that there are two intervals inside the
difference object. The first hit for t>0 is what the ray actually intersects.
In practice, the CSG intersection routine must maintain a list of intervals.
When the first hitpoint is determined, the material property and surface normal is
that associated with the hitpoint. In addition, you must pay attention to precision
issues because there is nothing to prevent the user from taking two objects that
abut and taking an intersection. This can be made robust by eliminating any
interval whose thickness is below a certain tolerance.
Figure 13.7. Intervals are
processed to indicate how
the ray hits the composite
object.
13.4 Distribution Ray Tracing
For some applications, ray-traced images are just too “clean.” This effect can be
mitigated using distribution ray tracing (Cook et al., 1984) . The conventionally
ray-traced images look clean, because everything is crisp; the shadows are per-