Kuan-Loong Yong, Seth Green, Patti McLain
CS348B Image Synthesis
Final Project Writeup [edited]

Smoke 
----- 

Our group modelled smoke as a volumetric object specified completely by a
space-density function and an gas illumination model. The ray-marching
algorithm involves approximating an integral that accummulates color and
opacity along the ray [1]. We used Blinn's [2] formulation of the
Henyey-Greenstein phase formula to compute the brightness of a smoke
particle. In order to speed up the computation, we do not compute for
ray-object intersections when tracing light rays from a smoke particle to
the light sources. This has little effect on the believability of the
smoke object since it is so amorphous anyway. Note, however, that the
smoke does cast convincing shadows on other surfaces.

To get the right look for the smoke, we used a cone distorted by a simple
(1 - exp(kx)) function to suggest the effect of smoke clinging onto the
surface of the cigarette before dissipating upwards, which corresponds
rather closely to our observations. To give the cone a puffy smoke-like
appearance, we peturbed the cone by a 3D turbulence function. The amount
of turbulence is proportional to the square of the height of the smoke
particle. The density of the smoke drops off linearly radially, and as
a function of the square root of the height vertically. Although we chose
these functions arbitrarily, the result is very convincing.

Given this framework, animating the smoke becomes an extremely
straightforward task. By simply displacing the 3D turbulence function
downwards as a function of time, we create the illusion of rising smoke. 


Water 
----- 

We introduced an automatic means of generating radial waves
with interpolated surface normals in our ray tracer. At run-time, the
program reads in a description of the wave surface and generates a huge
polyset, replete with an octree structure and per-vertex normals, on the
fly. The height of the waves vary sinusiodally with the distance from the
wave origin; their amplitude drops off linearly with increasing radial
distance. To add a touch of irregularity, we added a small amount of
low-frequency FBm noise to the wave function.

The water waves are also fully animatable. The program simply regenerates
a whole new polyset and discards the previous one whenever time
progresses.


Caustics 
-------- 

We formulated an efficient way of simulating reflection caustics due to
undulating height fields by hybridizing Watt's backward beam tracing
technique [3] with well-known techniques in the field of two-pass texture
mapping [4]. Using Watt's caustic polygon approach, we rasterize polygons
onto an intermediate bounding cylinder surrounding the object we wish to
throw caustics on. We form each caustic polygon by tracing rays from the
light source to each vertex of a triangle on the polygonal mesh,
reflecting those rays off (each vertex of the triangle must have its own
normal for this approach to be effective), and rasterizing the caustic
triangle formed by those rays when they intersect the intermediate
cylinder. Rasterization occurs on a special texture map which we term a
"caustic map" that the program can easily index into given the cylindrical
coordinates of the point of intersection. The brightness of each caustic
triangle is uniform, and is simply a function of the dot product between
the the averaged normal of the triangle and the ray direction to the light
source, and the ratio of the area of the actual polygon to that of the
caustic polygon. Please refer to [3] for a detailed discussion of this
computation. For speed and simplicity, we do not compute for ray-object
intersections when casting caustic polygons on the intermediate surface.

The second stage involves treating the caustic map as an ambient color
map, and projecting it optimally onto the underlying polyset mesh. A
simple radial projection fails miserably when the object is highly
non-cylindrical because of excessive distortion. We present a better
approach:

Given a point on the polyset object, we find the further intersection of
the ray originating from that point and having a direction parallel to the
surface normal with the bounding cylinder (the ray can intersect the
cylinder at most twice), after discarding all vector components parallel
to the axis of the cylinder. This is essentially a 2D problem involving
the intersection of a line with a circle. The program does the caustic map
lookup based on that point of intersection. The ambient color returned
from the lookup is scaled by the dot product of the surface normal with
the axis of the bounding cylinder before the shader adds that to the
surface color computed from the regular phong illumination model. This
additional step is necessary to attenuate caustics on surfaces that point
in the direction of the axis of the cylinder. Notice in our renderings
that caustics do not appear on flat, horizontal surfaces pointing away
from the water surface.

