Ilia A. Lebedev


5/10/2010 - Assignment 5 : An HDR path tracer.

Description

We chose to extend our already feature-packed raytracer (see assignment 4). We leveraged the framework from the previous assignment, and (aside from countless tweask and bugfixes) added the following key features:

  • An unbiased Monte Carlo renderer (using path tracing), which produces HDR images using the same parameters as the previously completed raytracer.
  • Path termination using Russian Roulette.
  • Background material (for things such as solid color backgrounds, sky, infinite reflections, etc).
  • An acceleration structure for faster ray tests (Bounding box hierarchy).
  • Many small algorithmic optimizations that made the path tracer (and the ray tracer) considerably faster.
  • An improved mechanism for antialiasing (per-pixel array of samples using the sinc function).
  • BRDF-based shading for all of the materials supported by our renderer in assignment 4 with appropriate importance sampling.
  • A very simple overcast skylight material.
Additionally, the project has all of the features presented in assignment 4.

Due to end-of-semester matters, we were unable to do as much as we wanted. The most notable of these unfortuante omissions is a bidirectional ray tracing algrorithm. The current implementation has limited efficiency (requires a large number of samples per pixel, despite material-specific importance sampling). We were unable to complete a metropolis light transport renderer in time for this deadline. The other unfortunate omission is support for transparent surfaces. We deemed a simple solution with perfect refractions unsuitable, as we sought to implement an unbiased renderer, and had trouble finding helpful literature that discussed BRDFs for transparent materials.

Executable and Source

  • A x86 binary is here.
  • Please contact Ilia if you would like to obtain the source code.

Notable Images

Due to insufficient allowance of rendering time (we have other classes too!), all of the images below were produced with 90-100 samples/pixel. The tube light images were rendered using 50 samples/pixel.
All run times are reported for an Intel Nahalem architecture (which helped a lot since path tracing is very much memory bound) clocked at 3GHz.

12 minutes. Radiant blue backlight. Three glowing spheres. Notice the color bleeding

3 minutes. A single glowing sphere.

6 minutes. There is no direct light in this scene. (anti-aliasing is disabled).

3 minutes. Notice that the diffuse surface is white at the point of contact with the glowing sphere.

6 minutes. There are 3 colored spherical lights above the camera's view.

2 minutes. The only light comes from an simple model of an overcast sky in the background.

2 minutes.

2 minutes.

<1 minute.

2 minutes. The gradient above is the "sky".

References

The following literature was used (a lot) in the design of this project:
  • Lafortune, WillemsUsing the Modifed Phong Refectance Model for Physically Based Rendering
  • Ashikhmin, Shirley, An Anisotropic Phong Light Reflection Model
  • Veach, Guibas, Metropolis Light Transport
  • Shirley, Realistic Ray Tracing
  • Lawrence, Rusinkiewicz, Ramamoorthi Efficient BRDF Importance Sampling Using a Factored Representation
  • Course notes and book

Scripting Language

We significantly extended and improved the scripting language assigned as part of this project. While maintaining compatibility with the test scenes provided, the language includes hooks for the extra features of our compiler, and productivity features such as file sourcing and reset of the current scene. Offset addressing is uded to allow re-use via source.

The following shorthands are used in describing the semantics of the scripting language:

  • i_var : an integer value for "var".
  • f_var : a decimal value for "var".
  • s_var : a string value for "var" with no whitespace.
  • 3_var : a tiplet of decimal values for "var" (a color or a vector).
