RTAO (Ray Traced Ambient Occlusion)

By "Equation (11.8)" of Real-Time Rendering Fourth Edition, the ambient occlusion can be calculated as k A ( p ) = H 2 ( n ) V ( p , ω i ) 1 π ( cos θ i ) + d ω i \displaystyle \operatorname{k_A}(\overrightarrow{p}) = \int_{\operatorname{H^2}(\overrightarrow{n})} \operatorname{V}(\overrightarrow{p}, \overrightarrow{\omega_i}) \frac{1}{\pi} (\cos \theta_i)^+ \, d \overrightarrow{\omega_i} where V ( p , ω i ) \displaystyle \operatorname{V} (\overrightarrow{p}, \overrightarrow{\omega_i}) is the visibility function and 1 π ( cos θ i ) + \displaystyle \frac{1}{\pi} (\cos \theta_i)^+ is the normalized clamped cosine.

1. Monte Carlo Integration

By AOIntegrator::Li in PBRT-V3 and AOIntegrator::Li in PBRT-V4, the Monte Carlo method can be used to integrate the ambient occlusion.

1-1. PDF

Since H 2 ( n ) 1 π ( cos θ i ) + d ω i = 1 \displaystyle \int_{\operatorname{H^2}(\overrightarrow{n})} \frac{1}{\pi} (\cos \theta_i)^+ \, d \overrightarrow{\omega_i} = 1 , the normalized clamped cosine 1 π ( cos θ i ) + \displaystyle \frac{1}{\pi} (\cos \theta_i)^+ can be used as the PDF.

1-2. Estimator

By "Equation (13.3)" of PBR Book V3 and "Equation (2.7)" of PBR Book V4, we have the Monte Carlo estimator k A ( p ) = H 2 ( n ) V ( p , ω i ) 1 π ( cos θ i ) + d ω i = 1 N V ( p , ω i ) 1 π ( cos θ i ) + 1 π ( cos θ i ) + = 1 N V ( p , ω i ) \displaystyle \operatorname{k_A}(\overrightarrow{p}) = \int_{\operatorname{H^2}(\overrightarrow{n})} \operatorname{V}(\overrightarrow{p}, \overrightarrow{\omega_i}) \frac{1}{\pi} (\cos \theta_i)^+ \, d \overrightarrow{\omega_i} = \sum \frac{1}{N} \frac{\operatorname{V}(\overrightarrow{p}, \overrightarrow{\omega_i}) \frac{1}{\pi} (\cos \theta_i)^+}{\frac{1}{\pi} (\cos \theta_i)^+} = \sum \frac{1}{N} \operatorname{V}(\overrightarrow{p}, \overrightarrow{\omega_i}) .

1-3. Sampling Normalized Clamped Cosine

By "13.6.3 Cosine-Weighted Hemisphere Sampling" of PBR Book V3 and "A.5.3 Cosine-Weighted Hemisphere Sampling" of PBR Book V4, we can efficiently sample the normalized clamped cosine.

The normalized clamped cosine sampling is calculated by CosineSampleHemisphere in UE4 and SampleHemisphereCosine in Unity3D.

1-4. Low Discrepancy Sequence

By "20.3 Quasirandom Low-Discrepancy Sequences" of [Colbert 2007], "13.8.2 Quasi Monte Carlo" of PBR Book V3 and "8.2.2 Low Discrepancy and Quasi Monte Carlo" of PBR Book V4, the low discrepancy sequence is the better alternative than pseudo random sequence to generate the ξ 1 \displaystyle \xi_1 and ξ 2 \displaystyle \xi_2 .

By "7.4.1 Hammersley and Halton Sequences" of PBR Book V3 and "8.6.1 Hammersley and Halton Points" of PBR Book V4, the Hammersley sequence is a typical low-discrepancy sequence.

The Hammersley sequence is calculated by Hammersley in UE4 and Hammersley2d in Unity3D.

2. Ray Tracing

The Ray Tracing APIs such as DXR (DirectX Raytracing) and Vulkan Ray Tracing can be used to calculate the visibility function.

2-1. Max Distance

By "11.3.2 Visibility and Obscurance" of Real-Time Rendering Fourth Edition, the visibility function V ( p , ω i ) \displaystyle \operatorname{V} (\overrightarrow{p}, \overrightarrow{\omega_i}) is actually the distance mapping function. The value of the visibility function is 1 instead of 0, when closest intersection distance is greater than a specified max distance.

2-2. Self Intersection

By [Wachter 2019], "3.9.5 Robust Spawned Ray Origins" of PBR Book V3 and "6.8.6 Robust Spawned Ray Origins" of PBR Book V4, we should offset the ray origin to avoid self intersection.

References

[Colbert 2007] Mark Colbert, Jaroslav Krivanek. "GPU-Based Importance Sampling." GPU Gems 3.
[Wachter 2019] Carsten Wachter, Nikolaus Binder. "A Fast and Robust Method for Avoiding Self-Intersection." Ray Tracing Gems.