> For the complete documentation index, see [llms.txt](https://ipgames.gitbook.io/htrace-ao/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ipgames.gitbook.io/htrace-ao/settings-and-properties/shared-settings/pipeline-integration.md).

# Pipeline Integration

## Injection Point <mark style="color:$info;">\[URP]</mark>

Defines the point at which AO is rendered in the Universal Render Pipeline.

* **Before Opaque:** renders AO before the **GBuffer pass** (in Deferred mode) or the **Forward pass** (in Forward mode), making occlusion results available to shaders early in the pipeline. This mode is designed primarily for sampling AO in **Shader Graph** or custom shaders. If this option is selected, the occlusion output is split: one copy is sent to shaders and another is output to the frame as usual. If you don't want the latter, you can safely reduce [Intensity](/htrace-ao/settings-and-properties/shared-settings/visuals.md#intensity) to **0**, as it won't affect the copy sent to shaders.
* **Before Lighting:** injects AO as if it were URP's native SSAO, letting URP combine it correctly with the rest of the lighting. **This is the recommended default option** if you don't need to sample AO in shaders.
* **After Opaque:** overlays AO on top of the final frame late in the pipeline, once every opaque pass is finished. Can help in cases where a manually rendered object with a custom shader doesn't receive or cast occlusion correctly due to not writing depth or normals in earlier passes. This injection point sacrifices correct lighting integration — for example, it will occlude direct lighting as well. Only recommended when neither of the above options is viable.

{% hint style="warning" %}
When using the **Before Opaque** injection point, [Exclude Casting](/htrace-ao/settings-and-properties/gtao-settings/gtao-visuals.md#exclude-casting-unity-6000) / [Receiving](/htrace-ao/settings-and-properties/shared-settings/visuals.md#exclude-receiving-unity-6000) masking options are unavailable, even in Deferred / + rendering paths, because this point is executed before the GBuffer pass, during which the Rendering Layer Mask is generated. However, since this point is intended for sampling the AO buffer directly in your own shaders, it gives you more granular control over receiving AO than masks: you can sample AO only on the objects / materials / shaders where you actually need it.&#x20;
{% endhint %}

#### Sampling HTrace AO in Shader Graph

HTrace AO for URP comes with a **Sample Scene** that provides an example of AO sampling in Shader Graph. When you switch the [Injection Point](/htrace-ao/settings-and-properties/shared-settings/pipeline-integration.md#injection-point-urp) to **Before Opaque**, you will notice that the HTrace Material Ball object outputs custom red-colored AO. This object uses the **AO Material Example Graph** shader, which you can inspect to see how AO sampling is performed. For convenience, we provide our `SampleHTraceAO` custom function node, which can be included in your Shader Graphs.

{% hint style="danger" %}
Be aware that there’s a [known bug](/htrace-ao/known-issues.md#before-opaque-injection-point--deferred-path-produces-incorrect-results-urp) on Unity’s side that you may encounter if you’re running the Deferred /+ rendering path. The effect may look incorrect in this case.
{% endhint %}

{% tabs %}
{% tab title="Example of a custom AO effect" %}

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

{% tab title="AO Material Example Graph" %}

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

## Reconstruct Normals <mark style="color:$info;">\[URP]</mark>

Reconstructs normals from the depth buffer. Normals reconstructed this way are flat and represent raw polygonal geometry, without accounting for smoothing groups or normal map details. This option is useful in combination with the **After Opaque** [Injection Point](#injection-point-urp), when a custom shader or object cannot write to the normal buffer, or when the normal buffer is otherwise unavailable.

*Performance impact: small*

{% tabs %}
{% tab title="Reconstruct Normals OFF" %}

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

{% tab title="Reconstruct Normals ON" %}

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/settings-and-properties/shared-settings/pipeline-integration.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.
