# CS488 - Introduction to Computer Graphics - Lecture 15

## Comments and Questions

- Mid-term
- Hand back A3, project proposals

# Ray Tracing II

### Recursive Ray Tracing

Just what the name says, but why would you do it?

- Unusual light paths for illumination, such as colour bleeding,
reflection

### Surface Normals

Implicit surfaces, i.e., given by f(Q) = 0.

- Normal is perpendicular to the tangent space n . (Q' - Q) as Q' -> Q
for all Q' on the surface.
- Normal is grad f(Q) = i df/dx + j df/dy + k df/dz

Transforming the normal vector

- Normal vector, n, defined by nT.(Q1-Q) = 0
- Under an affine transformation, M, n goes to n', Q goes to Q' = MQ, and
Q1 goes to Q1' = MQ1.
- The new tangent, n', is defined by n'T.(Q1'-Q') = 0 = n'T.M(Q1'-Q).
- If n'T = nT M^-1 then the equation is identically true.
- Therefore, n' = (M^-1)T n.
- Notice the structure: contravariant versus covariant.

### Constructive Solid Geometry (CSG)

Geometric primitives can make other geometric primitives by

- union
- intersection
- subtraction

The result is like sculpting; the problem is that describing the result is
very difficult; the solution is

- Keep the combined primitives uncombined in the model
- Do the set operations on the ray
- Remember the normals

### Texture Mapping

- Basic
- Start with a 2D image: pixellated or procedural
- Map 2D image onto primitive using a 2D affine transformation
- Simple if the surface of the primitive is flat
- otherwise, ...
- Texture pixels normally do not match display pixels, so some
image processing may be needed.

- Backwards map intersection point with ray into the image to get the
surface properties

- Normal Mapping (Bump mapping)
- Start with a difference surface, defined with respect to the
surface
- Calculate the normals to the difference surface and map them onto
the surface of the primitive
- Use the mapped surface models for lighting
- No occlusion, shadows are wrong, silhouettes are wrong, nobody
notices!

- Solid Textures
- Solution to mapping texture onto curved surfaces
- Usually procedural

### Speeding Up Intersection Tests

- Bounding Volumes (usually Boxes)
- Find the smallest - or close to smallest - regular volume that
encloses the object
- Use ray-intersect-volume as a pretest for fast negative
results.
- Trade-off between
- benefit of quicker `miss' detection
- cost of getting a good bounding surface
- Both increase as complexity of primitive increases

Scene subdision

- Divide the scene volume into sub-volumes: many ways to do it, such
as
- quad-trees
- oct-trees
- BSP trees
- ...

- List all primitives by sub-volume.
- Only test primitives in the sub-volumes through which a ray
passes.

#### Return to: