Skip to content

Commit 4fce91f

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 <[email protected]>
1 parent 34f7ac1 commit 4fce91f

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
@@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6262
- Fixed FOV change when enabling physical camera.
6363
- Fixed spot light shadows near plane
6464
- Fixed unsupported material properties show when rendering pass is Low Resolution.
65+
- Fixed auto-exposure mismatch between sky background and scene objects in path tracing (case 1385131).
6566

6667
## [13.1.2] - 2021-11-05
6768

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
@@ -383,9 +383,15 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle skyBuff
383383
passData.skyManager = m_SkyManager;
384384

385385
builder.SetRenderFunc(
386-
(RenderSkyPassData data, RenderGraphContext context) =>
386+
(RenderSkyPassData data, RenderGraphContext ctx) =>
387387
{
388-
data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthTexture, data.debugDisplaySettings, context.cmd);
388+
// Override the exposure texture, as we need a neutral value for this render
389+
ctx.cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, m_EmptyExposureTexture);
390+
391+
data.skyManager.RenderSky(data.hdCamera, data.sunLight, data.colorBuffer, data.depthTexture, data.debugDisplaySettings, ctx.cmd);
392+
393+
// Restore the regular exposure texture
394+
ctx.cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, GetExposureTexture(hdCamera));
389395
});
390396
}
391397
}

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)