Skip to content

Commit a5a3180

Browse files
[HDRP][Path Tracing] Fixed auto-exposure mistmatch between sky background and rendered objects (#6525)
* Fixed sky auto-exposure mismatch. * Updated changelog. * Fixed camera clear color. Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
1 parent 4fe0e67 commit a5a3180

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5454
- Fixed Transparent Depth Pre/Post pass by default for the built-in HDRP Hair shader graph.
5555
- Fixed build warnings due to the exception in burst code (case 1382827).
5656
- Fixed unsupported material properties show when rendering pass is Low Resolution.
57+
- Fixed auto-exposure mismatch between sky background and scene objects in path tracing (case 1385131).
5758

5859
## [12.1.2] - 2021-10-22
5960

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,15 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle skyBuff
370370
passData.skyManager = m_SkyManager;
371371

372372
builder.SetRenderFunc(
373-
(RenderSkyPassData data, RenderGraphContext context) =>
373+
(RenderSkyPassData data, RenderGraphContext ctx) =>
374374
{
375-
data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthTexture, data.debugDisplaySettings, context.cmd);
375+
// Override the exposure texture, as we need a neutral value for this render
376+
ctx.cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, m_EmptyExposureTexture);
377+
378+
data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthTexture, data.debugDisplaySettings, ctx.cmd);
379+
380+
// Restore the regular exposure texture
381+
ctx.cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, GetExposureTexture(hdCamera));
376382
});
377383
}
378384
}

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ void MissCamera(inout PathIntersection pathIntersection : SV_RayPayload)
4545
}
4646

4747
bool skyEnabled = _EnvLightSkyEnabled && _RaytracingCameraSkyEnabled;
48-
float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor;
49-
pathIntersection.value = missColor.rgb * GetInverseCurrentExposureMultiplier();
48+
float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor * GetInverseCurrentExposureMultiplier();
49+
pathIntersection.value = missColor.rgb;
5050
pathIntersection.alpha = missColor.a;
5151

5252
ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.value, pathIntersection.alpha);

0 commit comments

Comments
 (0)