SSAO vs Ray-Traced Ambient Occlusion in DirectX
Ambient occlusion is a rendering technique used to calculate how exposed each point in a scene is to ambient lighting, producing realistic contact shadows in crevices and corners. In modern graphics programming with DirectX, developers typically choose between Screen Space Ambient Occlusion (SSAO), a performance-friendly screen-space approximation, and Ray-Traced Ambient Occlusion (RTAO), a physically accurate method powered by DirectX Raytracing (DXR). This article breaks down the fundamental differences between SSAO and RTAO in DirectX, focusing on their rendering methodologies, visual accuracy, performance costs, and implementation pipelines.
Rendering Methodology
The primary difference between SSAO and RTAO lies in the data they use to compute occlusion:
- SSAO (Screen Space Ambient Occlusion): SSAO operates as a post-processing pass using standard rasterization pipelines in DirectX 11 or DirectX 12. It relies exclusively on the 2D depth and normal buffers (G-Buffer) visible to the camera. The shader samples points in a sphere or hemisphere around each pixel in screen space to estimate how much geometry blocks the surrounding light.
- RTAO (Ray-Traced Ambient Occlusion): RTAO utilizes the DirectX Raytracing (DXR) API to query full 3D world geometry rather than screen-space pixels. A ray generation shader shoots multiple rays out into a hemisphere aligned with the surface normal. These rays traverse a Bounding Volume Hierarchy (BVH) containing the actual scene geometry to check for true physical intersections.
Visual Accuracy and Artifacts
Because of their differing technical approaches, the visual outputs vary dramatically:
- Off-Screen Geometry: SSAO cannot account for objects outside the camera's field of view or behind other foreground elements. If an occluding object moves off-screen, its shadow abruptly disappears. RTAO samples the complete scene representation in memory, meaning off-screen objects cast accurate ambient shadows regardless of camera framing.
- Artifacts and Haloing: SSAO often suffers from white or dark "halos" around edges due to depth discontinuities and imprecise screen-space thickness assumptions. RTAO eliminates haloing entirely, providing soft, natural contact shadows that transition smoothly across geometric boundaries.
- Distance and Scale: SSAO uses heuristic radius settings that can over-darken or under-darken areas depending on the camera's distance to the object. RTAO natively respects world-space units, ensuring consistent and physically grounded shadows across near and distant geometry.
Performance and Hardware Requirements
The fidelity of RTAO comes with a substantial computational trade-off compared to SSAO:
- SSAO: Highly efficient and computationally predictable. It runs quickly on modern pixel or compute shaders, consuming a fraction of a millisecond of GPU frame time. It is compatible with virtually all DirectX 11- and DirectX 12-capable hardware, making it the standard choice for lower-end configurations and competitive high-framerate titles.
- RTAO: Extremely resource-intensive. Tracing multiple rays per pixel requires dedicated ray-tracing hardware (such as RT cores) to achieve playable frame rates. Because casting dozens of rays per pixel is prohibitive, RTAO implementations trace low ray counts (often 1 ray per pixel or less) and rely heavily on spatial and temporal denoising filters to eliminate noise, adding further algorithmic complexity and memory overhead.
DirectX Implementation Pipeline
Implementing each technique in DirectX requires entirely different architectural considerations:
- SSAO: Requires only standard DirectX rendering pipelines. The engine renders the depth and normal buffers into textures, executes a full-screen compute or pixel shader pass containing the sampling kernel, and applies a simple bilateral blur to smooth out sampling noise before blending the result into the lighting pass.
- RTAO: Requires DirectX 12 with DXR support (Tier 1.0 or 1.1). Developers must build and update two-level acceleration structures (Top-Level and Bottom-Level Acceleration Structures: TLAS and BLAS) in GPU memory to represent scene geometry. The pipeline requires configuring State Objects (RTPSOs), Ray Generation Shaders, Miss Shaders, and an integrated temporal denoiser to reconstruct clean occlusion maps before final composition.