You are on page 1of 29

Ray Tracing and other

Surface Rendering Methods


CMSC 161: Interactive Computer
Graphics
Global Illumination Algorithms
Global illumination indirectly reflected and
transmitted light
In contrast, local illumination is light that comes directly from
light sources to the point being shaded
Much of the light in real-world environments does not come
from direct light sources
So far we have modeled global illumination by an ambient
illumination term (constant)
Two different classes of algorithms have been used to
generate pictures that emphasize its contribution:
Recursive ray tracing
Radiosity methods


Light Transport in Brief
Light comes from
sources, reflects off
surfaces, and gets to
the eye
We are interested in
light that gets to a
particular pixel
What parts of the
scene could
contribute?
Light Transport and Ray Tracing
Ray tracing idea: answer the question What light arrives
here? by analyzing where it might have come from and
looking there
First level: look along ray to camera
Second level: think of how light could get to the surface
Directly from sources
Indirectly via reflection
Indirectly via transmission
Higher level: recursive
Ray Tracing
Determines the visibility of surfaces by tracing imaginary
rays of light from the viewers eye to the objects in the
scene
Think of it as a variation of the depth-buffer algorithm

Ray Tracing
Ray Tracing vs. Ray Casting
Is based on geometric optics methods, which trace the
paths of light rays
In ray tracing, a ray of light is traced in a backwards direction
(i.e. from the eye or camera through a pixel in the image plane)
Ray tracing handles shadows, multiple specular
reflections and texture mapping in a straightforward
manner
Ray Tracing
Center of projection and a window on
an arbitrary view plane are selected
For each pixel in the window, an eye
ray is fired from the center of projection
through the pixels center into the
screen
The pixels color is set to that of the
object at the closest intersection
If the ray misses all objects, then that
pixel is shaded the background color
Ray Tracing
We then reflect the ray off the visible surface along a
specular path
If the surface is transparent, we also send a ray through
the surface in the refraction direction
Reflection and refraction rays (in addition to shadow rays) are
referred to as secondary rays
This procedure is repeated for each secondary ray
Ray-Tracing Tree
As the rays from a pixel ricochet through space, each
successively intersected surface is added to a binary
ray-tracing tree
Left branches represent reflection paths while right branches
represent transmission paths
Ray-Tracing Tree
Maximum depth of ray-tracing trees can be set as a user
option, or by availability of storage
A path is terminated if it reaches the preset maximum or if the
ray strikes a light source
The intensity assigned to a pixel is then determined by
accumulating the intensity contributions, starting at the
bottom of its ray-tracing tree
Involves attenuation before adding intensities
Brief History
Was first developed by Appel (used a sparse grid of rays
to determine shading) and by Goldstein and Nagel (to
simulate trajectories of ballistic projectiles and nuclear
particles)
Appel was the first to ray trace shadows
Goldstein and Nagel pioneered the use of ray tracing to
evaluate Boolean set operations
Whitted and Kay extended ray tracing to handle specular
reflection and refraction
Ray Tracing Pseudocode

Ray Tracing Effects
Basic ray tracer: mirror reflections, sharp shadows
Ray Tracing Procedure
If a ray hits an object, we want to know if that point on
the object is in a shadow. So, when the ray hits an
object, a secondary ray (called a shadow ray) is shot
towards the light sources

Ray Tracing Procedure
How much light do I see if I look along this ray?
Distributed Ray Tracing
Randomly distribute rays according to various
parameters in the illumination model:
Pixel area
Reflection and refraction directions
Camera lens area
Time
The idea is based in the theory of oversampling:
Instead of approximating an integral by a single scalar value,
the function is point sampled and these samples are used to
define a more accurate scalar value
Soft and Hard Shadows
Distribute a number of shadow rays over the area of the
light source
Glossy Reflections and Translucency
Refraction
Reflection
Caustics
Motion Blur
Is the streaked or blurred appearance that moving
objects have because a cameras shutter is open for a
finite amount of time
Achieved by distributing rays over time
Camera Lens Depth of Field
Objects appear to be more or less in focus depending on
their distance from the lens, an effect known as depth of
field
Objects near the focal plane are projected as sharp images
Objects in front or in back of the focal plane are blurred
Images (slides 14 to 17) from www-csl.csres.utexas.edu

Efficiency Considerations for Visible-
Surface Ray Tracing
Ray tracing is so time-consuming because of the
intersection calculations
Since each ray must be checked against all objects, for a
naive ray tracer (with no speedup techniques) the time is
proportional to the product of the number of rays and the
number of objects in the scene
Some techniques:
Optimizing intersection calculations
Hierarchies
Spatial partitioning
Optimizing Intersection Calculations
Bounding volumes provide a particularly attractive way to
decrease the amount of time spent on intersection
calculations
The object does not need to be tested if the ray fails to
intersect with its bounding volume
Hierarchies
Although bounding volumes do not by themselves
determine the order of frequency of intersection tests,
bounding volumes may be organized in nested
hierarchies with objects at the leaves and internal nodes
that bound their children
Child volume is guaranteed not to intersect with a ray if
its parent does not
Thus, if intersection tests begin at the root, many branches of
the hierarchy (and hence many objects) may be trivially
rejected
Spatial Partitioning
Subdivides space top-down
Bounding box of the scene is calculated first, then
divided into a regular grid of equal-sized extents
Partitions can be examined in the order in which the ray
passes through them; thus as soon as a partition is
found in which there is an intersection, no more partitions
need to be inspected
Radiosity Lighting Model
Acurrate model of diffuse reflections from a surface by
considering energy transfers between surfaces, subject
to conservation of energy laws
Unlike conventional rendering algorithms, radiosity
methods first determine all the light interactions in an
environment in a view-independent way
Based on thermal-engineering models
Adding Surface Detail
Modeling Surface Detail with Polygons
Model structure and patterns with polygons facets
For example, squares on a checkerboard, tile patterns in a
linoleum floor, panels in a door
Texture Mapping
Map texture patterns onto the surfaces of objects
The texture pattern may either be defined
In a rectangular array
Or as a procedure that modifies surface intensity values
Compute texture coordinates at the intersection point
Texture Mapping
This process is akin to applying patterned paper on a
plain white box
Mip Mapping
MIP maps are precalculated, optimized collections of
images that accompany a main texture
To increase rendering speed
Reduce aliasing artifacts and achieve illusion of depth
Need more space in memory
Switch to a suitable mipmap image when the texture is viewed
from a distance or at a small size
MIP means multum in parvo, meaning much in a small
space
Bump Mapping
Although texture mapping can be used to add fine
surface detail, it is not a good method for modeling the
surface roughness that appears on some objects
The illumination detail in a texture pattern usually does not
correspond to the illumination direction in the scene
Bump mapping applies a perturbation function to the
surface to the surface normal and then uses the
perturbed normal in the illumination-model calculations
Silhouettes and shadows remain unaffected

You might also like