Direct3D 12 Ray Tracing Samples

Introduction to D3D12 Ray Tracing

Explore the power of real-time ray tracing with Direct3D 12. These samples demonstrate how to leverage the latest graphics hardware and the D3D12 Raytracing API to achieve photorealistic rendering, advanced lighting effects, and more. Dive into the code to understand the fundamental concepts, from acceleration structures to shader stages, and unlock new possibilities for your graphics applications.

Ray tracing opens up a new paradigm for rendering, allowing for more accurate simulation of light transport. This section provides a curated collection of samples, each focusing on specific aspects of D3D12 ray tracing implementation.

Featured Samples

Basic Ray Generation

A foundational sample demonstrating the essential steps for setting up and executing a basic ray tracing pipeline. Covers ray generation, closest hit, and miss shaders.

Basic Ray Generation RTX
View Sample

Acceleration Structure Building

Learn how to efficiently build and update bottom-up and top-down acceleration structures (BVH) for ray intersection testing.

Acceleration Structures BVH Performance
View Sample

Ray-AABB Intersection

A focused sample showcasing an optimized implementation of ray-axis-aligned bounding box (AABB) intersection tests, crucial for efficient ray traversal.

Intersection AABB Optimization
View Sample

Ray-Triangle Intersection

Explore the details of ray-triangle intersection algorithms, including Möller–Trumbore and barycentric coordinate methods, within the D3D12 RT framework.

Intersection Triangles Geometry
View Sample

Recursive Ray Tracing (Reflections)

Implement recursive ray tracing to achieve realistic reflections by bouncing rays off surfaces.

Reflections Recursion Shading
View Sample

Shadows with Ray Tracing

Demonstrates how to generate shadow rays to accurately compute shadows cast by lights.

Shadows Lighting Ray Casting
View Sample

Global Illumination Techniques

Implement advanced global illumination techniques like path tracing for more immersive and physically accurate lighting.

Global Illumination Path Tracing Advanced
View Sample

Key Concepts

Understanding the following concepts is crucial for working with D3D12 Ray Tracing:

Getting Started

To run these samples, you will need:

Each sample typically includes a solution file (.sln) that can be opened in Visual Studio. Refer to the individual sample documentation for specific build and execution instructions.

// Example of a simple ray generation shader snippet (HLSL)
struct RayPayload { float4 Color; };
[shader("raygeneration")]
void RayGen()
{
uint2 idx = DispatchRaysIndex().xy;
RayDesc ray;
ray.Origin = float3(0.0, 0.0, 0.0);
ray.Direction = float3(1.0, 0.0, 0.0); // Example direction
ray.TMin = 0.0;
ray.TMax = 1000.0;

RayPayload payload;
payload.Color = float4(0.0, 0.0, 0.0, 1.0);

TraceRay(TopLevelAS, 1, 0, ray, payload);

OutputImage[idx] = payload.Color;
}