Skip to content
/ RTAO Public

Ray Traced Ambient Occlusion (RTAO) implemented using DirectX Raytracing (DXR)

Notifications You must be signed in to change notification settings

boksajak/RTAO

Repository files navigation

RTAO

This is an implementation of Ray Traced Ambient Occlusion (RTAO) using DXR. Code is based on a IntroToDXR Project by Adam Marrs - you should check it out for build instructions and code description.

Release Mode

How it works

RTAO is meant as a replacement for typical SSAO effects found in many rendering engines, and therefore is implemented in a similar way. It is executed as a post-processing effect in two passes, which are separate from the main geometry rendering pass:

  1. AO raytracing pass - uses normals and depth from main rendering pass to reconstruct world space position of visible pixels, and shoots AO rays in a normal-oriented hemisphere from there.
  2. Filtering pass - applies temporal filter (box filter) and spatial low-pass filter (gaussian blur) on a noisy result from previous pass

AO raytracing pass simply shoots selected number of AO rays, using directions from a pre-calculated sample-set. It uses basic temporal accumulation and filtering - AO is stored for a few previous frames in a cache. Cached values are first aligned with current frame using reverse reprojection (which requires motion vectors from a renderer). A filtering pass then applies a box filter on cached values, and a spatial filter to smooth out the results.

Where to go from now

This is a basic implementation that can (and should) be improved! Try this:

  • Calculate AO in a 'main pass' - if you're using ray tracing for primary rays, you can add secondary AO rays directly to it, avoiding the need to execute another pass specifically for AO - make sure however to use simple closest-hit shader for AO rays, that does not load any materials and uses simple payload structure (just the T distance).
  • Implement downsampling - AO can be calculated in a lower resolution than main image. Make sure to execute filtering pass in full resolution to preserve sharpness on geometry edges (prevent unpleasant halo artifacts). Try adding dithering to the low-resolution result to reduce some of the "blockiness"
  • Adaptive sampling - use less samples in a great distance or in dark image areas.
  • Better sample-sets - find sample-sets that yield better visual results, take a look at interleaved sampling
  • Better filtering approaches - both temporal and spatial filters can be adjusted and tuned for specific scenes - dynamic scenes may not like the temporal approaches, but movement will hide noise better.

References

Requirements

  • Windows 10 v1809, "October 2018 Update" (RS5)
  • Windows 10 SDK v1809 (10.0.17763.0). Download it here.
  • Visual Studio 2017 or VS Code

Command Line Arguments

  • -width [integer] specifies the width (in pixels) of the rendering window
  • -height [integer] specifies the height(in pixels of the rendering window
  • -model [path] specifies the file path to a OBJ model

Licenses and Open Source Software

The code uses three dependencies:

The repository includes assets for use when testing the renderer:

About

Ray Traced Ambient Occlusion (RTAO) implemented using DirectX Raytracing (DXR)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published