Skip to content

Commit 202243c

Browse files
kechoEvergreen
authored andcommitted
[Jira # UUM-65289] Fix correct resolution for refractive color pyramid sampling with DRS
Lit shader passes were sampling the incorrect resolution for the color pyramid texture. When DRS goes from low to high, this would be noticeable by flickering of refractive surfaces. Example of the artifact: ![hh_flicker](https://media.github.cds.internal.unity3d.com/user/3327/files/96e08861-953b-4fe2-80cd-d3db17ef418f)
1 parent f69e87c commit 202243c

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1887,9 +1887,9 @@ IndirectLighting EvaluateBSDF_ScreenspaceRefraction(LightLoopContext lightLoopCo
18871887
float mipLevel = preLightData.transparentSSMipLevel;
18881888

18891889
// Clamp to avoid potential leaks around the edges when the dynamic resolution is set to low and the smoothness too.
1890-
float2 diffLimit = _ColorPyramidUvScaleAndLimitPrevFrame.xy - _ColorPyramidUvScaleAndLimitPrevFrame.zw;
1890+
float2 diffLimit = _ColorPyramidUvScaleAndLimitCurrentFrame.xy - _ColorPyramidUvScaleAndLimitCurrentFrame.zw;
18911891
float2 diffLimitMipAdjusted = diffLimit * pow(2.0,2.0 + ceil(abs(mipLevel)));
1892-
float2 limit = _ColorPyramidUvScaleAndLimitPrevFrame.xy - diffLimitMipAdjusted;
1892+
float2 limit = _ColorPyramidUvScaleAndLimitCurrentFrame.xy - diffLimitMipAdjusted;
18931893

18941894
samplingUV.xy = min(samplingUV.xy, limit);
18951895

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)
11731173
m_ShaderVariablesGlobalCB._VolumetricCloudsShadowOriginToggle -= new Vector4(hdCamera.camera.transform.position.x, hdCamera.camera.transform.position.y, hdCamera.camera.transform.position.z, 0);
11741174
}
11751175
m_ShaderVariablesGlobalCB._VolumetricCloudsFallBackValue = m_VolumetricCloudsShadowRegion.fallbackValue;
1176+
m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.currentViewportSize, hdCamera.historyRTHandleProperties.currentViewportSize);
11761177
m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitPrevFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.previousViewportSize, hdCamera.historyRTHandleProperties.previousRenderTargetSize);
11771178

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

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ static class HDShaderIDs
470470
public static readonly int _RenderingLayersTexture = Shader.PropertyToID("_RenderingLayersTexture");
471471
public static readonly int _DistortionTexture = Shader.PropertyToID("_DistortionTexture");
472472
public static readonly int _ColorPyramidTexture = Shader.PropertyToID("_ColorPyramidTexture");
473-
public static readonly int _ColorPyramidUvScaleAndLimitPrevFrame = Shader.PropertyToID("_ColorPyramidUvScaleAndLimitPrevFrame");
474473
public static readonly int _RoughDistortion = Shader.PropertyToID("_RoughDistortion");
475474

476475
public static readonly int _DebugColorPickerTexture = Shader.PropertyToID("_DebugColorPickerTexture");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ unsafe struct ShaderVariablesGlobal
301301
public uint _EnableComputeThickness;
302302
public float _VolumetricCloudsFallBackValue;
303303
public Vector4 _VolumetricCloudsShadowOriginToggle;
304-
304+
public Vector4 _ColorPyramidUvScaleAndLimitCurrentFrame;
305305
public Vector4 _ColorPyramidUvScaleAndLimitPrevFrame;
306306
}
307307
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0)
179179
uint _EnableComputeThickness;
180180
float _VolumetricCloudsFallBackValue;
181181
float4 _VolumetricCloudsShadowOriginToggle;
182+
float4 _ColorPyramidUvScaleAndLimitCurrentFrame;
182183
float4 _ColorPyramidUvScaleAndLimitPrevFrame;
183184
CBUFFER_END
184185

0 commit comments

Comments
 (0)