Skip to content

Fixed two issues with sky static lighting. #1775

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 8 commits into from
Sep 8, 2020
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
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue when undoing a change in diffuse profile list after deleting the volume profile.
- Fixed custom pass re-ordering and removing.
- Fixed TAA issue and hardware dynamic resolution.
- Fixed a static lighting flickering issue caused by having an active planar probe in the scene while rendering inspector preview.
- Fixed an issue where even when set to OnDemand, the sky lighting would still be updated when changing sky parameters.

### Changed
- Preparation pass for RTSSShadows to be supported by render graph.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ internal void ForceRenderingNextUpdate()

void UpdateProbeName()
{
// TODO: ask if this is ok:
if (settings.type == ProbeSettings.ProbeType.PlanarProbe)
if (settings.type == ProbeSettings.ProbeType.ReflectionProbe)
{
for (int i = 0; i < 6; i++)
probeName[i] = $"Reflection Probe RenderCamera ({name}: {(CubemapFace)i})";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ partial struct FrameSettings
(uint)FrameSettingsField.MotionVectors, // Enable/disable whole motion vectors pass (Camera + Object).
(uint)FrameSettingsField.ObjectMotionVectors,
(uint)FrameSettingsField.Decals,
(uint)FrameSettingsField.DecalLayers,
(uint)FrameSettingsField.DecalLayers,
(uint)FrameSettingsField.Refraction, // Depends on DepthPyramid - If not enable, just do a copy of the scene color (?) - how to disable refraction ?
(uint)FrameSettingsField.Distortion,
(uint)FrameSettingsField.Postprocess,
Expand Down Expand Up @@ -467,7 +467,7 @@ partial struct FrameSettings
(uint)FrameSettingsField.MotionVectors, // Enable/disable whole motion vectors pass (Camera + Object).
(uint)FrameSettingsField.ObjectMotionVectors,
(uint)FrameSettingsField.Decals,
(uint)FrameSettingsField.DecalLayers,
(uint)FrameSettingsField.DecalLayers,
//(uint)FrameSettingsField.Refraction, // Depends on DepthPyramid - If not enable, just do a copy of the scene color (?) - how to disable refraction ?
//(uint)FrameSettingsField.Distortion,
//(uint)FrameSettingsField.Postprocess,
Expand Down Expand Up @@ -797,6 +797,13 @@ internal static void Sanitize(ref FrameSettings sanitizedFrameSettings, Camera c
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.FPTLForForwardOpaque] &= !msaa;

sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.ProbeVolume] &= renderPipelineSettings.supportProbeVolume && (ShaderConfig.s_ProbeVolumesEvaluationMode != ProbeVolumesEvaluationModes.Disabled);

// We disable reflection probes and planar reflections in regular preview rendering for two reasons.
// - Performance: Realtime reflection are 99% not necessary in previews
// - Static lighting consistency: When rendering a planar probe from a preview camera it may induce a recomputing of the static lighting
// but with the preview lights which are different from the ones in the scene and will change the result inducing flickering.
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.ReflectionProbe] &= !preview;
sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.PlanarProbe] &= !preview;
}

/// <summary>Aggregation is default with override of the renderer then sanitized depending on supported features of hdrpasset.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,18 @@ public void UpdateEnvironment( HDCamera hdCamera,
m_BuiltinParameters.skySettings = skyContext.skySettings;
m_BuiltinParameters.cloudLayer = skyContext.cloudLayer;

// When update is not requested and the context is already valid (ie: already computed at least once),
// we need to early out in two cases:
// - updateMode is "OnDemand" in which case we never update unless explicitly requested
// - updateMode is "Realtime" in which case we only update if the time threshold for realtime update is passed.
if (IsCachedContextValid(skyContext) && !updateRequired)
{
if (skyContext.skySettings.updateMode.value == EnvironmentUpdateMode.OnDemand)
return;
else if (skyContext.skySettings.updateMode.value == EnvironmentUpdateMode.Realtime && skyContext.currentUpdateTime < skyContext.skySettings.updatePeriod.value)
return;
}

int skyHash = ComputeSkyHash(hdCamera, skyContext, sunLight, ambientMode, staticSky);
bool forceUpdate = updateRequired;

Expand All @@ -753,6 +765,7 @@ public void UpdateEnvironment( HDCamera hdCamera,
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.UpdateSkyEnvironment)))
{
// Debug.Log("Update Sky Lighting");
RenderSkyToCubemap(skyContext);

if (updateAmbientProbe)
Expand Down Expand Up @@ -832,7 +845,7 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC
{
m_StaticLightingSky.skySettings = staticLightingSky != null ? staticLightingSky.skySettings : null;
m_StaticLightingSky.cloudLayer = staticLightingSky != null ? staticLightingSky.cloudLayer : null;
UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd);
UpdateEnvironment(hdCamera, renderContext, m_StaticLightingSky, sunLight, m_StaticSkyUpdateRequired || m_UpdateRequired, true, true, SkyAmbientMode.Static, frameIndex, cmd);
m_StaticSkyUpdateRequired = false;
}

Expand Down