COMP1011 Assignment 2 - 05s2
Computing 1A 05s2 Last updated Thu 13 Oct 2005 10:59
Mail cs1011@cse.unsw.edu.au

A First Taste of Ray Tracing


In this section we give you a brief overview of the ray tracing technique. We will go into more detail in later sections.

The essential idea behind ray tracing is to model the way the eye actually perceives three dimensional scenes. Light that enters your eyes can come from a variety of different directions and can have followed rather convoluted paths to get there, for example by bouncing off one or more reflective surfaces.

Take a ray, any ray, which enters your eye. How do we work out just where it came from? One method is to cast a ray outwards from the eye position and to see what objects it intersects with. If it intersects with, say, a green sphere you might guess that we should colour the final point green. But this is only true if there is a light source. Naturally, nothing can be seen in complete shadow.

So what we must now do is work out whether a ray coming from the point of intersection with the object reaches a light source. If it does, without intersecting with any other objects, we can then safely colour the point green. However, if it does not reach the light because it hits another object first we can no longer let that light source contribute directly to the colour of that point. This is not the end of the story though; light can still come from that light source indirectly.

What if this second object that the ray intersects with is reflective? Isn't it possible that light striking it bounces off it and reaches the first object? The answer, of course, is yes. So we can see quite clearly that ray tracing is an inherently recursive process. Light can reflect off any number of objects before finally reaching the eye. In fact, there are cases where light rays are reflected forever. In order to avoid infinite recursion, or recursion to an infeasible depth, we set a limit on the number of reflections we are prepared to trace before deciding that the ray in question is a lost cause and will not reach a light source in a resonable number of reflections.

But what do we do when there is more than one light source? The answer is simpler than it might first appear. We calculate the contribution of each light source individually and simply add them together.

In this section we have outlined the basic ray tracing algorithm:

Of course this is only for a single ray! To compose an entire image of the scene we must repeatedly cast rays out from the eye from the top-left of the view plane down to the bottom-right. Only then will we have an accurate picture of what the eye can see.

In the following sections we first describe some of the physics involved in ray tracing. We then go on to describe the ray tracing algorithm in more detail. Throughout the sections (especially those of the bonus part) we will introduce and refer to the mathematics of three dimensional geometry, which includes such terms as vectors, dot products and normals. To do this assignment you'll need to understand these basic concepts but you will not have to program them.

Bonus ONLY: The bonus sections give more details on the physics, including how colours are represented and how light source can contribute to the lighting of a scene. These are known as diffuse and specular reflections respectively. The bulk of the mathematical concepts introduced in this assignment specification will be provided in a library of functions (Physics) for your use.