- Forward


Ray 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
    • One ray can propagate into multiple rays (e.g., reflection, transmission)
  • 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 Ray Tracer
Back SMYC Forward
  • What's Needed:
    • A non-empty RayTracingMaterial interface
    • Some classes that implement the RayTracingMaterial interface
    • A RayTracer
  • Some Simplifying "Assumptions":
    • A single Light
    • Ignore attenuation
    • Ignore aliasing
    • Ignore depth of field (i.e., focus)
The RayTracingMaterial Interface
Back SMYC Forward
cppexamples/graphics3d/raytracing/RayTracingMaterial.h
 
The Matte Class
Back SMYC Forward

The Specification

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

The Implementation

cppexamples/graphics3d/raytracing/Matte.cpp
 
The Light Intensity
Back SMYC Forward

For Multiple Possible Light Sources (Even Though There Is Only One)

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

The Specification

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

The Implementation

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

The Specification

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

The Implementation

cppexamples/graphics3d/raytracing/Transparent.cpp
 
Refraction
Back SMYC Forward
cppexamples/graphics3d/graphics3dUtilities.cpp (Fragment: refract)
 
Reflection/Transmission Proportion
Back SMYC Forward
cppexamples/graphics3d/graphics3dUtilities.cpp (Fragment: fresnel)
 
The RayTracer Class
Back SMYC Forward

The Specification

cppexamples/graphics3d/raytracing/RayTracer.h
 
The RayTracer Class (cont.)
Back SMYC Forward

The Implementation

cppexamples/graphics3d/raytracing/RayTracer.cpp
 
An Example
Back SMYC Forward
ray-tracing_spheres
There's Always More to Learn
Back -