Path Tracing

Monte-Carlo Path Tracing written in C++/CUDA

Path tracing is a render technique that simulates the interactions between rays from light sources and objects in the scene.

In order to get a rendered image of a 3D scene, for example the diamond images as the post’s cover, we essentially:

  1. Shoot rays rays from the positions of each pixel, through camera, to the scene;
  2. If a ray hits an object, then based on the material of the object’s surface:
    1. The ray bounces off randomly if the object is of diffusive material, which basically creates a new ray starts from the intersection with direction randomly distributed in a hemisphere;
    1. The ray bounces off only through the reflective direction if the object is of reflective material;
    1. The ray enters the object if the object is refractive, its direction changes according to the object’s index of refraction (eta).
  1. Repeat step 2. where rays keep bouncing off from a surface to another surface.
  2. A ray is terminated if:
    1. It reaches a light source;
    1. It hits nothing, means it will not do any contribution to the result image;
    1. It has bounced off enough times (or so-called depth), you can think this as a ray’s energy is all consumed.
  1. When all rays are terminated, we gather and average their colors and create a image based on it.

From the path-tracing procedures described above, we can get the sense that ‘Path Tracing’ is trying to simulate the stochastic phenomenon when light hits objects, which is also known and described by BSDFs, by shooting a lot of rays a lot of times into the scene, and approximate the continuous probability distribution by enough large number of discrete sampling. The best about Path Tracing is that the rays coming about from different pixels are independent, so we can use the power of GPU to run multiple threads, each carrying a ray, simultaneously on GPU.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

search previous next tag category expand menu location phone mail time cart zoom edit close