Course contentsShow
← Unreal Engine Game Development
Lesson 479 of 8807. Visual Fidelity and RenderingFree lesson

Leveraging Hardware Accelerated Ray Tracing

You will configure Unreal Engine's hardware-accelerated ray tracing features to generate physically accurate reflections, shadows, and global illumination in real-time.

In this lesson, you will learn how to configure Unreal Engine’s hardware-accelerated ray tracing to achieve physically accurate lighting, reflections, and shadows in real-time.

While standard deferred shading uses screen-space techniques (like SSR or SSAO) that rely only on what is visible to the camera, hardware ray tracing casts rays into the scene to gather data from off-screen or occluded objects. This effectively bridges the gap between pre-baked lightmaps and dynamic real-time performance.

Enabling the Pipeline

To begin, ensure your project is using DirectX 12 (SM6) under Project Settings > Platforms > Windows > Default RHI. Once enabled, navigate to the Post Process Volume settings to activate the features. You will want to toggle:

  • Ray Tracing Global Illumination (RTGI): Replaces indirect light bounces with physically accurate light propagation.
  • Ray Tracing Reflections: Provides perfect mirrors and accurate refraction, even for objects behind the player.
  • Ray Tracing Shadows: Generates area-aware shadows that soften naturally as they distance themselves from the occluder.

Practical Optimization

Because ray tracing is computationally expensive, we use the r.RayTracing.Reflections.SamplesPerPixel console variable to balance fidelity and performance. A lower sample count combined with the Denoiser is the industry-standard way to achieve a clean look without tanking your framerate. You can monitor the impact of these settings using the r.RayTracing.Visualize command to inspect which rays are hitting your geometry.

// Example: CVar to force high-quality ray tracing shadows for cinematic sequences
// This can be triggered via a volume or game state logic
IConsoleVariable* CVarShadows = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RayTracing.Shadows.SamplesPerPixel"));
if (CVarShadows)
{
    CVarShadows->Set(2, ECVF_SetByCommandline);
}

By offloading these intersection calculations to the GPU's dedicated RT cores, you move away from "faking" lighting approximations and transition into a physically plausible rendering environment. Remember that your material setup remains crucial; opaque surfaces will handle rays efficiently, while complex transparent materials will increase the traversal cost significantly.

Key Takeaway: Hardware-accelerated ray tracing replaces camera-dependent visual tricks with true geometric light simulation, providing physically accurate reflections and shadows that remain consistent regardless of the viewing angle.