From 852626885c41b350b000312e666b89c8f1283beb Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 17 Apr 2020 11:50:21 +0200 Subject: [PATCH 1/7] Added the API to override camera rendering --- .../RenderPipeline/HDRenderPipeline.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) 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 ebdfa2fb13e..da29f0d794b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -279,6 +279,7 @@ internal int GetMaxScreenSpaceShadows() bool m_ValidAPI; // False by default mean we render normally, true mean we don't render anything bool m_IsDepthBufferCopyValid; RenderTexture m_TemporaryTargetForCubemaps; + HDCamera m_CurrentHDCamera; private CameraCache<(Transform viewer, HDProbe probe, int face)> m_ProbeCameraCache = new CameraCache<(Transform viewer, HDProbe probe, int face)>(); @@ -1899,6 +1900,7 @@ AOVRequestData aovRequest // Updates RTHandle hdCamera.BeginRender(cmd); + m_CurrentHDCamera = hdCamera; if (m_RayTracingSupported) { @@ -2560,6 +2562,8 @@ void Callback(CommandBuffer c, HDCamera cam) // Otherwise command would not be rendered in order. renderContext.ExecuteCommandBuffer(cmd); cmd.Clear(); + + m_CurrentHDCamera = null; } struct BlitFinalCameraTextureParameters @@ -4753,5 +4757,57 @@ void SendColorGraphicsBuffer(CommandBuffer cmd, HDCamera hdCamera) VFXManager.SetCameraBuffer(hdCamera.camera, VFXCameraBufferTypes.Color, colorBuffer, 0, 0, hdCamera.actualWidth, hdCamera.actualHeight); } } + + /// + /// Overrides the current camera, changing all the matrices and view parameters for the new one. + /// It allows you to render objects from another camera, which can be useful in custom passes for example. + /// + public struct OverrideCameraRendering : IDisposable + { + CommandBuffer cmd; + + /// + /// Overrides the current camera, changing all the matrices and view parameters for the new one. + /// + /// The current command buffer in use + /// The camera that will replace the current one + /// + /// + /// using (new HDRenderPipeline.OverrideCameraRendering(cmd, overrideCamera)) + /// { + /// ... + /// } + /// + /// + public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) + { + this.cmd = cmd; + var hdrp = HDRenderPipeline.currentPipeline; + var hdCamera = HDCamera.GetOrCreate(overrideCamera); + + // Update HDCamera datas + hdCamera.Update(hdCamera.frameSettings, hdrp, hdrp.m_MSAASamples, hdrp.m_XRSystem.emptyPass); + hdCamera.UpdateAllViewConstants(false); + hdCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); + + ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); + } + + /// + /// Reset the camera settings to the original camera + /// + void IDisposable.Dispose() + { + if (m_CurrentHDCamera == null) + { + Debug.LogError("OverrideCameraRendering can only be called inside the render loop !"); + return; + } + + var hdrp = HDRenderPipeline.currentPipeline; + hdrp.m_CurrentHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); + ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); + } + } } } From 4cb6126bec6cb6208eecac159d405121e166add0 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 17 Apr 2020 11:50:27 +0200 Subject: [PATCH 2/7] Updated 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 ee5b4177476..c09cb091cb6 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -105,6 +105,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added Light decomposition lighting debugging modes and support in AOV - Added exposure compensation to Fixed exposure mode - Added support for rasterized area light shadows in StackLit +- Added an API in HDRP to override the camera within the rendering of a frame (mainly for custom pass). ### Fixed - Fix when rescale probe all direction below zero (1219246) From 27f9e29baa48bd0e2f7968d1de374bd9510e50bc Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 17 Apr 2020 12:10:01 +0200 Subject: [PATCH 3/7] Fixed compilation issue --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 da29f0d794b..43421a6bc07 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -4798,13 +4798,14 @@ public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) /// void IDisposable.Dispose() { - if (m_CurrentHDCamera == null) + var hdrp = HDRenderPipeline.currentPipeline; + + if (hdrp.m_CurrentHDCamera == null) { Debug.LogError("OverrideCameraRendering can only be called inside the render loop !"); return; } - var hdrp = HDRenderPipeline.currentPipeline; hdrp.m_CurrentHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); } From a71e6de35adb067df1a012e870ac5896aad94a0d Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 17 Apr 2020 16:19:06 +0200 Subject: [PATCH 4/7] Factorized protection function --- .../RenderPipeline/HDRenderPipeline.cs | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) 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 43421a6bc07..99c398009d5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -4764,7 +4764,8 @@ void SendColorGraphicsBuffer(CommandBuffer cmd, HDCamera hdCamera) /// public struct OverrideCameraRendering : IDisposable { - CommandBuffer cmd; + CommandBuffer cmd; + Camera overrideCamera; /// /// Overrides the current camera, changing all the matrices and view parameters for the new one. @@ -4782,6 +4783,11 @@ public struct OverrideCameraRendering : IDisposable public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) { this.cmd = cmd; + this.overrideCamera = overrideCamera; + + if (!IsContextValid(overrideCamera)) + return; + var hdrp = HDRenderPipeline.currentPipeline; var hdCamera = HDCamera.GetOrCreate(overrideCamera); @@ -4793,19 +4799,31 @@ public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); } - /// - /// Reset the camera settings to the original camera - /// - void IDisposable.Dispose() + bool IsContextValid(Camera overrideCamera) { var hdrp = HDRenderPipeline.currentPipeline; if (hdrp.m_CurrentHDCamera == null) { Debug.LogError("OverrideCameraRendering can only be called inside the render loop !"); - return; + return false; } + if (overrideCamera == hdrp.m_CurrentHDCamera.camera) + return false; + + return true; + } + + /// + /// Reset the camera settings to the original camera + /// + void IDisposable.Dispose() + { + if (!IsContextValid(overrideCamera)) + return; + + var hdrp = HDRenderPipeline.currentPipeline; hdrp.m_CurrentHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); } From b386cc5f12589731f0d2516bf008822e1d45a034 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Mon, 20 Apr 2020 17:32:31 +0200 Subject: [PATCH 5/7] Fixed camera override in scene view --- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 14 ++++++++++- .../RenderPipeline/HDRenderPipeline.cs | 25 +++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 721d597a27d..697cbd33e13 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -455,7 +455,7 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, } else { - finalViewport = new Rect(camera.pixelRect.x, camera.pixelRect.y, camera.pixelWidth, camera.pixelHeight); + finalViewport = GetPixelRect(); } actualWidth = Math.Max((int)finalViewport.size.x, 1); @@ -769,6 +769,9 @@ internal void UpdateCurrentSky(SkyManager skyManager) } } } + + internal void OverridePixelRect(Rect newPixelRect) => m_OverridePixelRect = newPixelRect; + internal void ResetPixelRect() => m_OverridePixelRect = null; #endregion #region Private API @@ -800,6 +803,7 @@ public RTHandle Allocator(string id, int frameIndex, RTHandleSystem rtHandleSyst IEnumerator> m_RecorderCaptureActions; int m_RecorderTempRT = Shader.PropertyToID("TempRecorder"); MaterialPropertyBlock m_RecorderPropertyBlock = new MaterialPropertyBlock(); + Rect? m_OverridePixelRect = null; void SetupCurrentMaterialQuality(CommandBuffer cmd) { @@ -1234,6 +1238,14 @@ void ReleaseHistoryBuffer() { m_HistoryRTSystem.ReleaseAll(); } + + Rect GetPixelRect() + { + if (m_OverridePixelRect != null) + return m_OverridePixelRect.Value; + else + return camera.pixelRect; + } #endregion } } 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 99c398009d5..695f15acc2f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -4766,6 +4766,8 @@ public struct OverrideCameraRendering : IDisposable { CommandBuffer cmd; Camera overrideCamera; + HDCamera overrideHDCamera; + float originalAspect; /// /// Overrides the current camera, changing all the matrices and view parameters for the new one. @@ -4784,17 +4786,27 @@ public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) { this.cmd = cmd; this.overrideCamera = overrideCamera; + this.overrideHDCamera = null; + this.originalAspect = 0; if (!IsContextValid(overrideCamera)) return; - + var hdrp = HDRenderPipeline.currentPipeline; - var hdCamera = HDCamera.GetOrCreate(overrideCamera); + overrideHDCamera = HDCamera.GetOrCreate(overrideCamera); + + // We need to patch the pixel rect of the camera because by default the camera size is synchronized + // with the game view and so it breaks in the scene view. Note that we can't use Camera.pixelRect here + // because when we assign it, the change is not instantaneous and is not reflected in pixelWidth/pixelHeight. + overrideHDCamera.OverridePixelRect(hdrp.m_CurrentHDCamera.camera.pixelRect); + // We also sync the aspect ratio of the camera, this time using the camera instead of HDCamera. + // This will update the projection matrix to match the aspect of the current rendering camera. + originalAspect = overrideCamera.aspect; + overrideCamera.aspect = (float)hdrp.m_CurrentHDCamera.camera.pixelRect.width / (float)hdrp.m_CurrentHDCamera.camera.pixelRect.height; // Update HDCamera datas - hdCamera.Update(hdCamera.frameSettings, hdrp, hdrp.m_MSAASamples, hdrp.m_XRSystem.emptyPass); - hdCamera.UpdateAllViewConstants(false); - hdCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); + overrideHDCamera.Update(overrideHDCamera.frameSettings, hdrp, hdrp.m_MSAASamples, hdrp.m_XRSystem.emptyPass); + overrideHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); } @@ -4823,6 +4835,9 @@ void IDisposable.Dispose() if (!IsContextValid(overrideCamera)) return; + overrideHDCamera.ResetPixelRect(); + overrideCamera.aspect = originalAspect; + var hdrp = HDRenderPipeline.currentPipeline; hdrp.m_CurrentHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); From 5775566195fddf7853e8d9ce9092fd6a55120c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Tue, 21 Apr 2020 17:14:50 +0200 Subject: [PATCH 6/7] Added isPersistant bool in HDCamera and allocateHistoryBuffers param in Update --- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 8 ++++++-- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 697cbd33e13..65890421363 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -199,6 +199,9 @@ internal struct ShadowHistoryUsage internal SkyUpdateContext m_LightingOverrideSky = new SkyUpdateContext(); + /// Mark the HDCamera as persistant so it won't be destroyed if the camera is disabled + internal bool isPersistent = false; + // VisualSky is the sky used for rendering in the main view. // LightingSky is the sky used for lighting the scene (ambient probe and sky reflection) // It's usually the visual sky unless a sky lighting override is setup. @@ -374,7 +377,7 @@ internal bool IsVolumetricReprojectionEnabled() // That way you will never update an HDCamera and forget to update the dependent system. // NOTE: This function must be called only once per rendering (not frame, as a single camera can be rendered multiple times with different parameters during the same frame) // Otherwise, previous frame view constants will be wrong. - internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, MSAASamples newMSAASamples, XRPass xrPass) + internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, MSAASamples newMSAASamples, XRPass xrPass, bool allocateHistoryBuffers = true) { // Inherit animation settings from the parent camera. Camera aniCam = (parentCamera != null) ? parentCamera : camera; @@ -403,6 +406,7 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, UpdateAntialiasing(); // Handle memory allocation. + if (allocateHistoryBuffers) { // Have to do this every frame in case the settings have changed. // The condition inside controls whether we perform init/deinit or not. @@ -553,7 +557,7 @@ internal static void CleanUnused() bool hasPersistentHistory = camera.m_AdditionalCameraData != null && camera.m_AdditionalCameraData.hasPersistentHistory; // We keep preview camera around as they are generally disabled/enabled every frame. They will be destroyed later when camera.camera is null - if (camera.camera == null || (!camera.camera.isActiveAndEnabled && camera.camera.cameraType != CameraType.Preview && !hasPersistentHistory)) + if (camera.camera == null || (!camera.camera.isActiveAndEnabled && camera.camera.cameraType != CameraType.Preview && !hasPersistentHistory && !camera.isPersistent)) s_Cleanup.Add(key); } 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 695f15acc2f..ff1f9f95f6c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -4795,6 +4795,9 @@ public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) var hdrp = HDRenderPipeline.currentPipeline; overrideHDCamera = HDCamera.GetOrCreate(overrideCamera); + // Mark the HDCamera as persistant so it's not deleted because it's camera is disabled. + overrideHDCamera.isPersistent = true; + // We need to patch the pixel rect of the camera because by default the camera size is synchronized // with the game view and so it breaks in the scene view. Note that we can't use Camera.pixelRect here // because when we assign it, the change is not instantaneous and is not reflected in pixelWidth/pixelHeight. @@ -4805,7 +4808,7 @@ public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) overrideCamera.aspect = (float)hdrp.m_CurrentHDCamera.camera.pixelRect.width / (float)hdrp.m_CurrentHDCamera.camera.pixelRect.height; // Update HDCamera datas - overrideHDCamera.Update(overrideHDCamera.frameSettings, hdrp, hdrp.m_MSAASamples, hdrp.m_XRSystem.emptyPass); + overrideHDCamera.Update(overrideHDCamera.frameSettings, hdrp, hdrp.m_MSAASamples, hdrp.m_XRSystem.emptyPass, allocateHistoryBuffers: false); overrideHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); From 9b1dd94b79d25f8619240d08e352f4b5af6b3e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Leli=C3=A8vre?= Date: Wed, 22 Apr 2020 18:29:35 +0200 Subject: [PATCH 7/7] Fixed camera override with dynamic resolution and moved it to internal --- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 12 +++++++++--- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 6 +++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 65890421363..e324144a3e2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -494,12 +494,18 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, RTHandles.SetReferenceSize(nonScaledViewport.x, nonScaledViewport.y, msaaSamples); } + /// Set the RTHandle scale to the actual camera size (can be scaled) + internal void SetReferenceSize() + { + RTHandles.SetReferenceSize(actualWidth, actualHeight, msaaSamples); + m_HistoryRTSystem.SwapAndSetReferenceSize(actualWidth, actualHeight, msaaSamples); + } + // Updating RTHandle needs to be done at the beginning of rendering (not during update of HDCamera which happens in batches) // The reason is that RTHandle will hold data necessary to setup RenderTargets and viewports properly. internal void BeginRender(CommandBuffer cmd) { - RTHandles.SetReferenceSize(actualWidth, actualHeight, msaaSamples); - m_HistoryRTSystem.SwapAndSetReferenceSize(actualWidth, actualHeight, msaaSamples); + SetReferenceSize(); m_RecorderCaptureActions = CameraCaptureBridge.GetCaptureActions(camera); @@ -1248,7 +1254,7 @@ Rect GetPixelRect() if (m_OverridePixelRect != null) return m_OverridePixelRect.Value; else - return camera.pixelRect; + return new Rect(camera.pixelRect.x, camera.pixelRect.y, camera.pixelWidth, camera.pixelHeight); } #endregion } 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 ff1f9f95f6c..da4b6c83959 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -4762,7 +4762,7 @@ void SendColorGraphicsBuffer(CommandBuffer cmd, HDCamera hdCamera) /// Overrides the current camera, changing all the matrices and view parameters for the new one. /// It allows you to render objects from another camera, which can be useful in custom passes for example. /// - public struct OverrideCameraRendering : IDisposable + internal struct OverrideCameraRendering : IDisposable { CommandBuffer cmd; Camera overrideCamera; @@ -4809,6 +4809,8 @@ public OverrideCameraRendering(CommandBuffer cmd, Camera overrideCamera) // Update HDCamera datas overrideHDCamera.Update(overrideHDCamera.frameSettings, hdrp, hdrp.m_MSAASamples, hdrp.m_XRSystem.emptyPass, allocateHistoryBuffers: false); + // Reset the reference size as it could have been changed by the override camera + hdrp.m_CurrentHDCamera.SetReferenceSize(); overrideHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); @@ -4842,6 +4844,8 @@ void IDisposable.Dispose() overrideCamera.aspect = originalAspect; var hdrp = HDRenderPipeline.currentPipeline; + // Reset the reference size as it could have been changed by the override camera + hdrp.m_CurrentHDCamera.SetReferenceSize(); hdrp.m_CurrentHDCamera.UpdateShaderVariablesGlobalCB(ref hdrp.m_ShaderVariablesGlobalCB, hdrp.m_FrameCount); ConstantBuffer.PushGlobal(cmd, hdrp.m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); }