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:

alt

1440p (2560x1440) @ 8 samples, 4 max ray bounces, in under 9 minutes

Technical Sheet

Tools that I used whilst working on this project:

  • IDE:
  • Frameworks:
    • SDL - OS Windowing, Basic Platform-Agnostic Renderer, Input
    • ImGui - "Immediate"-mode GUI
    • GLM - Graphics Programming Oriented Math Library
    • STB - Image Write Library ("stb_image_write.h")

Helpful Resources