🌞 A physically based monte carlo path tracer written in C++

Overview

Physically Based Path Tracer

The below 3D model for the Head of Michelangelo's David bust was taken from this link. Other .obj files taken from The Stanford 3D Scanning repository
Head of David

This repository contains the implementation of a physically based monte carlo path tracer in C++. The project avoids the use of graphics API's and attempts to implement simple physically based rendering effects from scratch.

This is a project I essentially come to in my free time and is something I intend to update sporadically. If you have read the code, or tried to create a scene and have found any flaws or errors in the way things have been done — do feel free to leave an issue!

Feature Tracker / To Do

  • Motion Blur
  • Antialiasing
  • Depth of Field
  • Bounding Volume Heirarchies
  • Multithread pixel processing
  • Add .obj object support
  • Importance Sampling
  • HDR Environment maps
  • Find a way to serialize BVH tree object (for re-use for large meshes)
  • Optimize and Multithread mesh BVH tree building
  • Optimize ray-triangle intersection routine
  • Implement additional BSDF's (Disney BSDF) and materials (sort of?)
  • Incorporate CUDA, get full rendering to happen on GPU

On halt for now, spending too much time on this

Denoiser

Noisy Render (Output) Normal map Albedo map Denoised Image

Since the application runs on the CPU, samples per pixel needs to be limited to obtain reasonable render times (even with multi-threading).

The images shown above are denoised using Intel® Open Image Denoise. The pre-compiled binaries (given in the website) fit right into this repository to call the shell script bin/denoise, which manages the whole denoising process and conversions.

The pre-compiled zip file (unzipped, includes a bin and a lib folder) needs to be moved into src/dependancies/, for the shell script denoise to work.

Usage

A sample binary has been uploaded with the repo (compiled on x86, as a 64 bit application), but its unlikely that it would generally work even on a system with the same configuration (try anyway, it just might). To compile in a device specific manner, you can create a Makefile using cmake (CMakeLists.txt given) or use the given Makefile.

After creating the Makefile using cmake and making/compiling the project (cmake . followed by make), the compiled binary (path-tracer) can be found in bin/ and is to be used with a single command line argument - the name of the scene in src/scenes/. (The folder src/scenes/ contains implementation of all the scenes in this readme file and few others. The .scene.h files are just C++, and the files were created mostly just for organisational purposes)

> ./bin/path-tracer GlowRoom

Running this should show a progress bar, after which 3 images will be stored in output - the noisy render (Primary output), an albedo image, and a normal map (To aid the denoising process). After these three images have been generated the denoise binary can be run in the same way that the main one was

> ./bin/denoise GlowRoom

The resolution of the output render and the samples per pixel have been hard-coded in main.cpp

Dependancies

A simple OpenMP call was used to multithread the loop which shoots multiple samples per pixel. The OpenMP dependancy is included by the CmakeLists.txt, but can easily be removed and worked without.

The project uses libraries for reading and writing images (stb_image and FreeImage) and for convenience. GLM was used for mathematical data types (vectors, matrices, etc.) and operations, but can easily be replaced by a few structs. ImageMagick is also required for commands in the denoise shell script.

More about depandancy set up in the sub-folder src/dependancies

Resources

This project takes a lot from Ravi Ramamoorthi's course - An intro to graphics; and the repository and code largely takes its structure and features from Peter Shirley's book series.

The Disney BSDF, though poorly incorporated and incomplete, takes a lot from this repository and the corresponding blog articles. Inspiration was also taken, but to a lesser extent from tinsel from mmacklin and GLSLPathTracer from knightcrawler25.

And just like everyone ever who has written a path tracer, constant references were made to Physically Based Rendering by Matt Pharr, Wenzel Jakob, and Greg Humphreys and its repository.

Note

This was more or less a pet project to be able to learn the fundamental basics of path tracing, and with every feature I added, I got carried away. I have licensed this project under the Zlib license, and do what you may with the code but I would highly recommend not to re-use the bsdf namespace and the core::Disney class, since some of the lobe calculations are off.

Issues
  • Segmentation fault

    Segmentation fault

    Hi, when I run the test case for David, using ./bin/path-tracer David, I got segmentation fault at line 277 in objects.cpp: glm::vec3 averaged_normal = (normals[fx - 1] + normals[fy - 1] + normals[fz - 1]) / 3.0f; the size of normal is 24 but fx ,fy ,fz is 167, 0 and 72 for the test case I'm running.

    I'm not sure if there's anything wrong with the fx, fy, fz value read from the file is wrong, or why the value will exceed size of normal.

    opened by AEstein 1
Releases(v1.0)
Owner
Aman Shenoy
Aman Shenoy
A path tracer based on hardware ray tracing

