Skip to content

Blackgaurd/pathtracer-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Path Tracer

Path tracing is an algorithm which builds on the ray tracing algorithm to accurately render objects and scenes involving lights, reflections, shadows, and different types of materials. This is done my simulating the true physics of light, rather than simply approximating it as ray tracing would do. Thus, it yields much more realistic images at the cost of performance. Rather than simulating a single light ray per pixel, path tracing simulates thousands of them bouncing "randomly" off surfaces to achieve details that would otherwise be much more difficult with ray tracing, such as soft shadows, anti-aliasing, and color bleeding.

Project details

Implementation of the path tracing algorithm written in C++ and GLSL. Here are some of its features:

  • Supports single threaded rendering on the CPU or concurrent rendering on the GPU using OpenGL.
    • GPU rendering is chunked into smaller jobs to avoid hogging the GPU from the OS.
  • Positionable camera using a position/forward vector system.
  • Proof of concept realtime rendering using SFML (only works on Linux).
  • Logarithmic time ray-triangle intersections by using a bounding volume hierarchy (BVH) built with the surface area heuristic.
    • The BVH is implemented with neither recursion nor pointers to be compatible with GLSL. Rather, it uses a stack in place of recursion and an array to store nodes.
  • Support for various materials:
    • Emitting/light materials of variable brightness and colour.
    • Lambertian diffuse or matte surfaces using random hemisphere sampling BRDF.
    • Specular diffuse or mirror surfaces of variable roughness using a combination of hemisphere and specular sampling BRDF's.
  • Global illumination and soft shadows thanks to using path tracing instead of ray tracing.

Examples

Standard Cornell Box.

  • SPP (samples per pixel): 10,000.
  • Ray depth: 5.
  • Triangles in scene: 30.
  • Resolution: 1024x1024.
  • Completion time: 112 seconds on GPU (~50 billion rays).

box

Cornell box-esque scene with specular reflection walls of increasing roughness.

  • SPP: 10,000.
  • Ray depth: 5.
  • Triangles in scene: 32.
  • Resolution: 1024x1024.
  • Average completion time: 230 seconds on GPU (~50 billion rays).

box0 box0.05 box0.1 box0.3 box0.5 box0.8

Running

This project uses Bazel for building. To build any of the examples:

bazel build //examples:example-name

And to run the executable:

./bazel-bin/examples/example-name

To Do

  • explicit light sampling here
    • punctual (point) light sources
    • light attenuation
  • skybox

About

GPU accelerated 3D rendering in C++ and GLSL.

Topics

Resources

Stars

Watchers

Forks

Languages