Tracing

Posted: October 3rd, 2010 | Tags: , , | 5 Comments »

Gregory Pakosz reminded me to write a follow up on my path tracing efforts since my last post on the subject.

It's good timing because the friendly work-place competition between Tom and me has been in full swing. The great thing about ray tracing is that there are many opportunities for optimisation at all levels of computation. This keeps you "hooked" by constantly offering decent speed increases for relatively little effort.

Tom had an existing BIH (bounding interval hierarchy) implementation that was doing a pretty good job, so I had some catching up to do. Previously I had a positive experience using a BVH (AABB tree) in a games context so decided to go that route.

Our benchmark scene was Crytek's Sponza with the camera positioned in the center of the model looking down the z-axis. This might not be the most representative case but was good enough for comparing primary ray speeds.

Here's a rough timeline of the performance progress (all timings were taken from my 2.6ghz i7 running 8 worker threads):

Optimisation Rays/second
Baseline (median split) 91246
Tweak compiler settings (/fp:fast /sse2 /Ot) 137486
Non-recursive traversal 145847
Traverse closest branch first 146822
Surface area heuristic 1.27589e+006
Surface area heuristic (exhaustive) 1.9375e+006
Optimized ray-AABB 2.14232e+006
VS2008 to VS2010 2.47746e+006

You can see the massive difference tree quality has on performance. What I found surprising though was the effect switching to VS2010 had, 15% faster is impressive for a single compiler revision.

I played around with a quantized BVH which reduced node size from 32 bytes to 11 but I couldn't get the decrease in cache traffic to outweigh the cost in decoding the nodes. If anyone has had success with this I'd be interested in the details.

Algorithmically it is a uni-directional path tracer with multiple importance sampling. Of course importance sampling doesn't make individual samples faster but allows you to take less total samples than you would have to otherwise.

So, time for some pictures:

Despite being the lowest poly models, Sponza (200k triangles) and the classroom (250k triangles) were by far the most difficult for the renderer; they both took 10+ hours and still have visible noise. In contrast the gold statuette (10 million triangles) took only 20 mins to converge!

This is mainly because the architectural models have a mixture of very large and very small polygons which creates deep trees with large nodes near the root. I think a kd-tree which splits or duplicates primitives might be more effective in this case.

A fun way to break your spatial hierarchy is simply to add a ground plane. Until I performed an exhaustive split search adding a large two triangle ground plane could slow down tracing by as much as 50%.

Of course these numbers are peanuts compared to what people are getting with GPU or SIMD packet tracers, Timo Aila reports speeds of 142 million rays/second on similar scenes using a GPU tracer in this paper.

Writing a path tracer has been a great education for me and I would encourage anyone interested in getting a better grasp on computer graphics to get a copy of PBRT and have a go at it. It's easy to get started and seeing the finished product is hugely rewarding.

Links:

John Carmack tweeting about his experience optimising the offline global illumination calculations in RAGE.

I was surprised to learn at SIGGRAPH that Arnold (as used by Sony Pictures Imageworks) is at it's core a uni-directional path tracer. Marcos Fajardo described some details in the Global Illumination Across Industries talk.

Mental Images iRay (their GPU based cloud renderer) looks impressive and apparently uses a single BSSRDF on all their surfaces which I guess helps simplify their GPU implementation.

Ompf.org

Model credits:

Sponza - Crytek
Classroom - LuxRender
Thai Statuette, Dragon, Bunny, Lucy - Stanford scanning repository

{ 5 Comments » }


5 Comments on “Tracing”

  1. 1 Daniel said at 8:29 pm on October 4th, 2010:

    Those renders look amazing! The indirect shadowing in the sponza scene is so detailed. That's one thing that gets lost to some degree when you use irradiance caching, the indirect shadows become much softer, because they don't necessarily correspond to where the caching heuristic thinks more samples are needed.

  2. 2 mmack said at 4:58 pm on October 5th, 2010:

    Hi Daniel, good to hear from you and thanks for the observation. Irradiance caching has been on my list of things to try, at the moment I'm just throwing more samples at the problem which isn't great for render times but at least looks nice :)

  3. 3 Eric Haines said at 7:45 am on October 14th, 2010:

    Fun little article, and I do love the gold statues. For a bit more on Arnold, see my article at http://tog.acm.org/resources/RTNews/html/rtnv23n1.html#art3.

  4. 4 Marcos Fajardo said at 7:00 am on January 16th, 2011:

    Those gold renders are awesome, in particular the Thai statue. Makes me want to go and implement a .ply reader and do some renders :). What was the specular BRDF, and how many glossy bounces were they rendered with?

  5. 5 mmack said at 7:19 pm on January 16th, 2011:

    Hi Marcos!

    There's nothing too special going on with the gold renders, I used Blinn's microfacet distribution with Schlick's Fresnel approximation and a standard geometry term.

    There was no maximum path length and instead I just waited for the path to leave the scene.

    I might just take the opportunity to say thank you for your talk at SIGGRAPH last year, it was quite inspirational! Great to see that path tracing can be made practical in production.


Leave a Reply