Coder Social home page Coder Social logo

rtao's Introduction

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:

rtao's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.