High Definition Render Pipeline API
HDRP uses the IPGames.HTraceAO.Runtime.HDRP.HTraceAO scene component and a HTraceAOProfile. It does not expose HTrace settings through the Unity Volume stack.
Public Type
namespace IPGames.HTraceAO.Runtime.HDRP
{
public class HTraceAO : MonoBehaviour
}The profile field is serialized but private. Assign it in the Inspector. The enabled component registers it as HTraceAOSettings.ActiveProfile.
In a player build, adding an unconfigured HDRP HTraceAO component at runtime does not create a missing profile. Author the component and its profile in the scene or prefab before building.
Changing Settings
using IPGames.HTraceAO.Runtime.Data.Public;
using IPGames.HTraceAO.Runtime.Globals;
using UnityEngine;
using HTraceAOComponent = IPGames.HTraceAO.Runtime.HDRP.HTraceAO;
public sealed class HDRPAmbientOcclusionController : MonoBehaviour
{
[SerializeField] private HTraceAOComponent HTrace;
public void SetEnabled(bool Enabled)
{
HTrace.enabled = Enabled;
}
public void SetRTAO()
{
var Profile = HTraceAOSettings.ActiveProfile;
if (Profile == null)
return;
Profile.GeneralSettings.AmbientOcclusionMode = AmbientOcclusionMode.RTAO;
Profile.GeneralSettings.Intensity = 1.5f;
Profile.RTAOSettings.TracingMode = TracingMode.InlineRayTracing;
Profile.RTAOSettings.RayCount = 2;
Profile.RTAOSettings.Resolution = ResolutionMode.Adaptive;
Profile.RTAOSettings.Denoising = RTAODenoisingMode.DoublePass;
}
}Disabling the component cleans up the HTrace custom passes and disables its override keyword. Do not use a non-null ActiveProfile as the only test for HDRP effect activity, because the global profile reference is not cleared by the HDRP component on disable. Check the component's isActiveAndEnabled state when activity matters.
HDRP Resource Patching
HTrace integrates its output into HDRP's native ambient-occlusion texture. To do this, it creates HTrace-compatible copies of HDRP's GTAO and RTAO shader resources and assigns those copies to HDRP's runtime resources.
The patched shaders contain two paths:
- with the HTrace override enabled, HDRP's native AO tracing stage is skipped and the HTrace AO buffer is written into HDRP's AO output;
- with the HTrace override disabled, the original HDRP shader logic continues to run.
This has several API consequences:
- While HTrace is active, native HDRP GTAO/RTAO tracing and denoising controls do not configure HTrace. Change
HTraceAOSettings.ActiveProfileinstead. - HTrace internally owns and updates a hidden HDRP
ScreenSpaceAmbientOcclusionoverride used for lighting integration. Direct edits to that generated override can be replaced on the next HTrace update. DirectLightOcclusion, andSpecularOcclusionin native RTAO mode, are synchronized from the HTrace profile.- Do not replace HDRP AO shader resources from gameplay code. That can remove the HTrace bridge or be replaced when HTrace patches the active HDRP resources again.
- Pipeline package upgrades can change the HDRP source shaders. Open the project in the Editor and let HTrace regenerate compatible resource copies before producing a build.
Patching is automatic when the HDRP HTrace component enables in the Editor. The patch implementation is infrastructure, not a stable gameplay API.
Batch-mode Builds
Automatic patching normally runs when the HDRP HTrace component enables in the Unity Editor. This does not happen when HTrace AO is added or updated while Unity is closed and the project is then built immediately by a fresh non-interactive Unity process. A common example is a CI workflow that imports the asset and starts a -batchmode build without first opening the project in the Editor.
In this workflow, run a separate batch-mode preparation step before the build:
IPGames.HTraceAO.Runtime.PipelelinesConfigurator
.HTraceSetupBuildBatchmode
.ApplyRuntimeResources();For example, invoke Unity with this method:
Unity -batchmode -projectPath <ProjectPath> -executeMethod IPGames.HTraceAO.Runtime.PipelelinesConfigurator.HTraceSetupBuildBatchmode.ApplyRuntimeResourcesThe method performs work only when Application.isBatchMode is true. It prepares always-included shaders, applies the HDRP resource patch, saves assets, refreshes synchronously, and exits the Editor with a success or failure code. Because it exits Unity after preparation, run the actual player build in a second batch-mode invocation after this step succeeds.
This extra step is unnecessary when the project has already been opened normally after importing or updating HTrace AO and automatic patching has completed. Do not call the method from gameplay code or from an interactive Editor session.
HDRP-specific Settings
| Member | Description |
|---|---|
GeneralSettings.OutputDithering | Dithers the HTrace value written to HDRP's 8-bit AO output. |
GeneralSettings.OutputDitheringAnimate | Animates the output dithering pattern. |
GeneralSettings.DirectLightOcclusion | Synchronizes HDRP's direct-lighting AO strength. |
RTAOSettings.TracingMode | Chooses native HDRP ray tracing or HTrace inline ray tracing on supported versions. |
RTAOSettings.SpecularOcclusion | Synchronizes HDRP's native specular-occlusion strength in RTAO mode. |
GeneralSettings.InjectionPoint and GeneralSettings.ReconstructNormals are not available in HDRP.
Native and Inline RTAO
TracingMode.NativeRayTracing uses HDRP's native ray-tracing scene and material evaluation. Settings that manage HTrace's own RTAS, such as HTrace culling and the RTAS mismatch debug view, are not applicable in the same way.
TracingMode.InlineRayTracing uses HTrace's RTAS path and enables HTrace-specific culling, screen-space alpha-cutout handling, and the hardware ray-tracing scene debug view.
Before changing modes, verify that the current Unity version, graphics API, HDRP asset, and hardware support the selected ray-tracing path.