Skip to content

4. Path tracing

Rubén Rodríguez edited this page Feb 5, 2020 · 4 revisions

Phase 4 - First compolsory assigment - Path tracing

Path tracing is a computer graphics Monte Carlo method of rendering images of three-dimensional scenes such that the global illumination is faithful to reality. Fundamentally, the algorithm is integrating over all the illuminance arriving to a single point on the surface of an object.

The path tracer has been built on top of previous assignments, from which it borrows the following:

  • A pinhole camera model.
  • The image description and saving routine.
  • Spheres and infinite planes as geometrical primitives.
  • The emission property (RGB tuple) for each primitive.
  • Any optional extensions implemented.

This assignment has added reflectance properties and provide the rendering algorithm which deals with them properly.

Path tracer

The path tracer enables a full light transport simulation. Each primitive includes reflectance properties that can later be used by the algorithm, additionally to the emission. Specifically, the reflectance properties are a combination of:

  • A Phong BRDF (the physically correct one, as it appears on the teaching materials).
  • A perfect specular reflectance according to the law of reflection (delta BRDF).
  • A perfect refraction according to Snell’s law (delta BTDF).

It has been assumed that an emitting object does not reflect light and viceversa (a reflecting object does not emit light). The path tracer has only one specific parameter (set by command line): the number of paths per pixel. The path interactions follows Monte Carlo sampling with Russian Roulette. Each path has the standard termination conditions (not hitting anything, hitting an object with no reflectance properties or by a Russian Roulette termination condition).

The output image has also its own command line parameters: width, height and file name. One of the scenes (the default one) is a CornellBox: five walls forming a box (with an open side for the camera to watch), all of them diffuse gray except the left one (red) and the right one (green). Inside of that box, there must be a light source (somewhere in the upper half of the box, that could be the whole upper wall) and two spheres on the floor. One of the spheres has a Phong material while the other has a combination of perfect specular and perfect refraction.

Point lights and next event stimation

Point lights and next event estimation. Each point light has a power (RGB tuple) and a specific position in space, and the scene has as many light sources as needed. At each interaction of each path, the path tracer estimates direct lighting from all the point light sources by casting shadow rays (next eventestimation). The number of light sources affects rendering time. In order to compare the effect of next event estimation, another test scene has been done, a CornellBoxin which the light source is a point light source in the upper half of the box (instead ofa whole planar primitive).

Extensions

In order to improve the quality of the path tracer implemented the following extensions have been added:

  • Triangles: in spite of having planes and spheres, another geometry primitive has been added, triangles. The main reason why this primitive was implemented was that this primitive is so useful in order to create renders that are very expressive and attractive. Apart from that with this primitives anothers objects like pyramids or prisms can be generated.

  • Textures: this extension modulates the emission of an object or any of the coefficientsthat model its appearance (Phong BRDF, perfect specular or perfect refraction). Othertextures (bump maps or normal maps, for instance) can be added as well but they are harderto model because they need a tangent field.

These extensions where added after the assigment of the subject.

  • Parallelization with several threads of execution: a parallelization strategy at image has been implemented. This technique consits in subdivide the image into regions (subimages). Mutex objects has been added in order to have control of the critical section of the algorithm. This avoid possible race conditions. The number of threads can be changed with a constant in the code of the programm.

  • Loading progress render bar: this improvement helps the user to see if there are problems while path tracing is making a render. The bar shows information about how much percent has been completed.

  • Tone Mapping: this module is explained in the Tone mapping section of the wiki. This module has been use in order to improve the tones of the image. So more beautiful images have been got.

For more details please look the report of the Path Tracing project which is called pathtracer_report.pdf

Renders

These are a set of renders made with path tracer algorithm: