From d2d251a24b30be3736a4ba7571c22d04a16a84d2 Mon Sep 17 00:00:00 2001 From: Anis Benyoub Date: Thu, 17 Dec 2020 11:29:06 +0100 Subject: [PATCH 1/2] Fixed the planar depth texture not being properly created and rendered to (case 1299617). --- .../CHANGELOG.md | 1 + .../HDRenderPipeline.RenderGraph.cs | 13 ++++++++----- .../Runtime/Utilities/HDRenderUtilities.cs | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index e351306150e..108a5c1cc45 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed computation of geometric normal in path tracing (case 1293029). - Fixed issues with path-traced volumetric scattering (cases 1295222, 1295234). - Fixed the default background color for previews to use the original color. +- Fixed the planar depth texture not being properly created and rendered to (case 1299617). ### Changed - Removed the material pass probe volumes evaluation mode. 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 960f5de647c..8afed08a12f 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 @@ -293,17 +293,20 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest, for (int viewIndex = 0; viewIndex < hdCamera.viewCount; ++viewIndex) { BlitFinalCameraTexture(m_RenderGraph, hdCamera, postProcessDest, backBuffer, viewIndex); - - if (target.targetDepth != null) - { - BlitFinalCameraTexture(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, m_RenderGraph.ImportTexture(target.targetDepth), viewIndex); - } } if (aovRequest.isValid) aovRequest.PushCameraTexture(m_RenderGraph, AOVBuffers.Output, hdCamera, postProcessDest, aovBuffers); } + for (int viewIndex = 0; viewIndex < hdCamera.viewCount; ++viewIndex) + { + if (target.targetDepth != null) + { + BlitFinalCameraTexture(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, m_RenderGraph.ImportTexture(target.targetDepth), viewIndex); + } + } + // XR mirror view and blit do device EndCameraXR(m_RenderGraph, hdCamera); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderUtilities.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderUtilities.cs index 752ac579c43..1a4937ac46e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderUtilities.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/HDRenderUtilities.cs @@ -341,13 +341,15 @@ public static void Render( [Obsolete("Use CreateReflectionProbeRenderTarget with explicit format instead", true)] public static RenderTexture CreateReflectionProbeRenderTarget(int cubemapSize) { - return new RenderTexture(cubemapSize, cubemapSize, 1, GraphicsFormat.R16G16B16A16_SFloat) + RenderTexture rt = new RenderTexture(cubemapSize, cubemapSize, 1, GraphicsFormat.R16G16B16A16_SFloat) { dimension = TextureDimension.Cube, enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; + rt.Create(); + return rt; } /// @@ -358,13 +360,15 @@ public static RenderTexture CreateReflectionProbeRenderTarget(int cubemapSize) /// The texture to use as reflection probe target. public static RenderTexture CreateReflectionProbeRenderTarget(int cubemapSize, GraphicsFormat format) { - return new RenderTexture(cubemapSize, cubemapSize, 1, format) + RenderTexture rt = new RenderTexture(cubemapSize, cubemapSize, 1, format) { dimension = TextureDimension.Cube, enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; + rt.Create(); + return rt; } /// @@ -375,13 +379,15 @@ public static RenderTexture CreateReflectionProbeRenderTarget(int cubemapSize, G /// The texture used as planar reflection probe target public static RenderTexture CreatePlanarProbeRenderTarget(int planarSize, GraphicsFormat format) { - return new RenderTexture(planarSize, planarSize, 1, format) + RenderTexture rt = new RenderTexture(planarSize, planarSize, 1, format) { dimension = TextureDimension.Tex2D, enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; + rt.Create(); + return rt; } /// @@ -391,13 +397,15 @@ public static RenderTexture CreatePlanarProbeRenderTarget(int planarSize, Graphi /// The texture used as planar reflection probe target public static RenderTexture CreatePlanarProbeDepthRenderTarget(int planarSize) { - return new RenderTexture(planarSize, planarSize, 1, GraphicsFormat.R32_SFloat) + RenderTexture rt = new RenderTexture(planarSize, planarSize, 1, GraphicsFormat.R32_SFloat) { dimension = TextureDimension.Tex2D, enableRandomWrite = true, useMipMap = true, autoGenerateMips = false }; + rt.Create(); + return rt; } /// From 49adcc0f26ad7c13424fa7c4df36edf2bc40d543 Mon Sep 17 00:00:00 2001 From: Anis Benyoub Date: Thu, 17 Dec 2020 11:35:46 +0100 Subject: [PATCH 2/2] adding comment --- .../Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs | 2 ++ 1 file changed, 2 insertions(+) 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 8afed08a12f..0be5de6f3e5 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 @@ -299,6 +299,8 @@ void ExecuteWithRenderGraph(RenderRequest renderRequest, aovRequest.PushCameraTexture(m_RenderGraph, AOVBuffers.Output, hdCamera, postProcessDest, aovBuffers); } + // This code is only for planar reflections. Given that the depth texture cannot be shared currently with the other depth copy that we do + // we need to do this seperately. for (int viewIndex = 0; viewIndex < hdCamera.viewCount; ++viewIndex) { if (target.targetDepth != null)