Files
2026-03-03 00:39:30 +05:00

2.7 KiB
Raw Blame History

Get started with ray tracing

The UnifiedRayTracing API enables you to write ray tracing code that executes on a wide range of GPUs. Unlike the RayTracingAccelerationStructure API, its key advantage is that it is able to operate without requiring hardware ray tracing support. It achieves this by offering multiple backends that can be dynamically selected based on the GPUs capabilities.

Backends

The following backends are available:

  • Hardware: Requires a GPU that supports hardware-accelerated ray tracing. This backend uses the RayTracingAccelerationStructure API.
  • Compute : Software implementation of ray tracing that works only on GPUs that support compute shaders.

By abstracting these different implementations behind a unified interface, the API allows you to write your ray tracing code once, and have it automatically adapt to the appropriate backend.

Main concepts

The API entry point is the RayTracingContext which is initialized for a specific backend.

The RayTracingContext enables you to create the 2 essential objects you need to perform ray tracing:

  • an acceleration structure (IRayTracingAccelStruct) which represents the geometry to trace rays against.
  • a shader (IRayTracingShader) which contains your ray tracing code that will run on the GPU.

RayTracingContext class features

For more information, refer to Using the API workflow.

Limitations

In order to accomodate both hardware-accelerated and non-accelerated GPUs, the API is more constrained than Unity's RayTracingAccelerationStructure API.

  • The API doesn't support any automatic scene updates. You must explicitly call IRayTracingAccelStruct.AddInstance or IRayTracingAccelStruct.RemoveInstance to update the acceleration structure.
  • The API supports only ray tracing with mesh geometries.
  • Once a hit is found, the TraceRay function returns immediately with the hit information. You need to write the shading code in the ray generation shader (.urtshader).