Rookie Awards 2024 - Open for Entries!
CPU pathtracer in C++ from scratch
Share  

CPU pathtracer in C++ from scratch

by TheSandvichMaker on 1 Jun 2021 for Rookie Awards 2021

A CPU pathtracer written in C++ from scratch as a university project.

2 1597 0
Round of applause for our sponsors

CPU Pathtracer in C++ from scratch.

This monte-carlo pathtracer is the second project I did for the Breda University of Applied Sciences. The pathtracer runs on the CPU, using multithreading, and can render scenes with large numbers of primitives (triangles, planes, spheres, boxes), simulating both dielectric and metallic materials.

Read the source on GitHub


Some of the features and techniques leveraged are:

- Bounding Volume Hierarchies for scenes and meshes, for fast intersection of large numbers of primitives.
- Next Event Estimation for the fast evaluation of direct light.
- Cosine-weighted Importance Sampling of the Hemisphere for the fast evaluation of indirect light.
- Multiple Importance Sampling to combine the contributions of next event estimation and importance sampling of the hemisphere more effectively.
- Configurable Reconstruction Filters for improved image reconstruction, resulting in better anti-aliased images.
- Russian Roulette path termination, terminating low-contribution paths randomly for faster convergence rates while keeping an unbiased renderer.
- Stratified Sampling for more well-distributed sampling sequences with better convergence rates than regular white noise.
- HDR environment maps provide natural lighting in scenes with ease, imported using a handwritten .hdr parser.
- Tonemapping, sRGB transform and TPDF blue noise dither to output a high quality image mapped from high dynamic range into the final 8 bits per channel output image format.
- Nested dielectrics allowing for simulating more complex scenes such as a glass marble with air bubbles.
- Simple but responsive UI using rxi's microui library, running on a separate thread from the rendering for full responsiveness even if the renderer is completely locking up.

Without Next Event Estimation / With Next Event Estimation
Both images were taken with 64 samples per pixel.

Nested dielectrics
Simulating a glass marble with air bubbles inside.

Youtube video showing off the pathtracer in realtime

The recording is at 960x540 because otherwise the framerate of the recording would be too low.

Made by Daniƫl Cornelisse, first year games programmer at the Breda University of Applied Sciences.

Third party resources used:
SDL2
Microui
stb_image

Comments (0)

This project doesn't have any comments yet.