We can "see" objects around us because light rays hit the object and travel to our eyes. Each object has a characteristic texture, color, shinyness which is a result of the way in which the light rays interact with the object. For example, a red object appears red because red light is reflected and blue and green light is absorbed. Mirrors reflect light essentially unchanged while objects with dull surfaces tend to disperse an incoming light ray in lots of directions.
Ray tracing is a method of generating realistic images in computer graphics by simulating the the interaction of light with surfaces. Light rays are emitted from light sources and are traced through the scene. The illumination and reflection properties of surfaces determine how the rays are reflected or transmitted at each intersection. The ray tracing process also results in realistic looking shadows and hidden surface removal.
The number of light rays we see are essentially infinite so we can not trace all rays. We are in fact only interested in those rays that reach our eyes. As a result we trace backwards, from our eye to a light source. If no such ray exists then we don't see anything.
Furthermore, when looking at a computer screen we are only concerned with what color to set each pixel on the screen. As a result, we really only care about the light rays that pass through a pixel on the screen and hit our eyes. Thus if we are drawing a sceen in a 100x100 window we really only need to trace 10,000 rays. Of course, this number is increased because each ray follows an eratic path as it is reflected off various objects.
Ray Tracing:
Models the physics of light and its interaction in an environment
Requires:
Global coordinate system
A scene containing objects - their shape and texture (i.e. how they interact with light)
Viewer - point of view
Image screen - an imaginary rectangular surface where the image will be "drawn". Points on the screen will correspond to pixels on your computer screen. It is like holding up a small window for you to look through.
Light sources - location and color
Forward in time - Process:
Light rays leave the light source and hit objects around the scene.
At each intersection, some of the light is absorbed, reflected, and transmitted.
Light rays that are reflected/transmitted continue on to possibly intersect with other objects.
Some of the rays make their way to the viewer's eyes where the rays are then "observed". It is these rays alone that we care about.
A subset of these observed rays also pass through the view screen. The color of each point on the view screen is determined by the sum total of all the light rays that pass through that point while on its way to the viewer
Backward
The actual mathematical calculations are done backwards because it is more efficient. We model all light rays that end at the viewer and go through the view screen (one ray for each pixel). We trace them backwards to determine where could they have come from. Based on that, we can calculate their color.
subroutine RayTrace { For each row of pixels { For each pixel in row { Determine ray from camera to pixel CalculateRayShade(ray) } } } subroutine CalculateRayShade(ray) { For each object in scene { Determine point of intersection (if any) of object with ray. } Determine the closest (if any) intersection point. For each light in scene { Send out a shadow ray from intersection point to light. For each object in scene { Determine if shadow ray intersects the object. } If shadow ray does not intersect any object { Calculate the local color of that object at the intersection point. CalculateRayShade(reflected ray) CalculateRayShade(transmitted ray) Set the pixel color to a weighted average of the local, reflected, and transmitted colors. } }
For more details, see ray.pdf and rayImplement.pdf.
[top]
[Home]