From 56d99a8be0ea8f6027ff28e33a2ec7caef442f23 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Tue, 20 Oct 2020 10:53:49 +0200 Subject: [PATCH 1/4] Add frame setting --- .../Runtime/Material/VTBufferManager.cs | 59 +++++++++++-------- .../HDRenderPipeline.RenderGraph.cs | 7 ++- .../RenderPipeline/HDRenderPipeline.cs | 13 ++-- .../RenderPipeline/Settings/FrameSettings.cs | 8 +++ 4 files changed, 55 insertions(+), 32 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/VTBufferManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/VTBufferManager.cs index e2c907533d3..d5fec43b3a3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/VTBufferManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/VTBufferManager.cs @@ -79,23 +79,29 @@ public void Cleanup() public void BeginRender(HDCamera hdCamera) { - int width = hdCamera.actualWidth; - int height = hdCamera.actualHeight; - bool msaa = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); - GetResolveDimensions(ref width, ref height); - if (msaa) - m_ResolverMsaa.UpdateSize(width, height); - else - m_Resolver.UpdateSize(width, height); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.VirtualTexturing)) + { + int width = hdCamera.actualWidth; + int height = hdCamera.actualHeight; + bool msaa = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); + GetResolveDimensions(ref width, ref height); + if (msaa) + m_ResolverMsaa.UpdateSize(width, height); + else + m_Resolver.UpdateSize(width, height); + } } public void Resolve(CommandBuffer cmd, RTHandle rt, HDCamera hdCamera) { - var parameters = PrepareResolveVTParameters(hdCamera); - var msaaEnabled = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); - RTHandle input = msaaEnabled ? FeedbackBufferMsaa : (rt != null ? rt : FeedbackBuffer); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.VirtualTexturing)) + { + var parameters = PrepareResolveVTParameters(hdCamera); + var msaaEnabled = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); + RTHandle input = msaaEnabled ? FeedbackBufferMsaa : (rt != null ? rt : FeedbackBuffer); - ResolveVTDispatch(parameters, cmd, input, m_LowresResolver); + ResolveVTDispatch(parameters, cmd, input, m_LowresResolver); + } } class ResolveVTData @@ -107,21 +113,24 @@ class ResolveVTData public void Resolve(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle input) { - using (var builder = renderGraph.AddRenderPass("Resolve VT", out var passData)) + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.VirtualTexturing)) { - // The output is never read outside the pass but is still useful for the VT system so we can't cull this pass. - builder.AllowPassCulling(false); - - passData.parameters = PrepareResolveVTParameters(hdCamera); - passData.input = builder.ReadTexture(input); - passData.lowres = builder.WriteTexture(renderGraph.ImportTexture(m_LowresResolver)); - - builder.SetRenderFunc( - (ResolveVTData data, RenderGraphContext ctx) => + using (var builder = renderGraph.AddRenderPass("Resolve VT", out var passData)) { - ResolveVTDispatch(data.parameters, ctx.cmd, data.input, data.lowres); - VirtualTexturing.System.Update(); - }); + // The output is never read outside the pass but is still useful for the VT system so we can't cull this pass. + builder.AllowPassCulling(false); + + passData.parameters = PrepareResolveVTParameters(hdCamera); + passData.input = builder.ReadTexture(input); + passData.lowres = builder.WriteTexture(renderGraph.ImportTexture(m_LowresResolver)); + + builder.SetRenderFunc( + (ResolveVTData data, RenderGraphContext ctx) => + { + ResolveVTDispatch(data.parameters, ctx.cmd, data.input, data.lowres); + VirtualTexturing.System.Update(); + }); + } } } 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 5d82c8928aa..16d2c1697a6 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 @@ -174,8 +174,11 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, m_PostProcessSystem.DoUserAfterOpaqueAndSky(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.resolvedDepthBuffer, prepassOutput.resolvedNormalBuffer); - // No need for old stencil values here since from transparent on different features are tagged - ClearStencilBuffer(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.OpaqueObjects)) // If we don't have opaque objects there is no need to clear. + { + // No need for old stencil values here since from transparent on different features are tagged + ClearStencilBuffer(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer); + } colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, vtFeedbackBuffer, currentColorPyramid, volumetricLighting, rayCountTexture, m_SkyManager.GetSkyReflection(hdCamera), gpuLightListOutput, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovBuffers); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 6bddb91693b..cd0f3ea9ee6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2988,12 +2988,15 @@ void Callback(CommandBuffer c, HDCamera cam) } #if ENABLE_VIRTUALTEXTURES - m_VtBufferManager.Resolve(cmd, m_GbufferManager.GetVTFeedbackBuffer(), hdCamera); - VirtualTexturing.System.Update(); - - if(m_VTDebugBlit != null) + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.VirtualTexturing)) { - PushFullScreenVTFeedbackDebugTexture(cmd, GetVTFeedbackBufferForForward(hdCamera), hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)); + m_VtBufferManager.Resolve(cmd, m_GbufferManager.GetVTFeedbackBuffer(), hdCamera); + VirtualTexturing.System.Update(); + + if (m_VTDebugBlit != null) + { + PushFullScreenVTFeedbackDebugTexture(cmd, GetVTFeedbackBufferForForward(hdCamera), hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)); + } } #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 35d57b997b1..a403e9fb285 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -132,6 +132,11 @@ public enum FrameSettingsField /// When enabled, HDRP renders custom passes contained in CustomPassVolume components. [FrameSettingsField(0, autoName: CustomPass, customOrderInGroup: 11, tooltip: "When enabled, HDRP renders custom passes contained in CustomPassVolume components.")] CustomPass = 6, +#if ENABLE_VIRTUALTEXTURES + /// When enabled, HDRP can use virtual texturing. + [FrameSettingsField(0, autoName: VirtualTexturing, customOrderInGroup: 105, tooltip: "When enabled, HDRP can use virtual texturing.")] + VirtualTexturing = 67, +#endif /// When enabled, HDRP processes a motion vector pass for Cameras using these Frame Settings. [FrameSettingsField(0, autoName: MotionVectors, customOrderInGroup: 12, tooltip: "When enabled, HDRP processes a motion vector pass for Cameras using these Frame Settings (Depends on \"Motion Vectors\" in current HDRP Asset).")] @@ -390,6 +395,7 @@ partial struct FrameSettings (uint)FrameSettingsField.TransparentPrepass, (uint)FrameSettingsField.TransparentPostpass, (uint)FrameSettingsField.CustomPass, + (uint)FrameSettingsField.VirtualTexturing, (uint)FrameSettingsField.MotionVectors, // Enable/disable whole motion vectors pass (Camera + Object). (uint)FrameSettingsField.ObjectMotionVectors, (uint)FrameSettingsField.Decals, @@ -464,6 +470,7 @@ partial struct FrameSettings (uint)FrameSettingsField.TransparentPrepass, (uint)FrameSettingsField.TransparentPostpass, (uint)FrameSettingsField.CustomPass, + (uint)FrameSettingsField.VirtualTexturing, (uint)FrameSettingsField.MotionVectors, // Enable/disable whole motion vectors pass (Camera + Object). (uint)FrameSettingsField.ObjectMotionVectors, (uint)FrameSettingsField.Decals, @@ -519,6 +526,7 @@ partial struct FrameSettings (uint)FrameSettingsField.TransparentPrepass, (uint)FrameSettingsField.TransparentPostpass, (uint)FrameSettingsField.CustomPass, + (uint)FrameSettingsField.VirtualTexturing, //(uint)FrameSettingsField.MotionVectors, // Enable/disable whole motion vectors pass (Camera + Object). //(uint)FrameSettingsField.ObjectMotionVectors, (uint)FrameSettingsField.Decals, From 43d026ff9f33379e363903427936fcc5015adfae Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Tue, 20 Oct 2020 11:19:58 +0200 Subject: [PATCH 2/4] 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 0fc25d5c255..1fa452e9ead 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added a new ray tracing only function that samples the specular part of the materials. - Adding missing marker for ray tracing profiling (RaytracingDeferredLighting) - Added the support of eye shader for ray tracing. +- Added frame setting for Virtual Texturing. ### Fixed - Fixed several issues with physically-based DoF (TAA ghosting of the CoC buffer, smooth layer transitions, etc) From e3991b662864594b863d35585cc302abaa82ed48 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Fri, 23 Oct 2020 09:42:59 +0200 Subject: [PATCH 3/4] Grey setting out and make it always available. --- .../Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs | 3 +++ .../Runtime/RenderPipeline/Settings/FrameSettings.cs | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs index bbfd8692eec..ee00c90cfd8 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs @@ -236,6 +236,9 @@ static void Drawer_SectionRenderingSettings(SerializedFrameSettings serialized, }); area.AmmendInfo(FrameSettingsField.RayTracing, overrideable: () => hdrpSettings.supportRayTracing); +#if !ENABLE_VIRTUALTEXTURES + area.AmmendInfo(FrameSettingsField.VirtualTexturing, overrideable: () => false); +#endif area.AmmendInfo(FrameSettingsField.MotionVectors, overrideable: () => hdrpSettings.supportMotionVectors); area.AmmendInfo(FrameSettingsField.ObjectMotionVectors, overrideable: () => hdrpSettings.supportMotionVectors); area.AmmendInfo(FrameSettingsField.TransparentsWriteMotionVector, overrideable: () => hdrpSettings.supportMotionVectors); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index a403e9fb285..053e6fda810 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -132,11 +132,9 @@ public enum FrameSettingsField /// When enabled, HDRP renders custom passes contained in CustomPassVolume components. [FrameSettingsField(0, autoName: CustomPass, customOrderInGroup: 11, tooltip: "When enabled, HDRP renders custom passes contained in CustomPassVolume components.")] CustomPass = 6, -#if ENABLE_VIRTUALTEXTURES /// When enabled, HDRP can use virtual texturing. [FrameSettingsField(0, autoName: VirtualTexturing, customOrderInGroup: 105, tooltip: "When enabled, HDRP can use virtual texturing.")] VirtualTexturing = 67, -#endif /// When enabled, HDRP processes a motion vector pass for Cameras using these Frame Settings. [FrameSettingsField(0, autoName: MotionVectors, customOrderInGroup: 12, tooltip: "When enabled, HDRP processes a motion vector pass for Cameras using these Frame Settings (Depends on \"Motion Vectors\" in current HDRP Asset).")] From 5618508786be3b5bb5de30669497f056f91e2066 Mon Sep 17 00:00:00 2001 From: FrancescoC-Unity Date: Fri, 23 Oct 2020 11:08:58 +0200 Subject: [PATCH 4/4] Reverts tuff meant for antoher branch --- .../Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 16d2c1697a6..5d82c8928aa 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 @@ -174,11 +174,8 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, m_PostProcessSystem.DoUserAfterOpaqueAndSky(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.resolvedDepthBuffer, prepassOutput.resolvedNormalBuffer); - if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.OpaqueObjects)) // If we don't have opaque objects there is no need to clear. - { - // No need for old stencil values here since from transparent on different features are tagged - ClearStencilBuffer(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer); - } + // No need for old stencil values here since from transparent on different features are tagged + ClearStencilBuffer(m_RenderGraph, colorBuffer, prepassOutput.depthBuffer); colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, vtFeedbackBuffer, currentColorPyramid, volumetricLighting, rayCountTexture, m_SkyManager.GetSkyReflection(hdCamera), gpuLightListOutput, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovBuffers);