# HTrace RTAO vs. HDRP RTAO

Both algorithms share the same ray-tracing implementation, which, due to its nature, can theoretically converge to the same result (ground truth). HTrace RTAO, however, makes its primary goal to achieve this result faster with minimal visual compromises, denoise it better, and provide useful scalability features along the way.

{% hint style="warning" %}
The following comparison is performed in the HDRP Demo Scene on a laptop RTX 3060 6GB, 1920 x 1080 native.
{% endhint %}

## Equal time, better result

This first test demonstrates how HTrace AO achieves better visual results with roughly equal timings. The main visual difference comes from a more advanced spatial denoising algorithm used by HTrace. The performance impact is, of course, quite high for an ambient occlusion effect, so we can start scaling down from here.

{% tabs %}
{% tab title="HDRP RTAO (\~9.0ms)" %}

<figure><img src="/files/xsBOOkpuEwWXAy042DYS" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace RTAO (\~8.5ms) " %}

<figure><img src="/files/IJEiz1yDlJcrGCDA72NX" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HDRP Settings" %}

<figure><img src="/files/wspc6rao8BUvJbHa3sgr" alt="" width="470"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace Settings" %}

<figure><img src="/files/HTtzwvxKl4gPhnoqq4dF" alt="" width="470"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Inline Ray Tracing

