- Forward


Path Tracing
An Introduction with Examples in C++


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Review
Back SMYC Forward
  • The Idea:
    • Trace rays backward from the view plane to the light source(s)
    • Find the intersection between the ray and objects in the scene
    • Each trace follows a single stochastic path
    • Multiple rays are used per pixel to account for propagation differences
  • Existing Elements:
    • A Ray class, an empty (for semantics only) Material interface, a Shape3D interface, an Intersection class, a CompositeShape (in the sense of the composite pattern) class, some classes that implement the Shape3D interface, and a Light class
Designing and Implementing a Path Tracer
Back SMYC Forward
  • What's Needed:
    • A non-empty PathTracingMaterial interface
    • Some classes that implement the RayTracingMaterial interface
    • A PathTracer
  • Some Simplifying "Assumptions":
    • A single Light
    • Use stocahstic sampling for antialiasing
    • Ignore depth of field (i.e., focus)
The PathTracingMaterial Interface
Back SMYC Forward
cppexamples/graphics3d/pathtracing/PathTracingMaterial.h
 
The Matte Class
Back SMYC Forward

The Specification

cppexamples/graphics3d/pathtracing/Matte.h
 
The Matte Class (cont.)
Back SMYC Forward

The Implementation

cppexamples/graphics3d/pathtracing/Matte.cpp
 
Generating Random Points
Back SMYC Forward

A Brute Force Approach

cppexamples/graphics3d/graphics3dUtilities.cpp (Fragment: randomPointInUnitDisk)
 
The Glossy Class
Back SMYC Forward

The Specification

cppexamples/graphics3d/pathtracing/Glossy.h
 
The Glossy Class (cont.)
Back SMYC Forward

The Implementation

cppexamples/graphics3d/pathtracing/Glossy.cpp
 
Reflections
Back SMYC Forward
cppexamples/graphics3d/graphics3dUtilities.cpp (Fragment: reflect)
 
The Transparent Class
Back SMYC Forward

The Specification

cppexamples/graphics3d/pathtracing/Transparent.h
 
The Transparent Class (cont.)
Back SMYC Forward

The Implementation

cppexamples/graphics3d/pathtracing/Transparent.cpp
 
Refraction
Back SMYC Forward
cppexamples/graphics3d/graphics3dUtilities.cpp (Fragment: refract)
 
Reflection/Transmission Probability
Back SMYC Forward
cppexamples/graphics3d/graphics3dUtilities.cpp (Fragment: fresnel)
 
The PathTracer Class
Back SMYC Forward

The Specification

cppexamples/graphics3d/pathtracing/PathTracer.h
 
The PathTracer Class (cont.)
Back SMYC Forward

The Implementation

cppexamples/graphics3d/pathtracing/PathTracer.cpp
 
An Example
Back SMYC Forward
path-tracing_spheres
There's Always More to Learn
Back -