From 68b7f0d79cb57e83eefe794ae68a81f71afd3e77 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Wed, 8 Dec 2021 11:17:08 +0100 Subject: [PATCH 1/3] Fixed sky auto-exposure mismatch. --- .../Runtime/RenderPipeline/PathTracing/PathTracing.cs | 10 ++++++++-- .../PathTracing/Shaders/PathTracingMain.raytrace | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index 161f358d903..029b0543f91 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -383,9 +383,15 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle skyBuff passData.skyManager = m_SkyManager; builder.SetRenderFunc( - (RenderSkyPassData data, RenderGraphContext context) => + (RenderSkyPassData data, RenderGraphContext ctx) => { - data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthTexture, data.debugDisplaySettings, context.cmd); + // Override the exposure texture, as we need a neutral value for this render + ctx.cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, m_EmptyExposureTexture); + + data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthTexture, data.debugDisplaySettings, ctx.cmd); + + // Restore the regular exposure texture + ctx.cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, GetExposureTexture(hdCamera)); }); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace index 265376c2cfa..8f282e717c8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace @@ -46,7 +46,7 @@ void MissCamera(inout PathIntersection pathIntersection : SV_RayPayload) bool skyEnabled = _EnvLightSkyEnabled && _RaytracingCameraSkyEnabled; float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor; - pathIntersection.value = missColor.rgb * GetInverseCurrentExposureMultiplier(); + pathIntersection.value = missColor.rgb; pathIntersection.alpha = missColor.a; ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.value, pathIntersection.alpha); From eb676d20e1a30e4b2abc36fb02d8a992de77fbb7 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Wed, 8 Dec 2021 11:23:41 +0100 Subject: [PATCH 2/3] 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 14c03cfb1f1..a5d2115a89d 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed HDRP build issues with DOTS_INSTANCING_ON shader variant. - Fixed default value of "Distortion Blur" from 1 to 0 according to the doc. - Fixed Transparent Depth Pre/Post pass by default for the built-in HDRP Hair shader graph. +- Fixed auto-exposure mismatch between sky background and scene objects in path tracing (case 1385131). ## [13.1.2] - 2021-11-05 From c23cc267aec9eec5d7e1bba82444441c9a484dd4 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Wed, 8 Dec 2021 11:53:39 +0100 Subject: [PATCH 3/3] Fixed camera clear color. --- .../RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace index 8f282e717c8..98d180ef56d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace @@ -45,7 +45,7 @@ void MissCamera(inout PathIntersection pathIntersection : SV_RayPayload) } bool skyEnabled = _EnvLightSkyEnabled && _RaytracingCameraSkyEnabled; - float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor; + float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor * GetInverseCurrentExposureMultiplier(); pathIntersection.value = missColor.rgb; pathIntersection.alpha = missColor.a;