fixored?

It works on my machine.

Archive for the ‘Global Illumination’ Category

CUDA Mersenne Twister

with one comment

I needed a random number generator for a CUDA project, and had relatively few requirements:

  • It must have a small shared memory footprint
  • It must be suitable for Monte Carlo methods (i.e. have long period and minimal correlation)
  • It must allow warps to execute independently when generating random numbers

There seem to be two main approaches to RNG in CUDA:

  1. Each thread has its own local history, operates independently. This can be seen in the Mersenne Twister sample in the CUDA SDK (which has a very short history of 19 values). This usually requires an expensive offline process to seed each thread appropriately to avoid correlation. I can’t spare the registers or local memory for this approach.
  2. Have a single generator per thread block, parallelise the update between all threads and synchronise using __syncthreads. This is the approach in the recent MTGP CUDA sample. I can’t use this approach because I am allowing each warp in the block to process jobs independently (using persistent threads) – calls to __syncthreads to synchronise every thread in the block are not possible.

What I ended up with is basically a modified version of MTGP (the second approach above), but with each warp able to grab random numbers independently from the shared MT state. This had the nice side-effect of reducing the shared memory footprint to be the same as the equivalent CPU MT implementation. Read the rest of this entry »

Written by Simon Brown

December 13th, 2009 at 11:09 pm

Adventures in CUDA Path Tracing: Part 1

with 5 comments

I thought I’d have a go at implementing some path tracing in CUDA. Let’s start simple: a classical path tracer with explicit direct lighting. Lots of hacks:

  • No BVH yet, every ray tests the 30 triangles of the Cornell Box
  • Every surface is lambertian (so cosine weighted hemisphere sampling for spawning rays)
  • Hardcoded for a single area light (which the camera cannot see)
  • Uses copy-pasted Moller intersection test from CPU code
  • Random number generation got moved to a texture read (with the texture data updated CPU-side) to avoid absurd register counts

Read the rest of this entry »

Written by Simon Brown

August 15th, 2009 at 2:55 pm

Metropolis Light Transport

with one comment

Here are a collection of papers/links on the topic of Metropolis Light Transport (MLT).  The core principle of detailed balance that underpins the Metropolis-Hastings algorithm is extremely neat, and its application to light transport (in particular using Veach’s path integral formulation) is very aesthetically pleasing.  This post doesn’t really go anywhere, just provides links for further reading. Read the rest of this entry »

Written by Simon Brown

May 10th, 2009 at 11:47 am

Multiple Importance

with 6 comments

At work I wrote a global illumination system from scratch.  It used classical ray tracing for the direct lighting, and photon mapping with final gather for the indirect term.  I use the past tense since we’ve now switched over to using lightcuts as the main renderer, which due to the work of an awesome colleague, is giving us better results (and faster).

To complete the set, I thought I’d have a go at implementing a bidirectional path tracer, a “full Veach“, if you will… Read the rest of this entry »

Written by Simon Brown

February 5th, 2009 at 11:50 pm