Skip to content

jx124/raytracer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monte Carlo Ray Tracer

Test scene
Test scene with diffuse, metallic, and glass spheres, rendered with depth of field (100 samples per pixel, render time: ~7s).

Quick Start

  1. Download the latest GLFW source packages from here and copy them into include/glfw/.
  2. Download the latest GLAD loaders from here with the following settings:
    • Language: C/C++
    • Specification OpenGL
    • API gl: Version 4.6
    • Profile: Core
    • Options: Tick Generate a loader
  3. Copy the glad.h file into include/glad/, the khrplatform.h file into include/KHR/, and the glad.c file into src/.
  4. Clone the GLM repo from here and copy the contents of the glm directory into include/glm/.
  5. Install dependencies: sudo apt install cmake xorg-dev (For non X11 on Unix users, check out this guide for more details).
  6. Give permission to the build script: chmod +x build.sh
  7. Build and run the program ./build.sh -r.

Features

This is a toy path tracer meant to explore concepts in computer graphics, parallel programming, as well as various statistical methods e.g. Monte Carlo estimation, multiple importance sampling, low-discrepancy samplers etc. Thus, some features present in production path tracers may not be implemented.

Integrators

  • RandomWalkIntegrator: For every ray intersection, uses importance sampling on the BSDFs of materials to choose the next ray direction, then recursively samples that direction.
  • SimplePathIntegrator: Similar to the RandomWalkIntegrator, but changes the recursive function calls to an iterative one, and additionally carries out next event estimation by sampling the lights in the scene to further minimize error.
  • PathIntegrator: Builds on the SimplePathIntegrator by using multiple importance sampling to weigh the BSDF and light samples. Implements Russian roulette path termination to cut down on low contribution rays and improve Monte Carlo efficiency.
Integrator Sample image Comments
RandomWalkIntegrator Scene rendered with the RandomWalkIntegrator at 200 samples per pixel 200 samples per pixel, render time: ~34s.
SimplePathIntegrator Scene rendered with the SimplePathIntegrator at 200 samples per pixel 200 samples per pixel, render time: ~24s.
PathIntegrator Scene rendered with the PathIntegrator at 200 samples per pixel 200 samples per pixel, render time: ~19s.

As seen from these images, the noise present in the scene rendered by the SimplePathIntegrator is much smaller despite the shorter rendering time and equal number of samples per pixel. However, new artefacts (the bright pixels) are introduced into the image. This is resolved in PathIntegrator which has an even shorter rendering time.

Samplers

  • IndependentSampler: returns a uniform sample.

Materials

  • Lambertian: perfectly diffuse material. Modifiable attributes:
    • Color
    • Emission
  • Metal. Modifiable attributes:
    • Color
    • Fuzz
  • Dielectric: glass-like material that both refracts and reflects light. Modifiable attributes:
    • Index of refraction

Geometries

  • Spheres
  • Quadrilaterals

Lights

  • Quadrilateral area lights

Optimizations

  • Parallelization using OpenMP (~7.4x speedup on 16 core machine).
  • Bounding Volume Hierarchies (BVHs) to speed up ray intersection tests (~4.7x speedup).

Acknowledgements

This project uses material from the following sources:

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages