C481 B581 Computer Graphics
Dana Vrajitoru

Ray Tracing

Global illumination model.
Consider the color of each pixel in the projected image as being determined by a ray of light arriving on this point according to the projection rule.
 

The Method

Recursive Reflection and Refraction

The algorithm
color trace(point p, vector d) { //page 658 in the textbook
  color local, reflected, transmitted;
  point q;  vector n;
  q = intersection(p, d, status);
  if (status == light_source)
    return light_source_color;
  if (status == no_intersection)
    return background_color;
  n = normal(q);
  r = reflect(q, n); t = transmit(q, n);
  local = phong(q, n, r);
  reflected = trace(q, r);
  transmitted = trace(q, t);
  return (local + reflected + transmitted);
}


The Ray
A ray is given by a starting point  (x0, y0, z0) and a unit vector (xd, yd, zd).
A point on the ray is defined by:
x = x0 + t xd
y = y0 + t yd
z = z0 + t zd
where t > 0.

The intersection between the ray and any surface S is given by the condition:
there exists t such that (x, y, z) is on S.
The problem of the intersection is in general complex.

Intersection with a Box

Intersection with a Sphere
A sphere is defined by a center (xc, yc, zc) and a radius r. Then the distance between the center of the sphere and the point on the ray is
d2(t) = (x0 + t xd - xc)2 +(y0 + t yd - yc)2 +(z0 + t zd - zc)2 = a t2 + b t + c
The minimum of this equation is obtained for tmin = -b/(2a) and the value is dmin = d(tmin)
If dmin <= r, then the ray crosses the sphere.
To compute the intersection, we must solve the equation  d2(t) = r2 .



Agent-Based RT

Ray Supersampling




Links:
POV Ray
http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtrace0.htm
Internet ray tracing competition.
http://www.youtube.com/watch?v=XVZDH15TRro
http://www.youtube.com/watch?v=mtHDSG2wNho

Photon mapping
http://www.youtube.com/watch?v=ReI7AsF3nnE
http://www.youtube.com/watch?v=uwDu_q212SY