![]()

Guoning Chen
Department of
electrical engineering and computer science,
![]()
General Description of the project
[Why use distribution ray tracing]
Ray tracing is one of the most
important techniques in computer graphics. Many phenomena, such as shadows,
reflections, and refracted light can be implemented by ray tracing. But basic
ray tracing calculates each ray direction at an infinitesimal point which is
the center of a pixel precisely, such that it will produce sharp reflections and sharp reflection in the scene that may not happen in nature. For
displaying shadow, basic ray tracing assumes all the light sources are point light sources, and consider a
single ray from the visible point to those light sources respectively. Hence,
it can only get hard shadow effect which is also rarely encountered in nature.
In addition, basic ray tracing using pinhole model as its camera model, so
every object in the scene can get a clear projection on the image plane no
matter what is the distance from the object to the image plane, which is
against to our basic knowledge that object is not close to the focal plane will
have a blur image on the image plane.
How can we defeat the defects of basic ray
tracing and create more realistic illuminated scene? Distribution ray tracing
(shortened as DRT) is one of those techniques that can solve the problem
somehow.
[What we have implemented]
Soft shadow
Rough reflection/refraction
Depth of field
Motion blur
![]()
Distribution Ray Tracing (DRT)
Distribution ray tracing is one of the techniques
that can generate more realistic image. Interestingly, the basic idea of DRT
comes from anti-aliasing. In anti-aliasing techniques, we use super-sampling to
produce blurred effect to decrease the jaggy appearance of the boundaries of
the objects in the scene. The idea is to get more color information for one
pixel instead of one, then, average these color to get the final color for that
pixel. DRT has similar idea. In stead of calculating only one ray for each visible pixel,
distribution ray tracing treats each pixel as a non-zero area region, and uses
super-sampling techniques to select several points in that region, then does
standard ray tracing from those points to obtain the intensity (three color
components) at those points. Finally, it averages the intensity of those points
with some weighting scheme to get the intensity of that pixel. Reader can find
more information in Robert L. Cook’s papers [1][2].
![]()
Implement of Different Effects
Using DRT
1. Soft Shadows
1) First, consider each light
source as a rectangular light source (defined by center position, size and
orientation, see figure 1)
2) Second, jitter the
sampling points in the rectangular region
{
We
divide the rectangular region into 16 sub-rectangles (as figure in right)
Use stratified sampling technique to jitter the
sampling points in each sub-rectangle evenly, make sure that each sub-rectangle
has one and only one sampling point (see figure 1).
}
3) Cast 16 rays from current visible point to
the 16 sampling points in the light source region respectively, perform the
same shadow testing as basic ray tracing for each ray. Then, calculate the
contribution of light from each sampling point using whitted shading (phong
illumination formula), average the colors obtained from each testing ray to get
the final color of that visible point.
Note that the size of the
rectangular light source will decide how blur the soft shadow we can get. In
this part of codes, you may need to carefully deal with the orientation of the
light source, otherwise, you may not get correct lighting result.
center size
![]()



(a) definition of
rectangular light source (b)
stratified sampling inside the light source
Fig. 1 Jitter
rectangular light source
2.
Rough reflection/refraction
1)
First, we calculate the perfect reflected / refracted direction using the same
way as basic ray tracing.
2)
Second, consider the unit hemisphere shown in figure 3, the axis direction is
the perfect reflected /refracted direction.
We
need to jitter the reflected / refracted directions on the hemisphere. For
simplicity, we use the parametric form (equation (1)) of this unit hemisphere.
(1)
We
first perform the sampling on a regular unit hemisphere located at origin
(figure 4), then, transform them to the correct position according to the
perfect direction.
In
addition, according to the specular rule, if the specular constant is very
large, the energy of the reflected rays will decrease fast when rotate apart
from the perfect direction. To make the distributed lights more concreted
(provide enough energy), we constrained the distributed area inside the region
(θ∈[0, 2
], φ∈[0,
/2]), and perform the
similar stratified sampling in this region to get 16 sampling directions.
3)
Third, we cast 16 rays along the 16 sampling directions from the reflected /
refracted point respectively. We deal with each ray as the basic ray tracing
does (recursive tracing including shadow testing). Thus, each ray will return a
color value. Averaging these colors using specular rule as weighted scheme
(equation (2)), we get the color for the visible point
(2)
Where perfect and jitter-direction
are all unit vector, n is the
specular constant of the surface.


![]()
Fig. 2 Jitter the
direction
3.
Depth of field
1) First, user defines the
focal distance (which is the distance between image plane and focal plane) and the
size (aperture) of the lens. For simplicity, we define the size of the lens in
screen space, hence, the real aperture of the lens is decided by the distance
between eye position and the image plane and the size of the aperture in screen
space. In addition, we use rectangle as the shape of the lens for the
convenience of distributed sampling.
2) Jitter the rays through
different positions on the lens.
This is a trick part of the program. Despite
the complex physical rules in optics system, we can use a quite simple way to
simulate the mechanism of lens.
First, we cast a ray from the
eye through the center of current pixel, and calculate the intersection between
this ray and the focal plane (which can be obtained from the focal distance and
image plane position) to find the focal point of the ray. Then jitter the
positions on the lens (the lens is a rectangular region whose center is current
pixel, the size is defined by user). Cast the 16 distributed rays from the
sampling position (not from eye!!) through the focal point we get before. Deal
with each ray as basic ray tracing does. Thus, each ray will return a color.
Averaging these colors, we get the final color for current pixel.
Note that, if the focal
distance and image plane position are constant, the aperture of the lens will
decide how blur the objects which are not close to the focal plane are.
4.
Motion blur
1) First, we need to define
the motion of the objects that you want to show motion blur effect. These
motions are all relative to the time. For example, if you want an object move
along a line, you need to define the direction of the movement and what is the
step size in one unit time.
2) Second, subdivide each
pixel, jitter the sampling points inside each sub-pixel just as we did in soft
shadow codes. And, allocate the time slice for each sub-pixel (for simplicity,
we use same pattern for all pixel [2]) at the same time.
3) Cast rays from each
sampling point inside each sub-pixel. Update the scene according to the time
slice current sub-pixel associated with.
4) Calculate the color for
each ray as basic ray tracing does.
5) Average the 16 returned
color to get the final color for current pixel.
![]()
Some result images
1. Soft shadow

Random jitter during shadow testing Constant jitter scheme for all shadow testing rays
2. Rough reflection and refraction
Rough reflection with sharp
refraction
Rough reflection without refraction

Texture mapping without
DRT
Texture mapping with rough reflection Texture mapping with
rough refraction

Basic ray tracing without
DRT
Rough refraction
Rough reflection and refraction
3. Depth of field

Depth of field (focal
plane = -2.0, size of lens = 128)
Depth of field (focal plane = -2.0, size of lens = 160)
4. Motion blur

Motion blur Motion blur (two moving spheres)
![]()
Download
Source code here
Report here
Result images here
Slides for DRT here
![]()
Reference
[1] Robert
L. Cook, Thomas Porter, Loren Carpenter, Distributed ray tracing,
Proceedings of the 11th annual conference on Computer graphics and interactive
techniques, p.137-145, January 1984.
[2]
Robert L. Cook, Stochastic
sampling in computer graphics, ACM Transactions on Graphics (TOG), v.5 n.1,
p.51-72, Jan. 1986.
[3] Peter Shirley, Fundamentals of Computer
Graphics (chapter 14). Published in Jul 2002 by A.K. PETERS
![]()
Last modified on 06/07/05 by Guoning Chen