Our mapping technique works remarkably well on surfaces which are not
highly cylindrical, as evidenced by our rendering of the cat polymesh. We
also noticed that, in order to get sufficient detail in the caustics, it
is necessary to subdivide the height field much more finely for computing
caustics than for actually rendering the height field itself. Our ray
tracer accomplishes this by storing two copies of each height field in
memory -- an ultra-high resolution mesh for creating caustic polygons, and
a lower resolution one used by the regular ray tracing pipeline.

***************************************************************

Cigarette Tip
-------------

The tip of the cigarette is modeled as a large number of small flat polygons to
simulate the flecks of charred tobacco that are produced by a burning
cigarette.  Before being lit a cigarette tip contains about 10-50 pieces of
tobacco arranged in a somewhat spiral pattern.  After burning the tobacco
breaks up into 100-1000 small flecks.  Near the center of the cigarette the
charred tobacco is black, and on the outer edge it is colored white from the
burnt wrapping paper.  The tip of the cigarette was modeled in Matlab and
exported as an inventor format file to be read by Composer.  The tip is modeled
as a dense number of concentric rings which were then split into
equicircumferential slices.  The vertices of each slice are perturbed by a
Gaussian noise function and a scaling function to give the end of the tip a
rounded appearance. Each vertex is given a diffuse color based on it�s distance
from the center.



*****************************************************************

Distribution Ray Tracing
________________________

The semi-diffuse reflections are based on the Gregory Ward 
anisotropic reflection model [1]. The specular part Ward's 
model is used, the diffuse portion of the reflection implements 
the Whitted model.  The diffuse portion of the Ward model is
equivalent to the Whitted model. The Ward model uses an elliptical 
gaussian function for the specular component. To generate the 
secondary rays using importance sampling, directions with the 
highest contribution have a higher probability of being sampled. 
Therefore, the sample rays are also generated from a gaussian 
distribution, around the mirror direction, and equal weighting 
is used for each of the rays. Multiple rays are only spawned 
at the first reflection, since the return from spawning multiple 
rays at each intersection is not computationally efficient, and
the contribution is lessened after each reflection.

Translucence is modeled similarly, the distribution is isotropic 
about the refracted direction. The contribution of rays are weighed 
equally. This gives the appearance of a mottled transparent 
medium.

Penumbra-
To generate penumbrae lights were modeled as axis-aligned boxes. 
This was computationally efficient, and does provide softened
shadows. To model lighting in an environment to evaluate different 
lighting selections, a more faithful approach to modeling the
light extent should be made. Shadow rays were uniformly generated 
that intersect the box. All rays provided equal contribution to 
the shadowing.

Camera Animation
________________

The animation of the camera is computed by providing 3 camera
data sets from composer. The animation uses the 3 sets of data
as control points for a quadradic Bezier curve. Therefore, 
the first and last points are interpolated with the intermediate
point providing the control.

***************************************************************

References
----------

[1]	Kajiya and Kay 1989
	Ray Tracing Volume Densities
	SIGGRAPH 89, vol 18, pp 165-174

[2]	Blinn, James 1982
	Light Reflection Functions for Simulation of Clouds and Dusty
	Surfaces.
	SIGGRAPH 82, vol 16, pp 21-29

[3]	Watt, Alan and Mark Watt 1992
	Advanced Animation and Rendering Techniques
	ACM Press, pp 253-256

[4]	Bier, E. A. 1986
	Two part texture mapping
	IEEE Computer Graphics and Applications, Sep 1986, 6(9), pp 40-53

[5]	Peitgen and Saupe 1988 
	The Science of Fractal Images
	Springer-Verlag, pp 100-101

[6]	Ward, Gregory
	Measuring and Modeling Anisotropic Reflection
	Computer Graphics 26, 2, July 1992