9.21.2013

Vulcan Renderer - Base framework, ray tracing, super sampling, path tracing, fresnel reflection, Cook-Torrance

I am working on a GPU based rendering engine on the side while I finish my last semester of undergrad.  I'm sitting in on the course cis565, which covers a lot of the material that I need to know to make this a successful endeavor.  I have written a few renderers before, but this is the first time that I am really taking my time and understand things more completely as I implement them.  I've also already added more functionality to this iteration that any previous iteration (and it's only been a little over a week!).  Also - I am stealing a lot of the software engineering side of this project from Mitsuba, which is a physically based renderer, as well as Takua, whose skeleton is provided from the base code.

Anyways - onto some renders!

First up is basic intersections to get the material color of each object.  This is useful as a debugging tool as well, so I left it in as one of the integrators available.




Useful, but not very interesting.  The next step is to add diffuse lighting, which is probably the simplest surface to simulate.



This is better, but if you look closely you can see some jagged edges on the spheres.  This can be solved by sampling each pixel multiple times.  The general term for sampling something a number of times is called super sampling.  Like I said, you can sample a pixel multiple times to anti-alias the image.  But you can also super same the camera's aperture to achieve depth of field, and the position of an object or the camera to achieve motion blur.


This looks a lot better.  The red and cyan spheres are in focus, while the white sphere - which is close to the camera - is out of focus.

This is all well and good, but there are still some problems.  The shadows are extremely dark in this scene.  A limit in ray tracing is that it only accounts for direct lighting, that is, lighting that comes directly from a light source.  However, in reality light reflects any number of times on and around surfaces before it reaches our eyes.  Simulating this type of light requires a more complex rendering algorithm.



Now we are getting to some more interesting images.  This image has been created using path tracing, which is one such algorithm to solve for indirect lighting.  It does look a lot better than the ray traced version of this scene.  There is still one thing that is limiting the visual interest though - the surfaces themselves are all diffuse.  Making everything diffuse is relatively easy, but not too interesting.  I have implemented a number of simple BRDFs, but the two I am going to mention are Fresnel reflection and Cook-Torrance micro-faceted specular reflectance.



The first image is ray traced, while the second is path traced.  The red sphere's highlight is modeled using the Cook-Torrance model I mentioned.  The two other spheres are exhibiting Fresnel reflection.  I included both images to point out some nice features that come along with path tracing at no extra cost.  You can see the color bleeding from the blue glass, as well as the caustic on the bottom of the screen.

So there we have it.  It's not much, but it is a good start.  One thing I should note again that this system is GPU based.  The time it took to produce these images ranged from less than a second to 2 or 3 minutes, which is not that fast compared to other GPU systems, but much faster compare to a CPU version.  I am planning on optimizing the GPU part as I move along.  

But before I go, I want to show 2 extra images that make a few visual comparisons.


This image visually shows how Fresnel reflection is working.  The left sphere is pure refraction, while the right sphere is pure reflection.  Fresnel, which is in the middle, mixes the two based on some fancy math that stems from the index of refraction of the sphere.

Anyways - I breezed through all of this really quickly, but this was meant to be a brief overview of the base for this project.  I may make some dedicated posts to Cook-Torrance and Fresnel though since they are relatively interesting.


PS - I am being annoying and making a name for this even though it is so basic.  Vulcan is the Roman equivalent of the Greek god of craftsmen and sculptors Hephaestus.