Universal Render Pipeline API
HTrace AO provides two URP settings workflows. The UseVolumes field on HTraceAORendererFeature selects which API is authoritative.
Public Types
| Type | Namespace | Description |
|---|---|---|
HTraceAO | IPGames.HTraceAO.Runtime.URP | Scene component that owns a profile when the Volume workflow is disabled. |
HTraceAORendererFeature | IPGames.HTraceAO.Runtime.URP.Infrastructure | URP renderer feature that schedules HTrace passes and selects the settings workflow. |
HTraceAOVolume | IPGames.HTraceAO.Runtime.URP.Infrastructure | URP Volume override used when UseVolumes is enabled. |
HRendererURP | IPGames.HTraceAO.Runtime.URP | Provides the current URP asset and Editor-only renderer-feature utilities. |
HTraceAORendererFeature
public class HTraceAORendererFeature : ScriptableRendererFeatureOn Unity 6000 or newer, the class derives from URP's ScreenSpaceAmbientOcclusion feature so it can replace the native AO integration point.
| Member | Type | Access | Description |
|---|---|---|---|
UseVolumes | bool | Read/write | Uses HTraceAOVolume settings when enabled; uses the scene HTraceAO profile when disabled. |
IsUseVolumes | bool | Static, read-only | Last workflow state synchronized by the active renderer feature. |
Configure UseVolumes on the renderer data asset. Changing renderer-feature assets at runtime is not recommended.
Profile Workflow
Use this workflow when Use Volumes is disabled. Add IPGames.HTraceAO.Runtime.URP.HTraceAO to a scene object and assign its profile in the Inspector.
The component has no public profile setter. Once it enables, the assigned profile is available through HTraceAOSettings.ActiveProfile.
using IPGames.HTraceAO.Runtime.Data.Public;
using IPGames.HTraceAO.Runtime.Globals;
using UnityEngine;
using HTraceAOComponent = IPGames.HTraceAO.Runtime.URP.HTraceAO;
public sealed class URPAmbientOcclusionController : MonoBehaviour
{
[SerializeField] private HTraceAOComponent HTrace;
public void SetEnabled(bool Enabled)
{
HTrace.enabled = Enabled;
}
public void SetBalancedGTAO()
{
var Profile = HTraceAOSettings.ActiveProfile;
if (Profile == null)
return;
Profile.GeneralSettings.AmbientOcclusionMode = AmbientOcclusionMode.GTAO;
Profile.GeneralSettings.InjectionPoint = URPInjectionPoint.BeforeLighting;
Profile.GeneralSettings.Intensity = 1.5f;
Profile.GTAOSettings.Resolution = GTAOResolutionMode.Half;
Profile.GTAOSettings.SliceCount = 2;
Profile.GTAOSettings.StepCount = 16;
}
}When the URP component is disabled, it clears ActiveProfile if it still owns the active global profile.
Volume Workflow
Use this workflow when Use Volumes is enabled. Modify the HTraceAOVolume stored in your source VolumeProfile, not the blended object returned by VolumeManager.instance.stack.
using IPGames.HTraceAO.Runtime.Globals;
using IPGames.HTraceAO.Runtime.URP.Infrastructure;
using UnityEngine;
using UnityEngine.Rendering;
public sealed class URPHTraceVolumeController : MonoBehaviour
{
[SerializeField] private Volume Volume;
private HTraceAOVolume Settings;
private void Awake()
{
VolumeProfile Profile = Volume.profile;
if (!Profile.TryGet(out Settings))
Settings = Profile.Add<HTraceAOVolume>(true);
}
public void SetGTAO(float Intensity)
{
Settings.Enable.overrideState = true;
Settings.Enable.value = true;
Settings.AmbientOcclusionMode.overrideState = true;
Settings.AmbientOcclusionMode.value = AmbientOcclusionMode.GTAO;
Settings.Intensity.overrideState = true;
Settings.Intensity.value = Intensity;
Settings.GTAOResolution.overrideState = true;
Settings.GTAOResolution.value = GTAOResolutionMode.Half;
}
public void SetEnabled(bool Enabled)
{
Settings.Enable.overrideState = true;
Settings.Enable.value = Enabled;
}
}The renderer feature copies the blended Volume values into an internal active profile before rendering. Writes to corresponding HTraceAOSettings.ActiveProfile fields are therefore overwritten by the Volume stack.
Set overrideState for every Volume parameter your profile should control. A value with overrideState == false can be replaced by another Volume or by the parameter default.
HTraceAOVolume Member Groups
HTraceAOVolume exposes the same user-facing names as the Inspector, with mode prefixes where necessary:
| Group | Members |
|---|---|
| Activation | Enable, AmbientOcclusionMode |
| General | HBuffer, Fadeout, Intensity, DirectLightingOcclusion, InjectionPoint, ReconstructNormals |
| SSAO | DebugModeSSAO, Thickness, Radius, SSAOExcludeCasting, SSAOExcludeReceiving, SSAOExcludedIntensity |
| GTAO | Members beginning with GTAO, including GTAOResolution, GTAOWorldSpaceRadius, GTAOSliceCount, GTAOStepCount, and the denoising controls |
| RTAO | Members beginning with RTAO, including RTAORayCount, RTAOResolution, pretrace, culling, masking, and denoising controls |
Mask parameters are available in Unity versions that provide the required rendering-layer API. Refer to Runtime API for ranges and enum values.
HRendererURP
public static class HRendererURP| Member | Availability | Description |
|---|---|---|
UrpAsset | Runtime | Returns GraphicsSettings.currentRenderPipeline as a UniversalRenderPipelineAsset, or null. |
UniversalRendererData | Editor only | Returns the default UniversalRendererData. |
IsSsaoNativeEnabled() | Editor only | Checks whether a native URP SSAO feature is present. |
GetRendererFeatureByTypeName(...) | Editor only | Searches renderer data assets for a feature by type name. |
GetRendererFeature<T>(...) | Editor only | Searches renderer data assets for a feature by type. |
AddHTraceRendererFeatureToUniversalRendererData() | Editor only | Adds the HTrace feature to the default renderer data asset. |
GetAllRendererFeatures<T>() | Editor only | Returns matching features from every renderer data asset. |
GetRenderersCount() | Editor only | Returns the number of configured renderer data assets. |
Editor-only members are removed from player builds. Use them in an Editor assembly or inside #if UNITY_EDITOR.
URP-specific Limitations
TracingModeis not exposed byHTraceAOVolume; URP RTAO uses inline ray tracing.SpecularOcclusionis an HDRP-specific control.InjectionPointandReconstructNormalsexist only in URP builds.- Switching
AmbientOcclusionModecan rebuild the renderer feature's internal pass set. Change modes at a controlled point rather than repeatedly every frame.