Coder Social home page Coder Social logo

pathtracer-cpp's Introduction

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

pathtracer-cpp's People

Contributors

blackgaurd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.