HTrace [provides](https://ipgames.gitbook.io/htrace-ao/comparisons-with-unitys-ao/pages/arNur0glRG2vJnfd6CcO#alpha-cutout-hdrp-unity-2023.2) 2 forms of hardware-accelerated ray-tracing. The first we call "Native", because this is the type of ray-tracing used by HDRP itself, and the second is called [Inline](https://discussions.unity.com/t/inline-ray-tracing-support-in-2023-2/925289). The latter can be viewed as a more flexible form of ray-tracing, but with certain drawbacks: for instance, it doesn't know much about material properties in the scene. Luckily, ambient occlusion (unlike, say, global illumination) requires only one material property: alpha cutout. At the same time, true alpha-cutout evaluation is notorious for slowing down ray traversal.

Therefore, we can turn this drawback into an advantage by using **Inline Ray Tracing** without evaluating alpha cutout during traversal, handling it instead in screen space against the existing depth buffer (falling back to a fully opaque geometry representation outside the frame). This reduces ray-tracing timings dramatically when alpha-cutout geometry is in view, with minimal visual bias.

{% tabs %}
{% tab title="HDRP RTAO (\~9.0ms)" %}

<figure><img src="/files/xsBOOkpuEwWXAy042DYS" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace RTAO + Inline Ray Tracing (\~4.5ms)" %}

<figure><img src="/files/lDyTenbBYIj4aOg1apMW" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Resolution Scaling

We can also speed up AO rendering by lowering the [resolution](/htrace-ao/settings-and-properties/rtao-settings/rtao-quality.md#resolution) of the effect (which is not possible with HDRP's native RTAO). We even have a specially designed mode for our RTAO called **Adaptive Resolution**, which is similar to VRS rendering and traces at different resolutions for different areas of the frame, depending on geometric complexity.

{% tabs %}
{% tab title="HDRP RTAO (\~9.0ms)" %}

<figure><img src="/files/xsBOOkpuEwWXAy042DYS" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace RTAO + Adaptive Resolution (\~2.8ms)" %}

<figure><img src="/files/wvmlPm9wdy6x3pJSVUkW" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

To scale down further, we can use **Quarter Resolution** (formerly known as Half in V1), which increases performance by almost 2x.

{% tabs %}
{% tab title="HDRP RTAO (\~9.0ms)" %}

<figure><img src="/files/xsBOOkpuEwWXAy042DYS" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace RTAO + Quarter Resolution (\~1.5ms)" %}

<figure><img src="/files/daEcfpirZQr7ORQSoIFR" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

By using HTrace RTAO with **Inline Ray Tracing** combined with **Adaptive** or **Quarter Resolution**, we managed to reduce the performance cost from 8.5 ms to 2.8 / 1.5 ms without decreasing the [Ray Count](/htrace-ao/settings-and-properties/rtao-settings/rtao-quality.md#ray-count), which was set to 4 rays per pixel for this test and could be tweaked further for even better performance if needed.

## Spatial Denoiser and Contact Occlusion

With a growing filter radius, **HDRP RTAO** yields progressively blurrier results, with many occlusion details destroyed by such aggressive denoising. Moreover, individual spatial samples become visible, forming distinctive lines and contours around geometric features. **HTrace RTAO** provides much smoother results that preserve detailed occlusion. Furthermore, it's equipped with the [Contact Occlusion](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/spatial-denoising.md#contact-occlusion) feature, which adds another layer of small-scale occlusion that brings out even the smallest geometry details.

{% tabs %}
{% tab title="HDRP RTAO" %}

<figure><img src="/files/Gj1dDua9bO1zeNDAFv27" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace RTAO" %}

<figure><img src="/files/b17YXuVaQokNBaWN0E0u" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="HTrace RTAO + Contact Occlusion" %}

<figure><img src="/files/46NB5EBfa1eNYTEAQcrn" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Screen Space Pretrace

**HTrace RTAO** can combine ray-traced results with screen-space ray marching, which can be especially useful when an object is visible to the main camera (rasterized) but cannot be added to the Ray Tracing Acceleration Structure for any reason, making it invisible to hardware ray tracing. Occlusion from such a missing object can be regained via the [Screen Space Pretrace](/htrace-ao/settings-and-properties/rtao-settings/rtao-quality.md#screen-space-pretrace) feature. **HDRP RTAO** doesn't offer such an approach, providing a hard split between screen-space and ray-traced ambient occlusion paths.

## Temporal Rejection

**HDRP RTAO** provides binary rejection options: [Occluder Motion Rejection](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@17.5/manual/reference-ambient-occlusion.html#:~:text=Occluder%20Motion%20Rejection) and [Receiver Motion Rejection](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@17.5/manual/reference-ambient-occlusion.html#:~:text=Receiver%20Motion%20Rejection), which are simple checkboxes - either on or off. When enabled, HDRP completely discards temporal accumulation for AO cast **from moving objects onto static** ones (e.g. occlusion from a statue cast onto the floor) **and onto themselves** (e.g. the surface of a statue). This is why in this example we see essentially no temporal denoising on the moving statues or the occlusion they cast, leading to excessive and unnecessary noise.

**HTrace RTAO**, on the other hand, tracks the speed of moving objects and the direction of their movement, and is able to reject temporal history adaptively. In this example, it strongly rejects only the occlusion cast by a fast-moving statue onto the floor beneath it. The occlusion of the slowly moving statue, as well as the occlusion the statues cast onto themselves, is rejected less aggressively or not at all, because in these cases the delta between the caster and the receiver is considered small enough. This rejection behaviour can be further [fine-tuned](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#rejection-static) through the UI.

{% hint style="warning" %}
Spatial denoising is reduced to a minimum in both cases here, to better demonstrate the temporal accumulation process.
{% endhint %}

{% embed url="<https://youtu.be/k1M4EZV3v54>" %}

Overall, HTrace RTAO uses a very advanced temporal denoising pipeline that utilizes **2.5D motion vectors**, a sharp **Bicubic** [Reprojection Filter](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#reprojection-filter), and allows you to explicitly set the maximum number of accumulated frames.

## Additional Features

Here is the list of most notable features HTrace RTAO offers **that are not present** in HDRP's RTAO implementation:

* [Fadeout](/htrace-ao/settings-and-properties/shared-settings/visuals.md#fadeout)
* [Exclude Receiving](/htrace-ao/settings-and-properties/shared-settings/visuals.md#exclude-receiving)&#x20;
* [Adaptive | Half | Quarter Resolution](/htrace-ao/settings-and-properties/rtao-settings/rtao-quality.md#resolution)
* [Inline Ray Tracing](https://ipgames.gitbook.io/htrace-ao/comparisons-with-unitys-ao/pages/arNur0glRG2vJnfd6CcO#alpha-cutout-hdrp-unity-2023.2)
* [Sample Rebalancing](/htrace-ao/settings-and-properties/rtao-settings/rtao-quality.md#sample-rebalancing-adaptive-resolution)
* [Screen Space Pretrace](/htrace-ao/settings-and-properties/rtao-settings/rtao-quality.md#screen-space-pretrace)
* [Double Pass Denoising](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising.md#denoising-mode)
* [Output Dithering](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising.md#output-dithering-hdrp)
* [Sharp Temporal Reprojection](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#reprojection-filter)
* [Explicit Temporal Samplecount Control](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#sample-count)
* [Static](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#rejection-static) [| Dynamic rejection with Velocity and Direction tracking](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#rejection-dynamic)
* [Disocclusion Boost](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/temporal-denoising.md#disocclusion-boost)
* [Contact Occlusion](/htrace-ao/settings-and-properties/rtao-settings/rtao-denoising/spatial-denoising.md#contact-occlusion)

{% embed url="<https://www.patreon.com/c/htrace>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ipgames.gitbook.io/htrace-ao/comparisons-with-unitys-ao/htrace-rtao-vs.-hdrp-rtao.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
