Final Project - Genie coming out of a Oil Lamp
AimOur aim for this project was to render a genie coming out of a lamp,
placed in a desert. The model for the lamp was based on the proposal
image, while the desert texture was procedurally generated, and the genie was
selected both for thematic aptness and the ability to demonstrate subsurface
- Fast subsurface scattering for the skin of the genie
- Improved photon mapping for efficient generation of caustics on the table
- Volumetric effects of the oil as a participating medium (for scattering
effects, and attenuation due to the medium)
- Perlin noise: Used to generate texture for the sand that the lamp is
We followed the algorithm outlined in . The steps involved are
- Uniform sampling of points on the mesh: These samples were obtained using
Turk's point repulsion algorithm  (discussed in more detail below)
- Evaluating the irradiance at each sample point: The irrradiance estimate
to be stored in the cache must take into account both direct and indirect
- Direct: For each point on the mesh, we sample incoming directions over
the hemisphere and trace these rays through, taking into account direct
lighting at every surface.
- Indirect: The estimate is obtained using path tracing.
- The irradiance samples are stored in an octree. Each node stores an
estimate of the total irradiance, total area and average position (weighted by
irradiance) of the points below it.
- Once the octree is built, the outgoing radiance at any point can be
calculated using the dipole approximation formulas.
- Note that specular reflections were ignored in the above scheme. We felt
that this did not detract from the scene much as skin does not have a high
component of subsurface reflections.
- For the integrator, we used the normal photon mapping integrator for
objects that did not show subsurface scattering, and read the cache values for
those that did.
Uniform sampling of points on the mesh (Turk's algorithm)
- Start with a random sampling of points on the mesh, where the probability
of a point being in a triangle is proportional to the triangle's area.
- Apply a "relaxation procedure" to the points:
- Each point exerts a repulsive force on the points near it. This force
drops off linearly and is zero beyond a certain distance r.
- Calculate the force on each point due to the neighboring points (rotated
to come into the same plane)
- Apply the force to each point to get the new positions.
- If the new positions are off the mesh, one must bring them onto the mesh
by always finding the edge crossed and rotating about it (this may have to
be done more than once).
- The above "relaxation procedure" can be applied as many times as
- We ran into a lot of numerical issues while implementing this algorithm,
as a lot of things were dependent (if naively implemented) on the sign of a
small quantity, or of the value of the division of two small numbers, which is
subject to numerical errors. Programming had to be done with care to get it
right and handle the edge cases correctly.
Improved photon mapping for efficient generation of causticsWhile pbrt
does have support for photon mapping, the method implemented is generic, and was
found to be quite inefficient for our situation. We added the following two
improvements to the caustic photon map generation:
- Shoot rays for caustic photons only at the specular objects:
- Define bounding spheres for the specular objects (or regions) for which
caustics are desired
- Take a spherical projection of this bounding sphere on the sphere
surrounding the various light source (we used a spherical projection because
the main light source in our scene was a point light). We also experimented
with spot lights and area lights, using planar projections and got
relatively good results.
- Shoot caustic photons (uniformly distributed by solid angle) in the
conical region defined by the center of the light source.
- Consider only refracted rays for the caustic photons. Since we were
interested in using the photon map solely for caustics, it made sense to only
store those photons that were transmitted through specular surfaces (i.e.
refracted). Among other things, this helped eliminate noise from low density
of photons scattered in other parts (non-caustic areas) of the scene.
- There was very little indirect lighting in our scene and therefore we
didnt use the photon maps for this purpose. Instead, we used an environment
light to simulate an ambient source in the scene.
Volumetric effects of the oilThe oil/glass and oil/air interface
together defined the volumetric extent of the oil. We model the oil as a
homogeneous participating medium with in-scattering and attenuation effects.
Since pbrt has support only for cuboidal shaped participating media, we had to
extend it to support arbitrary shapes. The geometry of the oil was defined as a
loop subdivision surface and we used an internal kd-tree to efficiently find
intersections of rays with the mesh (this resulted in significant speedups). In
the process, we also found a bug in pbrt - the image doesn't render properly (a
large number of pixels are assigned radiance values of 0) whenever a volumetric
medium coincides exactly with a primitve in the scene (in our case, the oild
medium and the oil primitive itself). To get around this, we scaled our medium
by a small amount.
Defining the oil as a volumetric medium contributed to
making it look far more realistic.
Texture mapping for the sandThe sand texture was modelled using Perlin
noise as follows:
It took some experimentation to get the look of the sand right.
- Given a texel (u,v), the curved nature of the dunes was modelled using an
expression of the form sqrt((u-u0)^2 + (v-v0)^2) as the base image.
- This base image was then modulated using fractional Brownian motion which
is based on adding a number of octaves of Perlin noise with different
frequencies and amplitudes.
- The value thus obtained was used to interpolate between two appropriate
shades of brown
- The texture thus generated was anti-aliased using supersampling.
Genie and the Oil Lamp
- A rapid hierarchical rendering technique for translucent
Jensen, Buhler. Proc. of SIGGRAPH 2002
- A practical model for subsurface light transport
Levoy, Hanrahan. Proc. of SIGGRAPH 2001
- Generating Textures on Arbitrary Surfaces Using
Turk. Proc of SIGGRAPH 1991