3D Scene Editor + Raytracer
Overview
A raytracing application, initially based on TinyRaytracer with various improvements + features being added over time. Its aimed to be a general purpose realtime raytracer for me to further familiarize myself with computer graphics as a whole, with features planned to tackle other areas such as rasterization and compute shaders. The current features included are:
- Realtime preview - Realtime updated preview of the render framebuffer, enabling for realtime scene editing by utilizing a secondary thread to update the preview, thus not interrupting the render itself on +2 CPU threaded systems
- Scene Object Editing - Select objects by clicking on them and edit all their properties from within the application itself
- Halton Sampling - Using the halton sequence, renders are anti-aliased by jittering the camera with a well-distributed sequence, reducing bias
- BVH-Acceleration - Using a BVH-node tree, rays are intersection checked against BVH nodes to reduce un-needed intersection checks with objects are not children of the validly tested BVH nodes
It's early days for this project as I try to re-familiarize myself with raytracing specifically, but I plan to add the following features:
- Optimized Preview - Currently the entire HDR framebuffer is copied and converted into LDR for the render preview texture every single frame. This is far from ideal and should only copy pixels that have been rendered since the last update frame
- CPU Multithreading - Modern CPUs have many CPU cores, and raytracing is thankfully a quite easy task to parallelize, so why not use them! This shouldn't require much effort with my current code (the preview already uses a separate thread)
- Translation, Rotation and Scaling Transformations - Planes currently are "rotated" via their normal vector, which limits what sort of rotations you can achieve. This will be especially important once triangle + mesh objects are added
- Material Texture Support - Materials currently only support a solid color, so adding texture support would allow for much higher fidelity materials, especially in combination with PBR
- PBR Materials - Currently the materials are mostly using simple lambert shading, which look fine but PBR is when things truly start to look photo-realistic
- Tone Mapping - Convert the HDR framebuffer (floating point, values more than 1) to an LDR image with gamma correction and specific modes such as filmic, reinhardt and ACES to achieve a more photorealistic look
- Mesh Support - Adding triangles and then mesh support would allow for much more complex scenes to be created within the raytracer
- Scene Serialization - Serialize the scene into a file that can be (re)loaded into the application for future use
- Rasterized Render Preview - For more immediate scene editing (without having to reduce the render resolution extremely low), render the scene preview using general GPU rasterization for quicker camera + object placement
- Compute Shader Raytracing - Move the raytracer onto the GPU entirely, allowing for much faster performance due to GPUs parallelism design. Will likely have to use Vulkan (via MoltenVK) since MacOS's OpenGL doesn't have compute shader support
- ReSTIR - Essentially a method for reusing samples from previous frames when the camera or scene changes, significantly enhancing render times
Source Code: Still In Development!
Demo
Demos performed on a M1 Macbook Air (2020), using a single CPU core:
1440p (2560x1440) @ 8 samples, 4 max ray bounces, in under 9 minutes
Current demo of the application, allowing for scene objects to be manipulated. Rendered 720p (1280x720) @ 8 samples, 4 max ray bounces, in under 2 minutes in a scene containing 1005 objects
60FPS Realtime preview of the scene (currently low-resolution raytracing, but plan to have a rasterized preview)
Technical Sheet
Tools that I used whilst working on this project:
- IDE:
- Frameworks:
Helpful Resources
- TinyRaytracer - A great (re)introduction to raytracing with minimal code to make it more digestible. Also served as a starting point for my project
- Raytracing in One Weekend (Book Series) - Wonderful series of web books about creating a increasingly more capable raytracer
- PBR Book (3rd Edition) - Fantastic resource on PBR (Physically Based Rendering)
- ScratchAPixel - Wonderful free education site on computer graphics