Program Two and Three: Advanced Ray Tracer

For this assignment, we had a few options available to implement. I chose the following:
  • Soft shadows
  • Gloss
  • Adaptive anti-aliasing
  • Animation
Soft Shadows:

Soft shadows are created by converting our 1-dimensional light source into a 2 or 3 dimensional light source. With the new light, we can spawn rays from random locations on the light. If you use enough rays (around 100 per initial ray), you will create a very soft shadow. Implementation was not difficult to figure out, the main difficulty was getting the new shadow rays scattered enough to give a uniform-like soft shadow.


Gloss is emulated by scattering reflected light. So instead of seeing a perfect reflection on a plane, we see a fuzzy reflection on the glossy surface. The main implementation challenge was finding a new ray direction that gave a good representation. I determine a random value between -0.5 and 0.5 times the percentage of gloss on the object for each component of the new direction vector. Doing this with enough rays will give a glossy effect.

Adaptive anti-aliasing:

Adaptive anti-aliasing is where you only anti-alias where your scene has the most aliasing. My thinking is that all of the aliasing will be at the edges of objects. With this in mind, my algorithm first determines when there is a change in the current object. As I pass through, I keep track of the current and the last object. As soon as it changes, I know I'm at the edge of an object. Then I subsample the pixel 9 times. With my current code, I was able to get the change in the current object ok. However for some reason I am not anti-aliasing much, if at all. My ray tracer outputs two images now, one being the normal image, and the other is the silhouette of each object.


Brian Caines © 2024 BrianCaines.com