Code Monkey home page Code Monkey logo

dxrpathtracer's Introduction

Path-traced image

DXR Path Tracer

This project is a very basic unidirectional path tracer that I wrote using DirectX Raytracing, also known as DXR. I mostly did this to learn the new API, and also for a bit of fun. Therefore you shouldn't take this as an example of the best or most performant way to implement a path tracer on the GPU: I mostly did whatever was fastest and/or easiest to implement! However it could be useful for other people looking for samples that are bit more complex than what's currently offered in the offical DirectX sample repo, or for people who want to start hacking on something and don't want to do all of the boring work themselves. Either way, have fun!

Build Instructions

The repository contains a Visual Studio 2019 project and solution file that's ready to build on Windows 10 using SDK 10.0.19041.0. All external dependencies are included in the repository (including a recent build of dxcompiler.dll), so there's no need to download additional libraries. Running the demo requires Windows 10 build 2004 or later, as well as a GPU/driver combination that supports D3D12_RAYTRACING_TIER_1_1.

The repository does not include textures for the Sponza and SunTemple scenes in order to avoid comitting lots of large binary files. To get the textures, download them from this release.

Using The App

To move the camera, press the W/S/A/D/Q/E keys. The camera can also be rotated by right-clicking on the window and dragging the mouse.

The render is progressively updated by shooting one ray per-pixel every frame, which takes anywhere from 14 to 30ms per frame on my RTX 2080 when the max path length is set to 3 (the default). Diffuse and specular sampling is currently supported, with lighting provided by a procedural sun and sky model. If you change a setting or move the camera, the render will reset and start accumulating samples again. Path lengths greater than 2 are computed by recursively tracing a new ray inside of the closest hit program, which is convenient but probably not the fastest way to things.

To improve the quality, increase the "Sqrt Num Samples" setting. As the name implies it's the square root of the number of samples, so increasing that value will increase the total render time non-linearly! You can also increase the maximum path length, which is capped at 3 (single-bounce) by default.

To switch between path-traced rendering and standard (boring) rasterization with no GI, toggle the "Enable Ray Tracing" setting.

Possible To-Do List

  • Support alpha-tested triangles for foliage
  • Investigate performance tradeoffs involved with having one D3D12_RAYTRACING_GEOMETRY_DESC per mesh in the source scene
  • Investigate higher-performance sampling schemes (currently using a stock implementation of Correlated Multi-Jittered Sampling)
  • Local light sources
  • Area light sampling with soft shadows
  • Non-opaque materials
  • Progress bar/text for the progressive render
  • Mip level selection using ray differentials

dxrpathtracer's People

Contributors

therealmjp avatar pzurita avatar stromaster 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.