From 8bc8f9dad3d6bfcc87ffef3f3d36a24b19edfced Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 2 Apr 2021 21:19:01 +0200 Subject: [PATCH] [HDRP] Merge Hd/bugfix #4065 --- .../CHANGELOG.md | 4 ++++ .../Runtime/Material/StackLit/StackLit.hlsl | 2 +- .../PostProcessing/Shaders/FinalPass.shader | 2 +- .../Runtime/RenderPipeline/Utility/HDUtils.cs | 18 ++++++++++++------ .../Runtime/Utilities/SceneObjectIDMap.cs | 5 +++++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index a9bda8cab28..76207a6c574 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -183,6 +183,10 @@ The version number for this package has increased due to a version update of a r - Fixed Warnings about "SceneIdMap" missing script in eye material sample scene - Fixed wizard checking FrameSettings not in HDRP Default Settings - Fixed error when opening the default composition graph in the Graphics Compositor (case 1318933). +- Fixed issue were the final image is inverted in the Y axis. Occurred only on final Player (non-dev for any platform) that use Dynamic Resolution Scaling with Contrast Adaptive Sharpening filter. +- Fixed a bug with Reflection Probe baking would result in an incorrect baking reusing other's Reflection Probe baking +- Fixed volumetric fog being visually chopped or missing when using hardware Dynamic Resolution Scaling. +- Fixed generation of the packed depth pyramid when hardware Dynamic Resolution Scaling is enabled. ### Changed - Now reflection probes cannot have SSAO, SSGI, SSR, ray tracing effects or volumetric reprojection. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl index 886dbf82aa9..1e453cb6f6d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl @@ -4222,7 +4222,7 @@ IndirectLighting EvaluateBSDF_ScreenSpaceReflection(PositionInputs posInput, } lighting.specularReflected = ssrLighting.rgb * lerp(reflectanceFactorB, reflectanceFactorC, bsdfData.coatMask); - reflectionHierarchyWeight = lerp(ssrLighting.a, ssrLighting.a * reflectanceFactorC, bsdfData.coatMask); + reflectionHierarchyWeight = lerp(ssrLighting.a, ssrLighting.a * reflectanceFactorC.x, bsdfData.coatMask); } else { diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader index ffe96dd0abd..8045695db59 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader @@ -93,7 +93,7 @@ Shader "Hidden/HDRP/FinalPass" #if defined(BILINEAR) || defined(CATMULL_ROM_4) || defined(LANCZOS) CTYPE outColor = UpscaledResult(positionNDC.xy); #elif defined(CONTRASTADAPTIVESHARPEN) - CTYPE outColor = LOAD_TEXTURE2D_X(_InputTexture, round(input.texcoord * _ViewPortSize.xy)).CTYPE_SWIZZLE; + CTYPE outColor = LOAD_TEXTURE2D_X(_InputTexture, ((input.texcoord.xy * _UVTransform.xy) + _UVTransform.zw) * _ViewPortSize.xy).CTYPE_SWIZZLE; #else CTYPE outColor = LOAD_TEXTURE2D_X(_InputTexture, positionSS).CTYPE_SWIZZLE; #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index aceca47c6d0..238de6db371 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -611,6 +611,7 @@ internal static void RestoreRenderPipelineAsset(bool wasUnsetFromQuality, Render internal struct PackedMipChainInfo { public Vector2Int textureSize; + public Vector2Int hardwareTextureSize; public int mipLevelCount; public Vector2Int[] mipLevelSizes; public Vector2Int[] mipLevelOffsets; @@ -633,12 +634,15 @@ public void ComputePackedMipChainInfo(Vector2Int viewportSize) if (viewportSize == mipLevelSizes[0]) return; - textureSize = viewportSize; - mipLevelSizes[0] = viewportSize; + bool isHardwareDrsOn = DynamicResolutionHandler.instance.HardwareDynamicResIsEnabled(); + hardwareTextureSize = isHardwareDrsOn ? DynamicResolutionHandler.instance.ApplyScalesOnSize(viewportSize) : viewportSize; + Vector2 textureScale = isHardwareDrsOn ? new Vector2((float)viewportSize.x / (float)hardwareTextureSize.x, (float)viewportSize.y / (float)hardwareTextureSize.y) : new Vector2(1.0f, 1.0f); + + mipLevelSizes[0] = hardwareTextureSize; mipLevelOffsets[0] = Vector2Int.zero; int mipLevel = 0; - Vector2Int mipSize = viewportSize; + Vector2Int mipSize = hardwareTextureSize; do { @@ -668,10 +672,12 @@ public void ComputePackedMipChainInfo(Vector2Int viewportSize) mipLevelOffsets[mipLevel] = mipBegin; - textureSize.x = Math.Max(textureSize.x, mipBegin.x + mipSize.x); - textureSize.y = Math.Max(textureSize.y, mipBegin.y + mipSize.y); + hardwareTextureSize.x = Math.Max(hardwareTextureSize.x, mipBegin.x + mipSize.x); + hardwareTextureSize.y = Math.Max(hardwareTextureSize.y, mipBegin.y + mipSize.y); + } + while ((mipSize.x > 1) || (mipSize.y > 1)); - } while ((mipSize.x > 1) || (mipSize.y > 1)); + textureSize = new Vector2Int((int)((float)hardwareTextureSize.x * textureScale.x), (int)((float)hardwareTextureSize.y * textureScale.y)); mipLevelCount = mipLevel + 1; m_OffsetBufferWillNeedUpdate = true; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/SceneObjectIDMap.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/SceneObjectIDMap.cs index 1132c6b5464..11393da6fa4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/SceneObjectIDMap.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/SceneObjectIDMap.cs @@ -260,6 +260,11 @@ int Insert(GameObject gameObject, TCategory category) m_IndexByGameObject.Add(gameObject, index); m_Entries.Insert(index, entry); + for (int i = index + 1; i < m_Entries.Count; ++i) + { + // Upon insertion, all index by game object entries after the insertion point need their index updated. + m_IndexByGameObject[m_Entries[i].gameObject] = i; + } return m_Entries[index].id; }