diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index fa2dc6f5262..eba82eddec0 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -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. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs index 6690a5a6d7d..111bf299026 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbe.cs @@ -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})"; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 6f4de1759e7..b9950eedb66 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -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, @@ -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, @@ -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; } /// Aggregation is default with override of the renderer then sanitized depending on supported features of hdrpasset. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs index b6c1199677d..cef35c4cedd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -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; @@ -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) @@ -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; }