Giter Site home page Giter Site logo

cppdirectxraytracing's Introduction

CppDirectXRayTracing

DirectX Raytracing Tutorials in C++

The main references of this tutorial are CSharpDirectXRaytracing and Nvidia tutorial. If not mentioned in the code, the tutorials from 01-07 are reconstructed from Nvidia tutorial, the 15-19 are ported from CSharpDirectXRaytracing. Part of the shader code in GI is modified from SIGGRAPH 2018 Course. All of those are awesome and useful resources to read.

The tutorial is served as the reconstruction and extension work of the Nvidia tutorial. The refactoring of the code is aiming at a eaiser understanding of DXR, and easier for the learners to extend. Unlike Falcor, the code doesn't has abstraction on the CPU host side.

The GI solution is packaged in release for win64 system.

Environment

Windows SDK 10.0.18362.0
Visual Studio 2019
GTX 1070 GPU Card (You can find if your graphics card supports DXR here)

Tutorials

The image shot of each sub-project, the projects can easily be run by clicking CppDirectXRayTracing.sln. Note the 7-14 is blank just because the tutorials diverged from the original nv turotials and I was too lazy to rename them.

Tutorial 1-6

Basic setting of the DXR.

Tutorial 7

Shader for ray-traced triangle

Tutorial 15

Pass vertex buffer and index bufer to shader instead of hand-made triangles.
The geometry construction is under Primitives.

Tutorial 16

Simple Phong lighting. Most of the changes are in the shader.

Tutorial 17

How to pass multiply geometry in to shader. This one combined the geometry into one vertex and index buffer, which is not practical, but doable.

Tutorial 17-2

The second way for passing multiple geometry.
The spheres are sent by index buffer and vertex buffer, the normals of the plane are tricky, specified in shader.

Tutorial 18

How to cast shadow ray and third way for passing multiple geometry. This is the same approach as Nvidia tutorial.
Bind primitive to different BLAS, each of the primitive has its own closest shader. Also instances of the spheres are binded to TLAS.
The aliasing of the shadow is potentially a bug in this way of sending geometry.

Tutorial 19

Reflections with Phong lighting. Shoot the reflection rays. Also see shaders in CSharpDirectXRaytracing
From now on, we stick to the second way of sending the geometry, which works best.

Tutorial 20

Set scene constant buffer and primitive constant buffer. This is useful for setting different materials.

Tutorial 21

How to do full global illumination in DXR. This tutorial implemented naive recursive ray tracer with Lambertian and GGX model. This sub-project is packaged as an win64-exe in release
Use keyboard number 1 to switch between Lambertian GI and AO with direct lighting.
Use keyboard number 2 to open GGX shading.
Use keyboard number 3 to open dynamic lighting.

Lambertian GI:

Lambertian GI

GGX GI:

GGX GI

AO with only direct light:

AO with only direct light

Dynamic Lighting:

Dynamic Lighting

Contribution

You are very welcomed to submit issues, extend the tutorial (e.g. better GI solution with less noise, techniques in Ray Tracing Gem), code quality improvements, code comment improvements, etc.

Resources

The Nvidia tutorial has a code walk through document, make sure to check it.
SIGGRAPH 2018 Course Good explanation of how to integrate the shader for global illumination.
Ray Tracing in One Weekend The basic theory of GI. The first among the series introduced the basics of ray tracing, the third among the series introduces the Monte Carlo strategy.

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.