From eaf6dc0f998a058f21ca0311f4b720bccf7b1453 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Thu, 22 Oct 2020 11:30:40 +0200 Subject: [PATCH 1/3] Make sure we clamp correctly when sampling in TAA --- .../PostProcessing/Shaders/TemporalAntialiasing.hlsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl index 3af4237d52c..9244c2ee662 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl @@ -21,19 +21,19 @@ float3 Fetch(TEXTURE2D_X(tex), float2 coords, float2 offset, float2 scale) { - float2 uv = (coords + offset * _ScreenSize.zw) * scale; + float2 uv = ClampAndScaleUVForBilinear((coords + offset * _ScreenSize.zw), scale); return SAMPLE_TEXTURE2D_X_LOD(tex, s_linear_clamp_sampler, uv, 0).xyz; } float4 Fetch4(TEXTURE2D_X(tex), float2 coords, float2 offset, float2 scale) { - float2 uv = (coords + offset * _ScreenSize.zw) * scale; + float2 uv = ClampAndScaleUVForBilinear((coords + offset * _ScreenSize.zw), scale); return SAMPLE_TEXTURE2D_X_LOD(tex, s_linear_clamp_sampler, uv, 0); } float4 Fetch4Array(Texture2DArray tex, uint slot, float2 coords, float2 offset, float2 scale) { - float2 uv = (coords + offset * _ScreenSize.zw) * scale; + float2 uv = ClampAndScaleUVForBilinear((coords + offset * _ScreenSize.zw), scale); return SAMPLE_TEXTURE2D_ARRAY_LOD(tex, s_linear_clamp_sampler, uv, slot, 0); } From 5469456f43796a6d0774e5778706fe2d3b53f9e5 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Thu, 22 Oct 2020 11:31:51 +0200 Subject: [PATCH 2/3] Changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 5f197b80443..1de2d98feab 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -22,6 +22,7 @@ The version number for this package has increased due to a version update of a r - Fixed the possibility to have a shader with a pre-refraction render queue and refraction enabled at the same time. - Fixed a migration issue with the rendering queue in ShaderGraph when upgrading to 10.x; - Fixed upside down XR occlusion mesh. +- Fixed issue with TAA causing bleeding of a view into another when multiple views are visible. ### Changed - Combined occlusion meshes into one to reduce draw calls and state changes with XR single-pass. From ad3702eecf472ea1094a9855cec238fef424f64d Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Thu, 22 Oct 2020 11:57:25 +0200 Subject: [PATCH 3/3] More safe fix. --- .../Shaders/TemporalAntialiasing.hlsl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl index 9244c2ee662..eaff2540d4d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl @@ -18,22 +18,30 @@ #define COMPARE_DEPTH(a, b) step(a, b) #endif +float2 ClampAndScaleForBilinearWithCustomScale(float2 uv, float2 scale) +{ + float2 maxCoord = 1.0f - _ScreenSize.zw; + return min(uv, maxCoord) * scale; +} float3 Fetch(TEXTURE2D_X(tex), float2 coords, float2 offset, float2 scale) { - float2 uv = ClampAndScaleUVForBilinear((coords + offset * _ScreenSize.zw), scale); + float2 uv = (coords + offset * _ScreenSize.zw); + uv = ClampAndScaleForBilinearWithCustomScale(uv, scale); return SAMPLE_TEXTURE2D_X_LOD(tex, s_linear_clamp_sampler, uv, 0).xyz; } float4 Fetch4(TEXTURE2D_X(tex), float2 coords, float2 offset, float2 scale) { - float2 uv = ClampAndScaleUVForBilinear((coords + offset * _ScreenSize.zw), scale); + float2 uv = (coords + offset * _ScreenSize.zw); + uv = ClampAndScaleForBilinearWithCustomScale(uv, scale); return SAMPLE_TEXTURE2D_X_LOD(tex, s_linear_clamp_sampler, uv, 0); } float4 Fetch4Array(Texture2DArray tex, uint slot, float2 coords, float2 offset, float2 scale) { - float2 uv = ClampAndScaleUVForBilinear((coords + offset * _ScreenSize.zw), scale); + float2 uv = (coords + offset * _ScreenSize.zw); + uv = ClampAndScaleForBilinearWithCustomScale(uv, scale); return SAMPLE_TEXTURE2D_ARRAY_LOD(tex, s_linear_clamp_sampler, uv, slot, 0); }