Project 10

Monte Carlo Effects

Creative Image:

(Image scaled down. Click on images for fullsize view.)

The left image shows a metallic, reflective sphere between two colored columns over a checkered plane. On the right is the same image, but with a glossy shader on the sphere. The image is filtered with a one-pixel support triangle filter, using 36 jittered samples per pixel. The reflections on the sphere were generated by casting 1000 monte carlo jittered reflection rays per pixel. The result looks pretty nice, I would say :)

Extra Credit:

I have also implemented translucency in dielectric materials. These two images show the Dielectric material from previous projects on the left, and a translucent glass on the right.

Design choices:
I pretty much followed the class notes in implementing these effects. The GlossyMetalMaterial class is instantiated like the MetalMaterial class, but with extra parameters specifying the degree to which the material diffuses its reflection, and how many Monte Carlo samples to use per hit point.

The translucent material behaves similarly, taking the same parameteres as DielectricMaterial, with extra parameters for the degree of translucency and how many ray to use in computing the shade of a pixel. Another decision I made for the translucent material is that Fresnel reflections (at grazing angles) are not made blurry. This was done so that a smooth glass sphere which is nonetheless translucent through its body would give the proper reflections. It would be rather simple to add another control parameter to allow for independently having blurry reflections as well, but I skipped this phase for simplicity.

The "degree" of diffusion/translucency is actually just a multiplier used to scale the random perturbation vectors that actually end up jittering the reflected/transmitted ray. Thus, for a value of 0, the new materials will behave just like the old ones, albeit slower. And for very large values, the materials will be arbitrarily diffusive.

Interesting Bugs:


This image shows a bug which I thought was rather cool. In selecting a random number, I was simply using the value of drand48() for both the x and y factors. However, this gives values in [0, 1), rather than (-1, 1) as we actually need. The image above shows the result of using the same random value for each pixel on the sphere (via re-seeding the random number generator with the same value before invoking it to jitter the reflection ray). Because x and y are both positive, each reflection ray gets skewed in the same relative direction. Because of the orientation of the normal vectors on the surface of a sphere, the jittered rays tend to get rotated towards the same angular direction, giving this trippy looking image.