Command Semantic Description
Scripting Features
Source from File source (filename) Executes a script file, allowing re-use of scene parts. Due to
Comment #(...)\n If you don't know, I can't help you.
Scene Reset reset Removes everything from the scene. Useful in interactive mode.
Exit exit Terminates the interpretation of the current command stream. Useful terminating execution from file and in interactive mode
Global Settings
Output Resolution size (i_width >= 1) (i_height >= 1) Sets the dimensions (in pixels) of the image produced.
Maximum Recursion Depth maxdepth (i_depth >= 0) Sets the maximum number of ray bounces to simulate. This controls the probability for Russian Roulette.
Anti-Aliasing supersample (i_samples2 >= 1) Sets the size of the jittered grid (N2 samples per pixel) for anti-aliasing.
Samples per Pixel resample (i_samples >= 1) Sets the number of rays to trace per jittered sub-pixel. Useful for fine-tuning the number of samples used by the path tracer.
Output File Name output (s_filename) Sets the file name of the output image (no extension!). EXR format is used for HDR images, while 24-bit BMP is used otherwise.
Preview File Name preview (s_filename) Sets the file name of a JPEG preview file. Used when saving an HDR image for instant visualization.
Camera camera (3_eye) (3_center) (3_up > 0) (f_vertical_fov > 0) Specifies the origin, focus, and up vector, as well as the vertical field of view (in degrees) of the camera.
Lens Size (for DOF) dof (f_amount) Sets wjat is effectively the lens size for the depth of field effect. Distributed rendering is used to jitter the camera eye position, weighing the contribution of each sample using a gaussian function.
Maximum Vertex Buffer Size maxverts (i_num >= 1) Sets the max depth of the vertex buffer.
Maximum Normal Buffer Size maxvertnorms (i_num >= 1) Sets the max depth of the normal buffer.
Commands
Render render [hdr] (image/depth/normals/photo) Invokes the renderer, which produces and saves the image. An optional "hdr" flag controls whether the image is saved as a high dynamic range file or a standard bitamp. Several render passes are available (and must be specified): depth map, normal map, and the full image. The "photo" flag uses radiance estimation using path tracing. Creates a bounding box hierarchy as a pre-processing step.
Save Rendered Image save (ldr/hdr) Saves the last-rendered image as a high dynamic range image or as a standard bitmap.
Post-Process Rendered Image postprocess (monochrome) Applies the specified post-process effect to the image (currently only monochrome). Other effects, such as gaussian blur can easily be added.
Geometry
Sphere sphere (3_center) (f_radius) Creates a sphere of a specified radius at a specified location. The current material is applied.
Vertex vertex (3_center) Create a new vertex, which can be used for creating triangles.
Vertex with Normal vertexnormal (3_center) (3_normal >= 0) Create a new vertex with a specified normal, which can be used for creating triangles with interpolated normals.
Flat Triangle tri (i_idex >= 0) (i_idex >= 0) (i_idex >= 0) Create a new triangle using specified vertex indices (idexing is offset by a frame pointer, allowing creating a separate vertex address space for each sourced file). The normal is perpendicular to the triagnle plane. The current material is applied.
Triangle with Interpolated Normals trinormal (3_center) (f_radius) Create a new triangle using specified vertex indices (idexing is offset by a frame pointer, allowing creating a separate vertex address space for each sourced file). The normal is interpolated across the triangle area from the vertex normals. The current material is applied.
Box box (3_center) (3_dimensions) Create a new axis-aligned box of specified dimensions at the specified location. Use a rotation transform to move the box to a desired location. The current material is applied.
Plane plane (3_point) (3_normal) Create a new infinite plane given a point on the plane and a perpendicular vector. The current material is applied.
Disk disk (3_center) (3_normal) (f_radius) Create a new disk plane given a center point, a radius, and a perpendicular vector. The current material is applied.
Transformations
Push Transfrom pushTransform Pushes an identity transform to the stack.
Pop Transform popTransform Removes the most recently pushed transform from the stack.
Translate translate (3_xyz) Modifies the transform on the top of the stack to add translation by a specified vector.
Non-Uniform Scale scale (3_xyz) Modifies the transform on the top of the stack to add scaling by a specified tripple.
Rotate About Axis translate (3_axis) (f_degrees) Modifies the transform on the top of the stack to add rotation about a specified vector by the specified angle (in degrees).
Materials
Create a new Material material (flat/lambert/phong/translucent/checkers) (args) Creates a new material. The material shader must be specified, and can be one of:
  • Flat: cartoony shader with lighting and shadows.
  • Lambert: a diffuse material
  • Phong: a standard phong shader
  • Translucent: a partially opaque material, which simulates light scattering through materials such as milk and dense glass.
  • Checkers: A simple 3D checkered material with a wider band at the main axes for debugging.
Diffuse diffuse (3_rgb) Create a copy of the current material with the specified diffuse color.
Specular specular (3_rgb) Create a copy of the current material with the specified specular color.
Shininess shininess (3_rgb) Create a copy of the current material with the specified shininess.
Emission emission (3_rgb) Create a copy of the current material with the specified emission color.
Ambient ambient (3_rgb) Create a copy of the current material with the specified ambient color.
Transparency specular (3_rgb) Create a copy of the current material with the specified transparency. Transparency is used in the refraction calculations. The sum of transparency and reflectance should not exceed 1.
Reflectance reflectance (f_reflectance) Create a copy of the current material with the specified reflectance. Reflectance is used in the reflection calculations. The sum of transparency and reflectance should not exceed 1.
Index of Refraction ior (f_ior) Index of refraction is used in computing the angle of refracted light, according to Snell's law. The ray is correctly refracted when entering and leaving the surface.
Reflection Blur gloss (f_amount) A stochastic effect, which jitters the surface normal used in reflection calculations to produce a brushed metal effect. More than one sample is usually needed to get the desired result (glosssamples or imagesamples can be used to this end).
Reflection Samples glosssamples (i_samples) Sets the number of rays averaged in computing the reflection color. Useful with glossy reflections.
Refraction Blur frost (f_amount) A stochastic effect, which jitters the surface normal used to compute the transmitted ray to produce an effect similar to sub-surface scattering, or a rough transmissive surface (frost). More than one sample is usually needed to get the desired result (frostsamples or imagesamples can be used to this end).
Reflection Samples frostsamples (i_samples) Sets the number of rays averaged in computing the refraction color. Useful with frosty refractions.
Lights
Create Directional Light directional (3_towards_light) (3_color) Creates a directional light with the direction opposite the one specified (vector specifies the direction towards the light). The specified color is used.
Create Point Light point (3_towards_light) (3_color) Creates an unattenuated point light at the speficied position. The specified color is used.
Set Light Attenuation attenuation (3_const_lin_quad) Sets the constant, linear and quadratic attenuation of the last-created light.
Light Samples lightsamples (i_samples >= 1) Controls the number of times the light is sampled per lighting calculation. Useful when using a scattered or area light.
Light Spread lightspread (f_spread) Controls the amount of scattering for a directional light, or the size (spherical) of a point light. Used to produce a soft shadow effect.