CSC 418/2504 Fall 2001: Ray-tracing project
For this project, no skeleton code is provided, but the implementation
should be relatively straightforward. Here are some suggestions on
organizing your code:
- Use object-oriented (C++) programming.
- Each kind of object in the scene should probably be a class. It
should include a method to do the following:
- intersect the object with a ray. There is some code for
intersecting:
and it should keep track of the following information:
- object material (colour)
- object's transformation matrix.
- object's properties (matte, opaque, transparent, etc).
- Intersection tests will return a hitpoint, a class which needs
associated information such as:
- the ray parameter "t" of the hitpoint.
- the surface normal (for lighting, refraction and
reflection).
- a pointer to the object, for other queries.
- The scene will keep track of objects and lights, and will need
methods to add objects to it. These methods may be invoked
through a parser that reads a scene description from a file (if
you feel very energetic), or may be invoked from a hard-coded
initialization function.
- Ray-tracing does not handle diffuse reflection efficiently. To
properly handle matte surfaces would require enormous numbers of
secondary rays per hit. Hence, follow this heuristic:
- If the surface is mirror-like or glass-like, spawn
secondary rays in the reflected and/or refracted
directions.
- If the surface is matte, do a global illumination
calculation, and return the ray's colour. Shadow rays are
used here.
In other words, don't keep following rays hoping to hit a
light. It will happen with zero probability (ie never), for
point lights.
- Here's a little hard-to-understand gotcha! that you will
probably run into: when a ray hits a surface, you obtain a hit
point. If you cast a secondary ray, it will start from the hit
point, and test all objects for intersection. Due to numerical
errors, the hitpoint may be slightly INSIDE the object, so the
math may yield an intersection with the same object again!
Hence, discard hits that are very close to the original hit
point.
Alejo Hausner,
Dept of Computer Science,
University of Toronto
Last modified: Tue Nov 20 17:34:33 EST 2001