diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 91fbe79c9c6..6c3c95d0c15 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed issue with compositor related custom passes still active after disabling the compositor (case 1305330) - Fixed some render texture leaks. - Fixed regression in Wizard that not fix runtime ressource anymore (case 1287627) +- Fixed error in Depth Of Field near radius blur calculation (case 1306228). ### Changed - Change the source value for the ray tracing frame index iterator from m_FrameCount to the camera frame count (case 1301356). diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs index bf1869b7ef9..52848d3862b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs @@ -507,7 +507,10 @@ TextureHandle DepthOfFieldPass(RenderGraph renderGraph, HDCamera hdCamera, Textu passData.fullresCoC = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = k_CoCFormat, enableRandomWrite = true, name = "Full res CoC" }); - int passCount = Mathf.CeilToInt((passData.parameters.nearMaxBlur + 2f) / 4f); + GetDoFResolutionScale(passData.parameters, out float unused, out float resolutionScale); + float actualNearMaxBlur = passData.parameters.nearMaxBlur * resolutionScale; + int passCount = Mathf.CeilToInt((actualNearMaxBlur + 2f) / 4f); + passData.dilationPingPongRT = TextureHandle.nullHandle; if (passCount > 1) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 6d6f68999d4..d1a37c0f329 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -1498,6 +1498,12 @@ DepthOfFieldParameters PrepareDoFParameters(HDCamera camera) return parameters; } + static void GetDoFResolutionScale(in DepthOfFieldParameters dofParameters, out float scale, out float resolutionScale) + { + scale = 1f / (float)dofParameters.resolution; + resolutionScale = (dofParameters.camera.actualHeight / 1080f) * (scale * 2f); + } + // // Reference used: // "A Lens and Aperture Camera Model for Synthetic Image Generation" [Potmesil81] @@ -1551,14 +1557,13 @@ static void DoDepthOfField(in DepthOfFieldParameters dofParameters, CommandBuffe float anamorphism = dofParameters.physicalCameraAnamorphism / 4f; float barrelClipping = dofParameters.physicalCameraBarrelClipping / 3f; - float scale = 1f / (float)dofParameters.resolution; + GetDoFResolutionScale(dofParameters, out float scale, out float resolutionScale); var screenScale = new Vector2(scale, scale); int targetWidth = Mathf.RoundToInt(dofParameters.camera.actualWidth * scale); int targetHeight = Mathf.RoundToInt(dofParameters.camera.actualHeight * scale); cmd.SetGlobalVector(HDShaderIDs._TargetScale, new Vector4((float)dofParameters.resolution, scale, 0f, 0f)); - float resolutionScale = (dofParameters.camera.actualHeight / 1080f) * (scale * 2f); int farSamples = dofParameters.farSampleCount; int nearSamples = dofParameters.nearSampleCount;