diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index ed3f4116836..7e646dfa567 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -151,6 +151,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the camera controller in the template with the old input system (case 1326816). - Fixed broken Lanczos filter artifacts on ps4, caused by a very aggressive epsilon (case 1328904) - Fixed global Settings ignore the path set via Fix All in HDRP wizard (case 1327978) +- Fixed GBuffer clear option in FrameSettings not working ### Changed - Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index 7bb18c0b32d..d882c5f50dd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -56,10 +56,9 @@ void CleanupPrepass() CoreUtils.Destroy(m_DownsampleDepthMaterial); } - bool NeedClearGBuffer() + bool NeedClearGBuffer(HDCamera hdCamera) { - // TODO: Add an option to force clear - return m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled(); + return m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() || hdCamera.frameSettings.IsEnabled(FrameSettingsField.ClearGBuffers); } HDUtils.PackedMipChainInfo GetDepthBufferMipChainInfo() @@ -118,7 +117,7 @@ TextureHandle CreateDepthBuffer(RenderGraph renderGraph, bool clear, bool msaa) return renderGraph.CreateTexture(depthDesc); } - TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa) + TextureHandle CreateNormalBuffer(RenderGraph renderGraph, HDCamera hdCamera, bool msaa) { #if UNITY_2020_2_OR_NEWER FastMemoryDesc fastMemDesc; @@ -129,7 +128,7 @@ TextureHandle CreateNormalBuffer(RenderGraph renderGraph, bool msaa) TextureDesc normalDesc = new TextureDesc(Vector2.one, true, true) { - colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer" + colorFormat = GraphicsFormat.R8G8B8A8_UNorm, clearBuffer = NeedClearGBuffer(hdCamera), clearColor = Color.black, bindTextureMS = msaa, enableMSAA = msaa, enableRandomWrite = !msaa, name = msaa ? "NormalBufferMSAA" : "NormalBuffer" #if UNITY_2020_2_OR_NEWER , fastMemoryDesc = fastMemDesc #endif @@ -402,7 +401,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h { decalBuffer = renderGraph.defaultResources.blackTextureXR; output.depthAsColor = CreateDepthAsColorBuffer(renderGraph); - output.normalBuffer = CreateNormalBuffer(renderGraph, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)); + output.normalBuffer = CreateNormalBuffer(renderGraph, hdCamera, hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)); return false; } @@ -460,7 +459,7 @@ bool RenderDepthPrepass(RenderGraph renderGraph, CullingResults cull, HDCamera h int mrtIndex = 0; if (msaa) output.depthAsColor = builder.UseColorBuffer(CreateDepthAsColorBuffer(renderGraph), mrtIndex++); - output.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, msaa), mrtIndex++); + output.normalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, hdCamera, msaa), mrtIndex++); if (decalLayersEnabled) decalBuffer = builder.UseColorBuffer(decalBuffer, mrtIndex++); @@ -564,7 +563,7 @@ struct GBufferOutput void SetupGBufferTargets(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle sssBuffer, TextureHandle vtFeedbackBuffer, ref PrepassOutput prepassOutput, FrameSettings frameSettings, RenderGraphBuilder builder) { - bool clearGBuffer = NeedClearGBuffer(); + bool clearGBuffer = NeedClearGBuffer(hdCamera); bool lightLayers = frameSettings.IsEnabled(FrameSettingsField.LightLayers); bool shadowMasks = frameSettings.IsEnabled(FrameSettingsField.Shadowmask); @@ -701,7 +700,7 @@ void ResolvePrepassBuffers(RenderGraph renderGraph, HDCamera hdCamera, ref Prepa output.resolvedDepthBuffer = builder.UseDepthBuffer(CreateDepthBuffer(renderGraph, true, false), DepthAccess.Write); output.depthValuesMSAA = builder.UseColorBuffer(depthValuesBuffer, 0); - output.resolvedNormalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, false), 1); + output.resolvedNormalBuffer = builder.UseColorBuffer(CreateNormalBuffer(renderGraph, hdCamera, false), 1); if (passData.needMotionVectors) output.resolvedMotionVectorsBuffer = builder.UseColorBuffer(CreateMotionVectorBuffer(renderGraph, false, false), 2); else diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 042dc4adbd4..8f712ed9129 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -76,7 +76,7 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest, LightingBuffers lightingBuffers = new LightingBuffers(); lightingBuffers.diffuseLightingBuffer = CreateDiffuseLightingBuffer(m_RenderGraph, msaa); - lightingBuffers.sssBuffer = CreateSSSBuffer(m_RenderGraph, msaa); + lightingBuffers.sssBuffer = CreateSSSBuffer(m_RenderGraph, hdCamera, msaa); var prepassOutput = RenderPrepass(m_RenderGraph, colorBuffer, lightingBuffers.sssBuffer, vtFeedbackBuffer, cullingResults, customPassCullingResults, hdCamera, aovRequest, aovBuffers); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs index 3fc0eea86ac..6436bd94752 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs @@ -162,7 +162,7 @@ static bool NeedTemporarySubsurfaceBuffer() // Albedo + SSS Profile and mask / Specular occlusion (when no SSS) // This will be used during GBuffer and/or forward passes. - TextureHandle CreateSSSBuffer(RenderGraph renderGraph, bool msaa) + TextureHandle CreateSSSBuffer(RenderGraph renderGraph, HDCamera hdCamera, bool msaa) { #if UNITY_2020_2_OR_NEWER FastMemoryDesc fastMemDesc; @@ -177,7 +177,7 @@ TextureHandle CreateSSSBuffer(RenderGraph renderGraph, bool msaa) enableRandomWrite = !msaa, bindTextureMS = msaa, enableMSAA = msaa, - clearBuffer = NeedClearGBuffer(), + clearBuffer = NeedClearGBuffer(hdCamera), clearColor = Color.clear, name = msaa ? "SSSBufferMSAA" : "SSSBuffer" #if UNITY_2020_2_OR_NEWER