Skip to content

Commit 55bb6ff

Browse files
Disabled specular occlusion for what we consider medium and larger scale rtao > 1.25 with a 25cm falloff interval. (#3023)
Co-authored-by: sebastienlagarde <[email protected]>
1 parent 5fecd49 commit 55bb6ff

File tree

10 files changed

+28
-9
lines changed

10 files changed

+28
-9
lines changed
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6060
- Improved robustness of volumetric sampling in path tracing (case 1295187).
6161
- Changed the clamping approach for RTR and RTGI (in both perf and quality) to improve visual quality.
6262
- Changed the warning message for ray traced area shadows (case 1303410).
63+
- Disabled specular occlusion for what we consider medium and larger scale ao > 1.25 with a 25cm falloff interval.
6364

6465
## [10.3.0] - 2020-12-01
6566

com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs.hlsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ CBUFFER_START(ShaderVariablesDebugDisplay)
6767
int _MatcapMixAlbedo;
6868
float _MatcapViewScale;
6969
int _DebugSingleShadowIndex;
70-
int _DebugProbeVolumeMode;
71-
float3 _DebugDisplayPad0;
70+
int _DebugDisplayPad0;
7271
CBUFFER_END
7372

7473

com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ internal void InitRaytracing(HDRenderPipeline renderPipeline)
242242
m_RaytracingAmbientOcclusion.Init(renderPipeline);
243243
}
244244

245+
internal float EvaluateSpecularOcclusionFlag(HDCamera hdCamera)
246+
{
247+
AmbientOcclusion ssoSettings = hdCamera.volumeStack.GetComponent<AmbientOcclusion>();
248+
bool enableRTAO = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && ssoSettings.rayTracing.value;
249+
if (enableRTAO)
250+
return m_RaytracingAmbientOcclusion.EvaluateRTSpecularOcclusionFlag(hdCamera, ssoSettings);
251+
else
252+
return 1.0f;
253+
}
254+
245255
internal bool IsActive(HDCamera camera, AmbientOcclusion settings) => camera.frameSettings.IsEnabled(FrameSettingsField.SSAO) && settings.intensity.value > 0f;
246256

247257
struct RenderAOParameters

com.unity.render-pipelines.high-definition/Runtime/Material/MaterialEvaluation.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void GetScreenSpaceAmbientOcclusionMultibounce(float2 positionSS, float NdotV, f
9898
float directAmbientOcclusion = lerp(1.0, indirectAmbientOcclusion, _AmbientOcclusionParam.w);
9999

100100
float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
101-
float indirectSpecularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(NdotV), indirectAmbientOcclusion, roughness);
101+
float indirectSpecularOcclusion = lerp(1.0, GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(NdotV), indirectAmbientOcclusion, roughness), _SpecularOcclusionBlend);
102102
float directSpecularOcclusion = lerp(1.0, indirectSpecularOcclusion, _AmbientOcclusionParam.w);
103103

104104
aoFactor.indirectSpecularOcclusion = GTAOMultiBounce(min(specularOcclusionFromData, indirectSpecularOcclusion), fresnel0);

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,11 +1039,14 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
10391039
m_ShaderVariablesGlobalCB._EnableRayTracedReflections = enableRaytracedReflections ? 1 : 0;
10401040
RecursiveRendering recursiveSettings = hdCamera.volumeStack.GetComponent<RecursiveRendering>();
10411041
m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = recursiveSettings.enable.value ? 1u : 0u;
1042+
1043+
m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = m_AmbientOcclusionSystem.EvaluateSpecularOcclusionFlag(hdCamera);
10421044
}
10431045
else
10441046
{
10451047
m_ShaderVariablesGlobalCB._EnableRayTracedReflections = 0;
10461048
m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = 0;
1049+
m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = 0.0f;
10471050
}
10481051

10491052
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingAmbientOcclusion.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public void Init(HDRenderPipeline renderPipeline)
2828
m_RTAOApplyIntensityKernel = m_PipelineRayTracingResources.aoRaytracingCS.FindKernel("RTAOApplyIntensity");
2929
}
3030

31+
public float EvaluateRTSpecularOcclusionFlag(HDCamera hdCamera, AmbientOcclusion ssoSettings)
32+
{
33+
float remappedRayLength = (Mathf.Clamp(ssoSettings.rayLength, 1.25f, 1.5f) - 1.25f) / 0.25f;
34+
return Mathf.Lerp(0.0f, 1.0f, 1.0f - remappedRayLength);
35+
}
36+
3137
static RTHandle AmbientOcclusionHistoryBufferAllocatorFunction(string viewName, int frameIndex, RTHandleSystem rtHandleSystem)
3238
{
3339
return rtHandleSystem.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16_SFloat, dimension: TextureXR.dimension,

com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ unsafe struct ShaderVariablesGlobal
268268
// Because the DepthPrepass doesn't have a DEBUG_DISPLAY variant, it is the only way to disable it for debug modes
269269
public float _GlobalTessellationFactorMultiplier;
270270

271-
public float _Pad8;
271+
public float _SpecularOcclusionBlend;
272272
public float _Pad9;
273273
}
274274
}

com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0)
151151
float4 _ProbeVolumeAmbientProbeFallbackPackedCoeffs[7];
152152
int _TransparentCameraOnlyMotionVectors;
153153
float _GlobalTessellationFactorMultiplier;
154-
float _Pad8;
154+
float _SpecularOcclusionBlend;
155155
float _Pad9;
156156
CBUFFER_END
157157

0 commit comments

Comments
 (0)