Skip to content

StokastX/Nexus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nexus Renderer

Interactive physically based GPU path tracer from scratch written in C++ using CUDA and OpenGL.

Screenshots

cannelle_et_fromage camera6 glass_of_water stormtrooper kitchen ford_mustang bedroom spider bathroom piano

Features

  • Interactive camera with thin lens approximation: FOV, defocus blur.
  • Wavefront path tracing, see Laine et al. 2013. The path tracing algorithm is divided into specialized CUDA kernels accessing global work queues to get more coherent workloads and to reduce the amount of inactive threads. Kernel launches are optimized using CUDA graphs.
  • Persistent threads with dynamic ray fetching, see Aila and Laine 2009. The trace kernel is launched with just enough threads to fill the device. During traversal, inactive threads will fetch new rays in the global trace queue to avoid wasting resources.
  • BVH:
    • Standard SAH-based BVH (BVH2) using binned building
    • Compressed-wide BVH (BVH8), see Ylitie et al. 2017. BVH2 is collapsed into an 8-ary BVH. Nodes are compressed to 80 bytes encoding the child nodes' bounding boxes to limit memory bandwidth on the GPU.
    • GPU builder: implements the H-PLOC algorithm proposed by Benthin et al. 2024, a high-performance GPU-oriented BVH construction method. H-PLOC builds high-quality BVHs through hierarchical clustering of spatially nearby primitives. The full algorithm is implemented in my NexusBVH library.
  • The BVH is split into two parts: a top level structure (TLAS) and a bottom level structure (BLAS). This allows for multiple instances of the same mesh as well as dynamic scenes using object transforms.
  • Model loader: obj, ply, fbx, glb, gltf, 3ds, blend with Assimp
  • Materials:
    • Diffuse BSDF (Lambertian)
    • Rough dielectric BSDF (Beckmann microfacet model, see Walter et al. 2007).
    • Rough plastic BSDF (mix between diffuse and rough specular).
    • Rough conductor BSDF.
  • Importance sampling: cosine weighted for diffuse materials, VNDF sampling for rough materials.
  • Multiple importance sampling, see Veach 1997. BSDF importance sampling is combined with next event estimation (direct light sampling) and the results from both sampling strategies are weighted using the power heuristic to get low-variance results.
  • Texture mapping (diffuse, emissive).
  • HDR environment maps.

Prerequisites

Nexus is a CMake-based project and requires the following dependencies:

The project has been tested on both Windows (with Visual Studio) and Ubuntu.

Build

  1. Clone the repository with submodules:

    git clone --recurse-submodules https://github.com/StokastX/Nexus
  2. Generate the solution via cmake:

    mkdir build
    cd build
    cmake ..
  3. Build the project:

  • On Linux: Use make on your preferred build system:

    make -j
  • On Windows (Visual Studio): Open the generated solution file in Visual Studio. Right-click on the Nexus target, set it as the startup project, and press F5 to build and run.

Resources

Here are the main resources I used for this project.

Path tracing in general

Getting started on ray tracing

BVH

  • Jacco Bikker's guides on SAH-based BVHs really helped me implement my first BVH and traversal on the GPU which was surprisingly fast.
  • Stich et al. 2009 explain in details binned building and spatial splits for BVH2.
  • Ylitie et al. 2017 for compressed wide BVHs.

PBR materials

Sampling

GPU optimization

I also had a look at other renderer implementations such as Blender's cycles, Tungsten renderer, and Jan van Bergen's CUDA ray tracer.

Dependencies

Models

Packages

No packages published

Contributors 2

  •  
  •