Skip to content

alipbcs/ZetaRay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZetaRay

MIT

A hobby real-time Direct3D 12 path tracer. Mainly developed for learning and experimenting with the latest research in real-time rendering.

To achieve real-time frame rates, this renderer utilizes recent developments such as hardware-accelerated ray tracing (DXR), advanced sampling (ReSTIR), and smart upscaling (AMD FSR2).

Sponza

Subway Station based on the NYC R46 subway, rendered by ZetaRay. (Scene by Alex Murias.)

Highlight Features

  • ReSTIR DI for many-light sampling from emissive meshes, sun, and sky [4]. Sampling efficiency is increased by
    • Power sampling using the alias method
    • A world-space voxel grid with stochastic light reservoirs per voxel [5]
  • Indirect lighting methods include:
    1. Unidirectional path tracer
    2. ReSTIR GI [1]: A variant of ReSTIR effective for diffuse and moderately glossy surfaces, but less effective for highly glossy surfaces.
    3. ReSTIR PT [6]: A more advanced variant of ReSTIR with significantly better quality for highly glossy surfaces compared to ReSTIR GI.
  • Ray differentials for texture MIP selection
  • Physically-based surface shading model inspired by OpenPBR [7]
  • Single scattering sky and atmosphere [2, 3]
  • Render graph for automatic resource barrier placement and multi-threaded GPU command list recording and submission (more details below)
  • AMD FSR2 upscaling
  • Temporal anti-aliasing (TAA)
  • Auto exposure using luminance histogram
  • glTF scene loading with the metalness-roughness workflow. Following extensions are also supported:
    • KHR_materials_emissive_strength
    • KHR_materials_ior
    • KHR_materials_transmission
    • KHR_materials_clearcoat

Render Graph

Graphics APIs such as Vulkan and Direct3D 12 require resource barriers to be placed manually by the programmer. These barriers control synchronization, memory visibility, and additionally for textures, resource layout. As program complexity grows, manual placement can lead to issues such as:

  • Becoming highly error-prone and limiting extensibility and prototyping.
  • GPU command buffers can be recorded in multiple threads; correct usage and prevention of data-race issues may be hard to achieve.

Furthermore, using multiple command buffers requires a correct submission order—e.g., command list A writes to a resource that is read by command list B, so A has to be submitted before B.

A render graph can help with all of the above; by analyzing resource dependencies, a directed acyclic graph (DAG) is formed from which submission order is derived and barriers are automatically placed. A visualization is shown below.

Render graph

A sample frame render graph.

Sample Editor

The main sample application (Samples/ZetaLab) provides a light editor experience with the following features:

  • Load glTF scenes (note the preprocessing step below)
  • Change object transformations (translation, rotation, and scaling) using a 3D gizmo
  • Modify material properties
  • Move light sources (sun and sky or emissives) and change their intensity, color, etc.
  • Renderer options, such as the number of light bounces, texture filtering, ReSTIR parameters, camera settings (pinhole or thin lens, FOV, f-stop), tonemapper, and more
  • GPU performance metrics:
    • Frametime graph
    • Frametime for individual shaders using hardware timestamp queries
    • VRAM usage
  • Hot-reload shaders

Requirements

  1. GPU with hardware-accelerated ray tracing support (Nvidia RTX 2000 series or later, AMD RX 6000 series or later)
  2. Windows 10 1909 or later
  3. Visual Studio 2019 or later. Builds with both MSVC and ClangCL toolsets.
  4. CMake 3.21 or later

Build

Standard CMake. In the project directory, run:

> mkdir build
> cd build
> cmake ..

Before running the project, glTF scenes need to be preprocessed first by generating mipmaps and converting textures to DDS format. A command-line utility app (Tools/BCnCompressglTF) is provided for this purpose. It can be used as follows:

> cd bin
> BCnCompressglTF <path-to-gltf>

The outputs are:

  1. The converted glTF scene file in the same directory with a _zeta suffix (e.g., myscene.gltf -> myscene_zeta.gltf)
  2. The compressed textures in the <path-to-gltf-directory>/compressed directory.

For convenience, a preprocessed Cornell Box scene is provided (Assets/CornellBox/cornell.gltf). After building the project, you can run it as follows:

> cd bin
> ZetaLab ../Assets/CornellBox/cornell.gltf

Currently, Unicode paths are not supported. Support is planned for a future release.

Screenshots

Subway Station

Subway Station. (Scene by Alex Murias.)


Classroom

Modified Blender 'Agent 327 Barbershop'. (Original Scene from Blender demo files.)


Classroom

Modified Blender 'Classroom'. (Original Scene by Christophe Seux.)


Country Kitchen

Country Kitchen. (Scene by Jay-Artist.)


Bistro

Amazon Lumberyard Bistro. (Scene from Open Research Content Archive (ORCA).)


Dining Room

Dining Room. (Scene by MaTTeSr.)


San Miguel

San Miguel 2.0. (Scene from Morgan McGuire's Computer Graphics Archive.)


San Miguel

San Miguel 2.0. (Scene from Morgan McGuire's Computer Graphics Archive.)


Junk Shop

Modified Blender 2.81 Splash Screen. (Original scene by Alex Treviño, hair model by bbb59149.)

References

[1] Y. Ouyang, S. Liu, M. Kettunen, M. Pharr and J. Pantaleoni, "ReSTIR GI: Path Resampling for Real-Time Path Tracing," Computer Graphics Forum, 2021.

[2] S. Hillaire, "A Scalable and Production Ready Sky and Atmosphere Rendering Technique," Computer Graphics Forum, 2020.

[3] MinimalAtmosphere, https://github.com/Fewes/MinimalAtmosphere

[4] B. Bitterli, C. Wyman, M. Pharr, P. Shirley, A. Lefohn and W. Jarosz, "Spatiotemporal reservoir resampling for real-time ray tracing with dynamic direct lighting," ACM Transactions on Graphics, 2020.

[5] J. Boksansky, P. Jukarainen, and C. Wyman, "Rendering Many Lights With Grid-Based Reservoirs," in Ray Tracing Gems 2, 2021.

[6] D. Lin, M. Kettunen, B. Bitterli, J. Pantaleoni, C. Yuksel and C. Wyman, "Generalized Resampled Importance Sampling: Foundations of ReSTIR," ACM Transactions on Graphics, 2022.

[7] OpenPBR Surface, https://github.com/AcademySoftwareFoundation/OpenPBR

External Libraries

License

MIT License—see LICENSE for more details.