Skip to content

[HDRP][Path Tracing] Fixed auto-exposure mistmatch between sky background and rendered objects #6525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed FOV change when enabling physical camera.
- Fixed spot light shadows near plane
- Fixed unsupported material properties show when rendering pass is Low Resolution.
- Fixed auto-exposure mismatch between sky background and scene objects in path tracing (case 1385131).

## [13.1.2] - 2021-11-05

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ 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();
float4 missColor = skyEnabled ? _SkyCameraTexture[COORD_TEXTURE2D_X(pathIntersection.pixelCoord)] : _RaytracingCameraClearColor * GetInverseCurrentExposureMultiplier();
pathIntersection.value = missColor.rgb;
pathIntersection.alpha = missColor.a;

ApplyFogAttenuation(WorldRayOrigin(), WorldRayDirection(), pathIntersection.value, pathIntersection.alpha);
Expand Down