Wednesday, April 9, 2014

OBJ Importing and Anti-Aliasing

Thanks to a new tutorial by Mike Farnsworth at Renderspud, I added an OBJ Loader class to my ray tracer. My implementation only supports the basics (no quads, vertex normals, nor texture coordinates; just triangles), but it works. And what better model to test it on than everyone's favorite open-source monkey, Suzanne:
The model has 968 faces. At 512x512 with 2-4 anti-aliasing samples, this took nearly 4 hours to render on my trusty laptop. It's a start.

Speaking of anti-aliasing, we now have it. There are two modes. The first one sends out an equal number of rays through each pixel, each slightly offset from one another. The results are averaged together to form the final pixel color. The second mode sends out a single ray through each pixel to get a rough image. It then finds the edges (the parts of the image that will benefit most from anti-aliasing) by calculating the color gradient of the image (see Sobel Operator for more on this). Then it re-renders only the high-contrast pixels with a higher number of samples. This way, smooth parts of the image render quickly, but the edges are properly anti-aliased.
 (I'm being really liberal with the definition of the + sign in this graphic)
I'm still fiddling with the edge detection and how to get the best-looking image for the most reasonable render time.

Now it's time to start implementing an acceleration structure like a BVH.

No comments:

Post a Comment