# CS488 - Introduction to Computer Graphics - Lecture 25

## Review

1. Intersection tests
2. Anti-aliasing
3. Office hours

## Ray Tracing

#### Distribution Ray Tracing

What's wrong with

1. Beam tracing
2. Super sampling
3. Stochastic sampling

It doesn't try explicitly to put the work into the places that make the most difference.

Trying to do so we should get heuristics like

• If <xxx> is important, then put extra rays into <yyy>.

Here are a few such heuristics

Distribute carefully over

1. Reflection directions <==>
• you want better highlights.
• Why would you want better highlights?
• How would you do this?
2. Area lights <==>
• you want soft shadows
• Why would you want soft shadows?
• How would you get them?
3. Aperture <==>
• you want depth of focus effects
• Why would you want depth of focus effects?
• How would you get them?
4. Time <==>
• you want motion blur.
• Why would you want motion blur?
• How would you get it?

All these techniques are inordinately expensive!

## Lighting

The caustic project.

What is a caustic?

#### Bidirectional Ray Tracing

Recursive ray tracing makes a tree with a big fan-out: Cost ~ exp( n*d ,) where d is the depth, n is the fan-out.

• n is big, so it's worth getting d down.

Bright idea

1. Trace out from eye
2. Trace out from sources of illumination
3. Match the rays in the centre ... somehow!
4. The resulting double cone gets the same performance at Cost ~ exp( n*d/2 ), which is surely worth it.

The problem is step 3. How do you match the rays? The current state of the art is photon mapping. Here's how it works.

From every light source

• send out rays in `randomly' chosen directions
• For each ray
• Follow it until it hits a surface.
• If the surface is reflective
• Send out a ray in the reflection direction
• If the surface is not reflective
• Accumulate a pool of illumination
• Send out a ray in a randomly chosen direction
• Continue following rays until ...

For each pixel

• Cast a ray into the scene
• When it hits a surface, use the light you find accumulated there for the illumination in your lighting model

Notice tuning and calibration needed.

What creates the caustics?

#### Participating Media

What is fog?

• Lots of little water droplets
• Light gets scattered

What is beer?

• Lots of little colour centres
• Light gets absorbed

What they have in common is

• The farther light goes the more likely it is to get scattered or absorbed.
• The property is described by Beer's Law (named after August Beer, no relation)
• I(x) ~ exp( -k(\lambda) x )

What happens to the light that doesn't make it through?

## Surface Properties

#### Texture Mapping

1. Basic
1. Start with a 2D image: pixellated or procedural
2. 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.
3. Backwards map intersection point with ray into the image to get the surface properties
2. Normal Mapping (Bump mapping)
1. Start with a difference surface, defined with respect to the surface
2. Calculate the normals to the difference surface and map them onto the surface of the primitive
3. Use the mapped surface models for lighting
4. No occlusion, shadows are wrong, silhouettes are wrong, nobody notices!
3. Solid Textures
1. Solution to mapping texture onto curved surfaces
2. Usually procedural