CS184 Section 9
Ray Tracing Basics

Brandon Wang
April 3, 2012
Material adapted from Fu-Chung Huang and Carlo Sequin.



Signal Intuition

Signal Intuition

Signal Intution


Little to no OpenGL.

Made from scratch.

Ray Tracing

OpenGL: Transform objects into unit cube, project unit cube onto image plane.

Ray tracing: Shoot rays from camera into the scene.

More expensive, but easier to model complex physics. More closely resembles actual physics. (The biggest difference is the direction of the ray)

Current research: real-time

Ray Tracing

Shooting Rays


\vec{r} = \vec{a}+t\cdot\vec{d}

Hitting an object

For now, loop over all objects, figure out if the ray intersects it. (Next week, do something smarter.)

Imagine a world of spheres only - center and radius. Intersection is if the ray comes closer than radius to sphere.

For transformations, transform the ray to object space to. (This is done so you don't have to write arbitrary intersection tests, only with your primitives)

Once you do spheres, move on to boxs and/or triangles, and other shapes if you wish.

Hitting an object

Computing Lighting

Computing Lighting

You've already done this! Phong illumination model. (Review old slides when implementing)

If you stop here, you will get quality similar to OpenGL. This is called ray casting.

Computing Lighting

Computing Lighting

But if you recurse, you can do nice things.

Shoot a ray from the point of intersection to...

In Implementation...

It will be a bit more difficult to get started with this, as you start from scratch.

  1. Get the BSOD. (Black image output.) Start with eye position, image plane corners, and image dimension.
  2. Make a primitive shape (sphere, triangle, or even circle). Write the ray-primitive intersection, but make it return some color for intersection. (Don't write the Phong stuff yet - make sure your geometry is right).
  3. Transform the primitive (scale, rotate, translate, etc). Make sure your rays are being transformed correctly
  4. Phong illumination model
  5. Shadows
  6. Acceleration structures (Next week)
  7. Fancy stuff (Your own leisure)

Raytracing Journal

I've heard that this is useful.

Raytracing Journal




And the more fancy...

Soft Shadows

Motion Blur

Subsurface Scattering

Global Illumination


Animated Movie

And anything else you can think of...