Skip to content

Commit

Permalink
Disabled specular occlusion for what we consider medium and larger sc…
Browse files Browse the repository at this point in the history
…ale rtao > 1.25 with a 25cm falloff interval. (#3023)

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
  • Loading branch information
anisunity and sebastienlagarde committed Jan 12, 2021
1 parent 5fecd49 commit 55bb6ff
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 9 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Expand Up @@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Improved robustness of volumetric sampling in path tracing (case 1295187).
- Changed the clamping approach for RTR and RTGI (in both perf and quality) to improve visual quality.
- Changed the warning message for ray traced area shadows (case 1303410).
- Disabled specular occlusion for what we consider medium and larger scale ao > 1.25 with a 25cm falloff interval.

## [10.3.0] - 2020-12-01

Expand Down
Expand Up @@ -67,8 +67,7 @@ CBUFFER_START(ShaderVariablesDebugDisplay)
int _MatcapMixAlbedo;
float _MatcapViewScale;
int _DebugSingleShadowIndex;
int _DebugProbeVolumeMode;
float3 _DebugDisplayPad0;
int _DebugDisplayPad0;
CBUFFER_END


Expand Down
Expand Up @@ -242,6 +242,16 @@ internal void InitRaytracing(HDRenderPipeline renderPipeline)
m_RaytracingAmbientOcclusion.Init(renderPipeline);
}

internal float EvaluateSpecularOcclusionFlag(HDCamera hdCamera)
{
AmbientOcclusion ssoSettings = hdCamera.volumeStack.GetComponent<AmbientOcclusion>();
bool enableRTAO = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && ssoSettings.rayTracing.value;
if (enableRTAO)
return m_RaytracingAmbientOcclusion.EvaluateRTSpecularOcclusionFlag(hdCamera, ssoSettings);
else
return 1.0f;
}

internal bool IsActive(HDCamera camera, AmbientOcclusion settings) => camera.frameSettings.IsEnabled(FrameSettingsField.SSAO) && settings.intensity.value > 0f;

struct RenderAOParameters
Expand Down
Expand Up @@ -98,7 +98,7 @@ void GetScreenSpaceAmbientOcclusionMultibounce(float2 positionSS, float NdotV, f
float directAmbientOcclusion = lerp(1.0, indirectAmbientOcclusion, _AmbientOcclusionParam.w);

float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
float indirectSpecularOcclusion = GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(NdotV), indirectAmbientOcclusion, roughness);
float indirectSpecularOcclusion = lerp(1.0, GetSpecularOcclusionFromAmbientOcclusion(ClampNdotV(NdotV), indirectAmbientOcclusion, roughness), _SpecularOcclusionBlend);
float directSpecularOcclusion = lerp(1.0, indirectSpecularOcclusion, _AmbientOcclusionParam.w);

aoFactor.indirectSpecularOcclusion = GTAOMultiBounce(min(specularOcclusionFromData, indirectSpecularOcclusion), fresnel0);
Expand Down
Expand Up @@ -1039,11 +1039,14 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
m_ShaderVariablesGlobalCB._EnableRayTracedReflections = enableRaytracedReflections ? 1 : 0;
RecursiveRendering recursiveSettings = hdCamera.volumeStack.GetComponent<RecursiveRendering>();
m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = recursiveSettings.enable.value ? 1u : 0u;

m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = m_AmbientOcclusionSystem.EvaluateSpecularOcclusionFlag(hdCamera);
}
else
{
m_ShaderVariablesGlobalCB._EnableRayTracedReflections = 0;
m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = 0;
m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = 0.0f;
}

ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);
Expand Down
Expand Up @@ -28,6 +28,12 @@ public void Init(HDRenderPipeline renderPipeline)
m_RTAOApplyIntensityKernel = m_PipelineRayTracingResources.aoRaytracingCS.FindKernel("RTAOApplyIntensity");
}

public float EvaluateRTSpecularOcclusionFlag(HDCamera hdCamera, AmbientOcclusion ssoSettings)
{
float remappedRayLength = (Mathf.Clamp(ssoSettings.rayLength, 1.25f, 1.5f) - 1.25f) / 0.25f;
return Mathf.Lerp(0.0f, 1.0f, 1.0f - remappedRayLength);
}

static RTHandle AmbientOcclusionHistoryBufferAllocatorFunction(string viewName, int frameIndex, RTHandleSystem rtHandleSystem)
{
return rtHandleSystem.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16_SFloat, dimension: TextureXR.dimension,
Expand Down
Expand Up @@ -268,7 +268,7 @@ unsafe struct ShaderVariablesGlobal
// Because the DepthPrepass doesn't have a DEBUG_DISPLAY variant, it is the only way to disable it for debug modes
public float _GlobalTessellationFactorMultiplier;

public float _Pad8;
public float _SpecularOcclusionBlend;
public float _Pad9;
}
}
Expand Up @@ -151,7 +151,7 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0)
float4 _ProbeVolumeAmbientProbeFallbackPackedCoeffs[7];
int _TransparentCameraOnlyMotionVectors;
float _GlobalTessellationFactorMultiplier;
float _Pad8;
float _SpecularOcclusionBlend;
float _Pad9;
CBUFFER_END

Expand Down

0 comments on commit 55bb6ff

Please sign in to comment.