GoldenSun GoldenSun is a GPU path tracer. It uses hardware ray tracing APIs to do the tracing. As an experimental project, there is no release plan, n

Minmin Gong 20 Feb 27, 2022
A Hydra-enabled GPU path tracer that supports MaterialX.

A Hydra-enabled GPU path tracer that supports MaterialX.

Pablo Delgado 156 Jul 27, 2022
A realtime Vulkan voxel path tracer.

brickmap-vulkan A realtime Vulkan voxel path tracer. This is a work in progress! This system is a Vulkan/SPIRV implementation of the BrickMap by stijn

brandon reinhart 0 Jul 29, 2022
ReferencePT - Supplemental code accompanying Ray Tracing Gems II, Chapter 14: The Reference Path Tracer

The Reference Path Tracer Code sample This is a supplemental code accompanying Ray Tracing Gems II, Chapter 14: The Reference Path Tracer. Code is bas

Jakub Boksansky 143 Jul 28, 2022
physically based renderer written in DX12 with image-based lighting, classic deffered and tiled lighting approaches

Features Classical Deferred Renderer Physically Based shading Image Based Lighting BRDF Disney model (Burley + GGX) Tangent space normal mapping Reinh

Alena 35 Jun 2, 2022
SoL (for Speed of Light, or sun in Spanish) is a Physically-based rendering library written in modern C++

SoL (for Speed of Light, or sun in Spanish) is a small rendering library written in C++20. Its goal is to strike a good balance between performance and usability, and allow easy experimentation for rendering researchers.

Arsène Pérard-Gayot 10 May 19, 2022
Software ray tracer written from scratch in C that can run on CPU or GPU with emphasis on ease of use and trivial setup

A minimalist and platform-agnostic interactive/real-time raytracer. Strong emphasis on simplicity, ease of use and almost no setup to get started with

Arnon Marcus 43 Jul 22, 2022
Yocto/GL: Tiny C++ Libraries for Data-Driven Physically-based Graphics

Yocto/GL: Tiny C++ Libraries for Data-Oriented Physically-based Graphics Yocto/GL is a collection of small C++17 libraries for building physically-bas

Fabio Pellacini 2.3k Jul 29, 2022
Vulkan physically based raytracer including denoising

VulkanPBRT Vulkan physically based raytracer including denoising. The GPU raytracer is based on Vulkan only, as well as for the denoising only the Vul

null 15 May 26, 2022
A modern C++ physically based renderer

The Dakku Renderer Warning: This project is currently under developing and does not guarantee any consistency. About Dakku is a physically based rende

xehoth 6 Apr 15, 2022
A physically based shader for woven cloth

ThunderLoom A physically based shader for woven cloth This projects consits of three main parts: Irawan shading model At its core is an implementation

null 89 Jul 21, 2022
Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.

pbrt, Version 3 This repository holds the source code to the version of pbrt that is described in the third edition of Physically Based Rendering: Fro

Matt Pharr 4.2k Aug 6, 2022
appleseed is an open source, physically-based global illumination rendering engine primarily designed for animation and visual effects.

appleseed is an open source, physically-based global illumination rendering engine primarily designed for animation and visual effects.

appleseedhq 1.9k Aug 2, 2022
SVG animation from multiple SVGs or single GIF using tracer

svgasm svgasm is a proof-of-concept SVG assembler to generate a self-contained animated SVG file from multiple still SVG files with CSS keyframes anim

Tom Kwok 168 Jul 20, 2022
Pathway is an Android library that provides new functionalities around the graphics Path API.

Pathway is an Android library that provides new functionalities around the graphics Path API.

Romain Guy 119 Jul 28, 2022
Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.

Horde3D Horde3D is a 3D rendering engine written in C++ with an effort being as lightweight and conceptually clean as possible. Horde3D requires a ful

Volker Vogelhuber 1.3k Aug 5, 2022
A library for high-performance, modern 2D graphics with SDL written in C.

SDL_gpu, a library for making hardware-accelerated 2D graphics easy. by Jonathan Dearborn SDL_gpu is licensed under the terms of the MIT License. See

Jonathan Dearborn 1k Aug 3, 2022
Linux/X11 tool for intercepting mouse events and executing commands. Written in Kotlin Native.

XMG XMG (X11 Mouse Grabber) is a Linux/X11 tool for intercepting mouse button press events and triggering actions. It's a way of making use of the ext

Eduardo Fonseca 12 Sep 11, 2021
A toy renderer written in C using Vulkan to perform real-time ray tracing research.

This is a toy renderer written in C using Vulkan. It is intentionally minimalist. It has been developed and used for the papers "BRDF Importance Sampl

Christoph Peters 261 Jul 24, 2022