CSE 168
Assignment 4 Report
Nicholas Porter
6/12/06
b. Soft Shadows
c. Hot Keys
3. Final Image
Global Illumination was implemented using particle tracing. Particles are cast out randomly from each light source and bounce a certain number of times around the scene. Each triangle has an accumulator Image attached to it where it stores the accumulated light from the particle trace. These accumulators are then used to fetch the indirect light when drawing the scene. The indirect light is added to the direct light to produce the final image.
+

Direct + Indirect
Final:

Soft shadows were implemented, the shading routine offsets the light position to a number of slightly different random locations and then casts rays at it. Partially occluded sources give partial light, completely occluded or completely visible give complete shadows or no shadows respectively.
No soft shadows:

Soft shadows:

The special part of this project was that the rendered scene would use only procedural textures. My scene is a very simple intersection with buildings (I have never used a modeling program before!) and it requires: 1) brick textures for the buildings, 2) a sidewalk texture, 3) an asphalt texture, and 4) a lamp post texture. The first three are visible in the following image:

Note the staggering of the bricks. All the textures are procedurally generated.
I altered the .obj loading code to be able to handle material library (.mtl) files used by the Wavefront object file. I included two special hacks. First, starting a material name with 'p' will make the loader treat it as a procedural texture. So "predbrick" will use the red brick material. Second, the map_Kd line (which loads a texture) can be changed to map_Kn and will load a bumpmap.
I altered the parser and lexer to allow additional variables to be set. An example would be:
global
{
# screen dimensions
width 350
height 350
# other options
background color 0, 0, 0
# particle tracing
accumulator size 128
particle depth 10
num particles 200000
particle sampling 8
# soft shadows
shadow samples 40
shadow offset 3000
}
The Particle Tracing and Soft Shadows options are new. Most are obvious. Shadow offset sets the divisor for how far to randomly displace the light source. Bigger values mean a smaller displacement (and, hence, wider dispersion of the soft edge of the shadow). This should be changed depending on the size of the scene loaded.
The following hotkeys were added:
'[' - Toggle Direct Illumination On/Off
']' - Toggle Indirect Illumination On/Off (either of these can be on, or both)
'u' - Toggle soft shadows On/Off
'p' - Calculate Indirect Illumination (you need to hit this yourself, indirect illumination isn't calculated by default since it may take a long time)

The lighting on the red brick wall is due to the fact that there is a second light out of the picture to the right.