Ray Tracer with Monte Carlo Color-Bleeding

Joshua Maass

CPE 473, Spring 2011


Overview

The purpose of my final project was to implement some form of color-bleeding via the Monte Carlo approach to raytracing -- by casting out sampling rays from a given point in order to determine the amount of color the other objects in the scene provide.

The ray tracer does this by randomly casting 256 rays out from every ray-object intersection point. The random rays are cast so that they are anywhere between 0 and 90 degrees from the object's normal at the intesection point. These rays each return the color of whever nearest object they hit. The colors are then averaged to form the average color found by the rays. A fraction of the average color is then given to the initial point (where the 256 random rays were cast from) which creates the color-bleeding effect.


Run-Time

My ray tracer builds an oct-tree from the objects in the scene, which helps to decrease the run-time of larger files. For "bunny_jumbo.pov", it normally would have taken almost 30 minutes to run without the oct-tree (and without anti-aliasing or doing Monte Carlo). With the oct-tree, "bunny_jumbo.pov" only takes about 4 minutes to fully run (also without anit-aliasing or Monte Carlo).

For scenes with very few objects, however, the oct-tree doesn't seem to have any effect on the ray tracer's performance. Each of the scenes below required about 10-12 minutes to run with Monte Carlo but without anti-aliasing, and about 90-120 minutes to run with Monte Carlo and with anti-aliasing (9 rays per pixel).


Images


A small room with three colored walls and a white sphere in the center. With color-bleeding, we can see that the walls have cast some of their color onto the sphere -- the left side of the sphere is blue-ish while the right is red-ish. Also, on the two lower corners of the room, we can see that the part of the floor not obscured by shadow is casting its own light onto the colored walls.



A small room with two objects--a blue sphere and a tall, white box -- and one colored wall. With color-bleeding, we can see that the red wall is coloring the side of the box nearest to it red. The box is also being given the color of the blue sphere. You'll notice, however, that the top of the box (the part furthest from the sphere) is being colored blue while the bottom of the box (the part nearest to the sphere) is still white/grey. I tried looking for the bug that's causing this, but I wasn't able to find it.



A ring of colored spheres arranged in rainbow order with a white sphere in the center. Each of the colored spheres is casting a little bit of its own color onto the center sphere. The colored spheres also appear to the casting their color onto the other colored spheres.

Resource