CS488 - Introduction to Computer Graphics - Lecture 21


Ray Tracing

Intersection Tests

Eye-pixel ray

E + t*(P - E)

Object in scene

Set of points {Q} satisfying

Solve the equation

Another idea: intersect in object coordinates


Shading for Ray Tracing

When we have found the intersection point we need to calculate a colour.

We know

  1. The eye ray, e = Q-E
  2. Surface properties
  3. The normal vector, n

For each light

  1. Calculate illumination: RGB - the colour, l - the light ray
  2. Accumulate outgoing light
for ambient
   use surface RGB and illuminant RGB to calculate colour
for each source of illumination
   calculate the illumination of the intersection point by the source: RGB
   calculate the direction of the illumination, l
   use e, n, l to calculate intensity of light along eye ray
      -- probably using Phong lighting model
   use surface RGB and illuminant RGB to calculate colour
   add to colour

How about shadows?

Illumination may be blocked by occluding objects

In principle,

  1. Do an intersection test from the light
  2. If it hits the eye ray intersection, then

    else

Add the the code above

   cast a ray from the illuminant in the direction of the intersection
   if first point intersected is the intersection then

In practice this means

  1. Translate the illuminant to the origin
  2. Run the usual intersection code using l

How about reflections?

Just extent the eye ray into the virtual world behind the mirror

In practice this means

  1. Translate the intersection point on the mirror to the origin
  2. Run the usual intersection code using e = e - 2 n \dot e

Recursive Ray Tracing

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

  1. Unusual light paths for illumination, such as colour bleeding, reflection

Transforming Surface Normals

The tangent plane (space)

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

Calculating the tangent plane in practice

Either

Or

  1. Choose two points, Q1 & Q2, slighty away from Q in different directions
  2. The points must lie on the surface: f(Q1) = f(Q2) = 0
  3. The plane spanned by Q-Q1 and Q-Q2 is an approximation to the tangent plane

The normal vector

The normal vector is the outward facing unit vector perpendicular to the tangent plane.

It is defined by

  1. |n| = 1
  2. n \dot t1 = 0
  3. n \dot t2 = 0

t1 & t2 can be the vectors Q-Q1 & Q-Q2.

In practice

  1. 2 & 3 are linear equations
  2. Solve them up to a constant
  3. Use 1 to set the overall normalization

Transformations

Transforming the normal vector

  1. Under an affine transformation, M, Q goes to MQ, and Q' goes to MQ'.
  2. The new tangent, n1, is defined by n1.M(Q'-Q) = 0.
  3. u \dot Mv = 0 if and only if inv(transposeM)u \dot v = 0.
  4. Therefore n' = inv(transposeM)n is the transformed normal vector.

Most of the time this doesn't matter, but ...


Modelling

Constructive Solid Geometry (CSG)

Geometric primitives can make other geometric primitives by

  1. union
  2. intersection
  3. subtraction

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

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, ...
    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


Return to: