From ac93e17237a154c114c756436d2701952cf6a8a5 Mon Sep 17 00:00:00 2001 From: anisunity <42026998+anisunity@users.noreply.github.com> Date: Fri, 3 Apr 2020 12:22:10 +0200 Subject: [PATCH 01/81] [7.x.x Backport] Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). (#6507) * - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). * Small fix to avoid text overlapping too much Co-authored-by: Remi Chapelain --- .../CHANGELOG.md | 1 + .../Settings/SerializedScalableSetting.cs | 60 +++++++++++++------ 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6cc7b8f936b..deb9311e71e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed drag area width at left of Light's intensity field in Inspector. - Fix for issue that prevented scene from being completely saved when baked reflection probes are present and lighting is set to auto generate. - Fixed the depth buffer copy made before custom pass after opaque and normal injection point. +- Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs index 29ffffe21c3..ddf918b1a6a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedScalableSetting.cs @@ -136,29 +136,55 @@ ScalableSettingSchema schema static void MultiField(Rect position, GUIContent[] subLabels, T[] values) where T: struct { + // The number of slots we need to fit into this rectangle var length = values.Length; - var num = (position.width - (float) (length - 1) * 3f) / (float) length; - var position1 = new Rect(position) - { - width = num - }; - var labelWidth = EditorGUIUtility.labelWidth; + + // Let's compute the space allocated for every field including the label + var num = position.width / (float) length; + + // Reset the indentation var indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; + + // Variable to keep track of the current pixel shift in the rectangle we were assigned for this whole section. + float pixelShift = 0; + + // Loop through the levels for (var index = 0; index < values.Length; ++index) { - EditorGUIUtility.labelWidth = CalcPrefixLabelWidth(subLabels[index], (GUIStyle) null); - if (typeof(T) == typeof(int)) - values[index] = (T)(object)EditorGUI.DelayedIntField(position1, subLabels[index], (int)(object)values[index]); - else if (typeof(T) == typeof(bool)) - values[index] = (T)(object)EditorGUI.Toggle(position1, subLabels[index], (bool)(object)values[index]); - else if (typeof(T) == typeof(float)) - values[index] = (T)(object)EditorGUI.FloatField(position1, subLabels[index], (float)(object)values[index]); - else - throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field"); - position1.x += num + 4f; + // Let's first compute what is the width of the label of this scalable setting level + // We make sure that the label doesn't go beyond the space available for this scalable setting level + var labelWidth = Mathf.Clamp(CalcPrefixLabelWidth(subLabels[index], (GUIStyle)null), 0, num); + + // Draw the Label at the expected position + EditorGUI.LabelField(new Rect(position.x + pixelShift, position.y, labelWidth, position.height), subLabels[index]); + + // We need to remove from the position the label size that we've just drawn and shift by it's length + pixelShift += labelWidth; + + // The amount of space left for the field + float spaceLeft = num - labelWidth; + + // If at least two pixels are left to draw this field, draw it, otherwise, skip + if (spaceLeft > 2) + { + // Define the rectangle for the field + var fieldSlot = new Rect(position.x + pixelShift, position.y, num - labelWidth, position.height); + + // Draw the right field depending on its type. + if (typeof(T) == typeof(int)) + values[index] = (T)(object)EditorGUI.DelayedIntField(fieldSlot, (int)(object)values[index]); + else if (typeof(T) == typeof(bool)) + values[index] = (T)(object)EditorGUI.Toggle(fieldSlot, (bool)(object)values[index]); + else if (typeof(T) == typeof(float)) + values[index] = (T)(object)EditorGUI.FloatField(fieldSlot, (float)(object)values[index]); + else + throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field"); + } + + // Shift by the slot that was left for the field + pixelShift += spaceLeft; } - EditorGUIUtility.labelWidth = labelWidth; EditorGUI.indentLevel = indentLevel; } From f4f74f13bd2641fef829e0e212e8fcc06f60ccab Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 7 Apr 2020 11:24:50 +0200 Subject: [PATCH 02/81] Fixed an usage of a a compute buffer not bound (1229964) (#28) Co-authored-by: Anis --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Lighting/LightLoop/LightLoop.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index deb9311e71e..3750842ffaa 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for issue that prevented scene from being completely saved when baked reflection probes are present and lighting is set to auto generate. - Fixed the depth buffer copy made before custom pass after opaque and normal injection point. - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). +- Fixed an usage of a a compute buffer not bound (1229964) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index e00440045ef..253b45ecd8a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -3150,7 +3150,8 @@ void BuildGPULightListsCommon(HDCamera hdCamera, CommandBuffer cmd) // Note we clear the whole content and not just the header since it is fast enough, happens only in one frame and is a bit more robust // to changes to the inner workings of the lists. // Also, we clear all the lists and to be resilient to changes in pipeline. - ClearLightList(hdCamera, cmd, resources.tileAndClusterData.bigTileLightList); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.BigTilePrepass)) + ClearLightList(hdCamera, cmd, resources.tileAndClusterData.bigTileLightList); ClearLightList(hdCamera, cmd, resources.tileAndClusterData.lightList); ClearLightList(hdCamera, cmd, resources.tileAndClusterData.perVoxelOffset); From 5ddc5f7d57402d8d02dcbec132714e1103d1d222 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Fri, 3 Apr 2020 12:16:21 +0200 Subject: [PATCH 03/81] Removed wrongly serialized fields in StaticLightingSky (#6441) --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Sky/StaticLightingSky.cs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3750842ffaa..acc501d6d50 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the depth buffer copy made before custom pass after opaque and normal injection point. - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). - Fixed an usage of a a compute buffer not bound (1229964) +- Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs index 2736cfcf1c4..38611f3af22 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using UnityEngine.Serialization; @@ -15,8 +16,9 @@ class StaticLightingSky : MonoBehaviour int m_LastComputedHash; bool m_NeedUpdateStaticLightingSky; - // This one contain only property values from overridden properties in the original profile component - public SkySettings m_SkySettings; + [NonSerialized] + public SkySettings m_SkySettings; // This one contain only property values from overridden properties in the original profile component + [NonSerialized] public SkySettings m_SkySettingsFromProfile; public SkySettings skySettings From 5faae4d30c5215a9388debbc8ee3d43937b3ec5c Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 7 Apr 2020 20:53:55 +0200 Subject: [PATCH 04/81] Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. #6480 --- .../CHANGELOG.md | 1 + .../PostProcessing/PostProcessSystem.cs | 74 +++++++++++++++++-- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index acc501d6d50..e9e42b0a523 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). - Fixed an usage of a a compute buffer not bound (1229964) - Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. +- Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 615d2af76bd..a04f91e90b3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -133,6 +133,15 @@ private enum SMAAStage HDRenderPipeline m_HDInstance; + void FillEmptyExposureTexture() + { + var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); + tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); + tex.Apply(); + Graphics.Blit(tex, m_EmptyExposureTexture); + CoreUtils.Destroy(tex); + } + public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources defaultResources) { m_Resources = defaultResources; @@ -206,11 +215,7 @@ public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources // TODO: Write a version that uses structured buffer instead of texture to do atomic as Metal doesn't support atomics on textures. m_MotionBlurSupportsScattering = m_MotionBlurSupportsScattering && (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Metal); - var tex = new Texture2D(1, 1, TextureFormat.RGHalf, false, true); - tex.SetPixel(0, 0, new Color(1f, ColorUtils.ConvertExposureToEV100(1f), 0f, 0f)); - tex.Apply(); - Graphics.Blit(tex, m_EmptyExposureTexture); - CoreUtils.Destroy(tex); + FillEmptyExposureTexture(); // Initialize our target pool to ease RT management m_Pool = new TargetPool(); @@ -287,6 +292,23 @@ public void Cleanup() m_FarBokehTileList = null; } + // In some cases, the internal buffer of render textures might be invalid. + // Usually when using these textures with API such as SetRenderTarget, they are recreated internally. + // This is not the case when these textures are used exclusively with Compute Shaders. So to make sure they work in this case, we recreate them here. + void CheckRenderTexturesValidity() + { + if (!m_EmptyExposureTexture.rt.IsCreated()) + FillEmptyExposureTexture(); + + HDUtils.CheckRTCreated(m_InternalLogLut.rt); + HDUtils.CheckRTCreated(m_TempTexture1024.rt); + HDUtils.CheckRTCreated(m_TempTexture32.rt); + if (m_KeepAlpha) + { + HDUtils.CheckRTCreated(m_AlphaTexture.rt); + } + } + public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdInstance) { m_HDInstance = hdInstance; @@ -336,6 +358,8 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn m_DitheringFS = frameSettings.IsEnabled(FrameSettingsField.Dithering); m_AntialiasingFS = frameSettings.IsEnabled(FrameSettingsField.Antialiasing); + CheckRenderTexturesValidity(); + // Handle fixed exposure & disabled pre-exposure by forcing an exposure multiplier of 1 if (!m_ExposureControlFS) { @@ -929,6 +953,40 @@ void DoTemporalAntialiasing(CommandBuffer cmd, HDCamera camera, RTHandle source, m_TAAPropertyBlock.SetVector(HDShaderIDs._RTHandleScaleHistory, camera.historyRTHandleProperties.rtHandleScale); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputTexture, source); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputHistoryTexture, prevHistory); +<<<<<<< HEAD +======= + m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputVelocityMagnitudeHistory, prevMVLen); + + m_TAAPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain); + + float minAntiflicker = 0.0f; + float maxAntiflicker = 3.5f; + float motionRejectionMultiplier = Mathf.Lerp(0.0f, 250.0f, camera.taaMotionVectorRejection * camera.taaMotionVectorRejection * camera.taaMotionVectorRejection); + + var taaParameters = new Vector4(camera.taaHistorySharpening, Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, 0.0f); + Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x, + prevHistory.referenceSize.y * prevHistory.scaleFactor.y); + var rtScaleForHistory = camera.historyRTHandleProperties.rtHandleScale; + var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y); + + // Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point. + float crossWeights = Mathf.Exp(-2.29f * 2); + float plusWeights = Mathf.Exp(-2.29f); + float centerWeight = 1; + + float totalWeight = centerWeight + (4 * plusWeights); + if (camera.TAAQuality == HDAdditionalCameraData.TAAQualityLevel.High) + { + totalWeight += crossWeights * 4; + } + + // Weights will be x: central, y: plus neighbours, z: cross neighbours, w: total + Vector4 taaFilterWeights = new Vector4(centerWeight / totalWeight, plusWeights / totalWeight, crossWeights / totalWeight, totalWeight); + + m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaPostParameters, taaParameters); + m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaHistorySize, taaHistorySize); + m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaFilterWeights, taaFilterWeights); +>>>>>>> 968d203cb6... Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. (#6480) CoreUtils.SetRenderTarget(cmd, destination, depthBuffer); cmd.SetRandomWriteTarget(1, nextHistory); @@ -2644,7 +2702,11 @@ public RTHandle Get(in Vector2 scaleFactor, GraphicsFormat format, bool mipmap = var hashCode = ComputeHashCode(scaleFactor.x, scaleFactor.y, (int)format, mipmap); if (m_Targets.TryGetValue(hashCode, out var stack) && stack.Count > 0) - return stack.Pop(); + { + var tex = stack.Pop(); + HDUtils.CheckRTCreated(tex.rt); + return tex; + } var rt = RTHandles.Alloc( scaleFactor, TextureXR.slices, DepthBits.None, colorFormat: format, dimension: TextureXR.dimension, From 3531a5791d9d79ddd36b11d5e9515805b2186bea Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 7 Apr 2020 21:14:10 +0200 Subject: [PATCH 05/81] Update PostProcessSystem.cs --- .../PostProcessing/PostProcessSystem.cs | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index a04f91e90b3..1f419daff06 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -953,40 +953,6 @@ void DoTemporalAntialiasing(CommandBuffer cmd, HDCamera camera, RTHandle source, m_TAAPropertyBlock.SetVector(HDShaderIDs._RTHandleScaleHistory, camera.historyRTHandleProperties.rtHandleScale); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputTexture, source); m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputHistoryTexture, prevHistory); -<<<<<<< HEAD -======= - m_TAAPropertyBlock.SetTexture(HDShaderIDs._InputVelocityMagnitudeHistory, prevMVLen); - - m_TAAPropertyBlock.SetTexture(HDShaderIDs._DepthTexture, depthMipChain); - - float minAntiflicker = 0.0f; - float maxAntiflicker = 3.5f; - float motionRejectionMultiplier = Mathf.Lerp(0.0f, 250.0f, camera.taaMotionVectorRejection * camera.taaMotionVectorRejection * camera.taaMotionVectorRejection); - - var taaParameters = new Vector4(camera.taaHistorySharpening, Mathf.Lerp(minAntiflicker, maxAntiflicker, camera.taaAntiFlicker), motionRejectionMultiplier, 0.0f); - Vector2 historySize = new Vector2(prevHistory.referenceSize.x * prevHistory.scaleFactor.x, - prevHistory.referenceSize.y * prevHistory.scaleFactor.y); - var rtScaleForHistory = camera.historyRTHandleProperties.rtHandleScale; - var taaHistorySize = new Vector4(historySize.x, historySize.y, 1.0f / historySize.x, 1.0f / historySize.y); - - // Precompute weights used for the Blackman-Harris filter. TODO: Note that these are slightly wrong as they don't take into account the jitter size. This needs to be fixed at some point. - float crossWeights = Mathf.Exp(-2.29f * 2); - float plusWeights = Mathf.Exp(-2.29f); - float centerWeight = 1; - - float totalWeight = centerWeight + (4 * plusWeights); - if (camera.TAAQuality == HDAdditionalCameraData.TAAQualityLevel.High) - { - totalWeight += crossWeights * 4; - } - - // Weights will be x: central, y: plus neighbours, z: cross neighbours, w: total - Vector4 taaFilterWeights = new Vector4(centerWeight / totalWeight, plusWeights / totalWeight, crossWeights / totalWeight, totalWeight); - - m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaPostParameters, taaParameters); - m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaHistorySize, taaHistorySize); - m_TAAPropertyBlock.SetVector(HDShaderIDs._TaaFilterWeights, taaFilterWeights); ->>>>>>> 968d203cb6... Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. (#6480) CoreUtils.SetRenderTarget(cmd, destination, depthBuffer); cmd.SetRandomWriteTarget(1, nextHistory); From 84b722da62ff2a385c4af7fa0b3688e49741d083 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Fri, 3 Apr 2020 12:14:50 +0200 Subject: [PATCH 06/81] Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. #6493 --- .../Editor/Volume/VolumeComponentListEditor.cs | 15 ++++++++++----- .../Runtime/Volume/VolumeProfile.cs | 18 ++++++++++++++++++ .../CHANGELOG.md | 1 + .../Settings/DefaultSettingsPanel.cs | 14 +++++++++++--- 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs index f487281dc3c..21a110079a0 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeComponentListEditor.cs @@ -16,24 +16,24 @@ namespace UnityEditor.Rendering /// in the inspector: /// /// using UnityEngine.Rendering; - /// + /// /// [CustomEditor(typeof(VolumeProfile))] /// public class CustomVolumeProfileEditor : Editor /// { /// VolumeComponentListEditor m_ComponentList; - /// + /// /// void OnEnable() /// { /// m_ComponentList = new VolumeComponentListEditor(this); /// m_ComponentList.Init(target as VolumeProfile, serializedObject); /// } - /// + /// /// void OnDisable() /// { /// if (m_ComponentList != null) /// m_ComponentList.Clear(); /// } - /// + /// /// public override void OnInspectorGUI() /// { /// serializedObject.Update(); @@ -58,6 +58,8 @@ public sealed class VolumeComponentListEditor Dictionary m_EditorTypes; // Component type => Editor type List m_Editors; + int m_CurrentHashCode; + /// /// Creates a new instance of to use in an /// existing editor. @@ -195,9 +197,12 @@ public void OnGUI() if (asset == null) return; - if (asset.isDirty) + // Even if the asset is not dirty, the list of component may have been changed by another inspector. + // In this case, only the hash will tell us that we need to refresh. + if (asset.isDirty || asset.GetHashCode() != m_CurrentHashCode) { RefreshEditors(); + m_CurrentHashCode = asset.GetHashCode(); asset.isDirty = false; } diff --git a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index 31a3f01272a..127ae880810 100644 --- a/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -279,5 +279,23 @@ public bool TryGetAllSubclassOf(Type type, List result) return count != result.Count; } + + + /// + /// A custom hashing function that Unity uses to compare the state of parameters. + /// + /// A computed hash code for the current instance. + public override int GetHashCode() + { + unchecked + { + int hash = 17; + + for (int i = 0; i < components.Count; i++) + hash = hash * 23 + components[i].GetHashCode(); + + return hash; + } + } } } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index e9e42b0a523..25b769d58c2 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an usage of a a compute buffer not bound (1229964) - Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. - Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. +- Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs index 1018c140941..b244d14d284 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs @@ -45,6 +45,7 @@ public class Styles ReorderableList m_BeforeTransparentCustomPostProcesses; ReorderableList m_BeforePostProcessCustomPostProcesses; ReorderableList m_AfterPostProcessCustomPostProcesses; + int m_CurrentVolumeProfileHash; public void OnGUI(string searchContext) { @@ -207,6 +208,13 @@ void Draw_VolumeInspector() } EditorGUILayout.EndHorizontal(); + // The state of the profile can change without the asset reference changing so in this case we need to reset the editor. + if (m_CurrentVolumeProfileHash != asset.GetHashCode() && m_CachedDefaultVolumeProfileEditor != null) + { + m_CurrentVolumeProfileHash = asset.GetHashCode(); + m_CachedDefaultVolumeProfileEditor = null; + } + Editor.CreateCachedEditor(asset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedDefaultVolumeProfileEditor); EditorGUIUtility.labelWidth -= 18; bool oldEnabled = GUI.enabled; @@ -230,13 +238,13 @@ void Draw_VolumeInspector() hdrpAsset.defaultLookDevProfile = newLookDevAsset; EditorUtility.SetDirty(hdrpAsset); } - + if (GUILayout.Button(EditorGUIUtility.TrTextContent("New", "Create a new Volume Profile for default in your default resource folder (defined in Wizard)"), GUILayout.Width(38), GUILayout.Height(18))) { DefaultVolumeProfileCreator.CreateAndAssign(DefaultVolumeProfileCreator.Kind.LookDev); } EditorGUILayout.EndHorizontal(); - + Editor.CreateCachedEditor(lookDevAsset, Type.GetType("UnityEditor.Rendering.VolumeProfileEditor"), ref m_CachedLookDevVolumeProfileEditor); EditorGUIUtility.labelWidth -= 18; oldEnabled = GUI.enabled; @@ -311,7 +319,7 @@ static string GetDefaultName(Kind kind) } return defaultName; } - + public static void CreateAndAssign(Kind kind) { var assetCreator = ScriptableObject.CreateInstance(); From 0cd029919edb82f4c394e135f3ef29e926db8946 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 2 Apr 2020 11:15:43 +0100 Subject: [PATCH 07/81] Hdrp/docs/glossary f number (#6523) * Update Glossary.md * Update Glossary.md --- .../Documentation~/Glossary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md b/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md index 93c340fad87..65bbdd53b8e 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md @@ -40,7 +40,7 @@ A face refers to one side of a piece of geometry. The front face is the side of #### f-number: -The ratio of the focal length to the diameter of the camera lens. +The ratio of the focal length to the diameter of the camera lens. HDRP technically uses [t-number](https://en.wikipedia.org/wiki/F-number#T-stop), but since Cameras in Unity are optically perfect, f-number and t-number are identical. From accff861218da0672b0700356722a58ef5c8949f Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Tue, 7 Apr 2020 19:32:29 +0200 Subject: [PATCH 08/81] Clamp probes compression factor to 0 (#19) --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Utilities/ProbeSettings.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 25b769d58c2..3d5d5675c61 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. - Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. - Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. +- Fix for range compression factor for probes going negative (now clamped to positive values). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs index 23499318e19..23360c346f5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/ProbeSettings.cs @@ -137,6 +137,7 @@ public struct Lighting public float fadeDistance; /// The result of the rendering of the probe will be divided by this factor. When the probe is read, this factor is undone as the probe data is read. /// This is to simply avoid issues with values clamping due to precision of the storing format. + [Min(1e-6f)] public float rangeCompressionFactor; } From b754f52b3cc3dc1d97215fc3051d8e9a4cc32548 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 8 Apr 2020 00:15:55 +0200 Subject: [PATCH 09/81] path validation when creating new volume profile (#36) --- .../Editor/Volume/VolumeProfileFactory.cs | 16 +++++++++++++--- .../CHANGELOG.md | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs b/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs index c9eba822995..cf00102a263 100644 --- a/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs +++ b/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileFactory.cs @@ -56,12 +56,22 @@ public static VolumeProfile CreateVolumeProfile(Scene scene, string targetName) { var scenePath = Path.GetDirectoryName(scene.path); var extPath = scene.name; - var profilePath = scenePath + "/" + extPath; + var profilePath = scenePath + Path.DirectorySeparatorChar + extPath; if (!AssetDatabase.IsValidFolder(profilePath)) - AssetDatabase.CreateFolder(scenePath, extPath); + { + var directories = profilePath.Split(Path.DirectorySeparatorChar); + string rootPath = ""; + foreach (var directory in directories) + { + var newPath = rootPath + directory; + if (!AssetDatabase.IsValidFolder(newPath)) + AssetDatabase.CreateFolder(rootPath.TrimEnd(Path.DirectorySeparatorChar), directory); + rootPath = newPath + Path.DirectorySeparatorChar; + } + } - path = profilePath + "/"; + path = profilePath + Path.DirectorySeparatorChar; } path += targetName + " Profile.asset"; diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3d5d5675c61..931c4151dd4 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. - Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. - Fix for range compression factor for probes going negative (now clamped to positive values). +- Fixed path validation when creating new volume profile (case 1229933) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. From bc7cc756c5558a3b9395da0b2affb98ea9442309 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Wed, 15 Apr 2020 12:50:33 +0200 Subject: [PATCH 10/81] [Backport 7.x.x] Fix various leaks in HDRP (#120) * Fixed a number of leak in HDRP # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs * Update changelog --- .../Runtime/Common/ComponentSingleton.cs | 15 ++++++++++++++- .../CHANGELOG.md | 1 + .../Runtime/Core/Textures/TextureCacheCubemap.cs | 4 +++- .../Runtime/Lighting/Shadow/HDShadowManager.cs | 12 ++++++++---- .../Runtime/PostProcessing/PostProcessSystem.cs | 4 ++++ .../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 ++ .../RenderPipeline/RenderPass/MipGenerator.cs | 4 +++- .../Runtime/RenderPipeline/Utility/HDUtils.cs | 11 +++++++++-- .../PhysicallyBasedSkyRenderer.cs | 7 ++++--- 9 files changed, 48 insertions(+), 12 deletions(-) diff --git a/com.unity.render-pipelines.core/Runtime/Common/ComponentSingleton.cs b/com.unity.render-pipelines.core/Runtime/Common/ComponentSingleton.cs index fb02eab90cb..993c1283d03 100644 --- a/com.unity.render-pipelines.core/Runtime/Common/ComponentSingleton.cs +++ b/com.unity.render-pipelines.core/Runtime/Common/ComponentSingleton.cs @@ -20,7 +20,7 @@ public static TType instance { if (s_Instance == null) { - GameObject go = new GameObject("Default " + typeof(TType)) { hideFlags = HideFlags.HideAndDontSave }; + GameObject go = new GameObject("Default " + typeof(TType).Name) { hideFlags = HideFlags.HideAndDontSave }; go.SetActive(false); s_Instance = go.AddComponent(); } @@ -28,5 +28,18 @@ public static TType instance return s_Instance; } } + + /// + /// Release the component singleton. + /// + public static void Release() + { + if (s_Instance != null) + { + var go = s_Instance.gameObject; + CoreUtils.Destroy(go); + s_Instance = null; + } + } } } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 931c4151dd4..f6b0b47887d 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. - Fix for range compression factor for probes going negative (now clamped to positive values). - Fixed path validation when creating new volume profile (case 1229933) +- Fixed various object leaks in HDRP. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs index bb2ca768c52..82c52aec49a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Core/Textures/TextureCacheCubemap.cs @@ -189,7 +189,9 @@ public void Release() CoreUtils.Destroy(m_CubeBlitMaterial); } - m_Cache.Release(); + CoreUtils.Destroy(m_BlitCubemapFaceMaterial); + + CoreUtils.Destroy(m_Cache); } private bool TransferToPanoCache(CommandBuffer cmd, int sliceIndex, Texture[] textureArray) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs index 159ac9e7d04..345b8f95eda 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs @@ -257,6 +257,8 @@ partial class HDShadowManager : IDisposable int m_CascadeCount; int m_ShadowResolutionRequestCounter; + Material m_ClearShadowMaterial; + private static HDShadowManager s_Instance = new HDShadowManager(); public static HDShadowManager instance { get { return s_Instance; } } @@ -268,7 +270,7 @@ private HDShadowManager() public void InitShadowManager(RenderPipelineResources renderPipelineResources, DepthBits directionalShadowDepthBits, HDShadowInitParameters.HDShadowAtlasInitParams punctualLightAtlasInfo, HDShadowInitParameters.HDShadowAtlasInitParams areaLightAtlasInfo, int maxShadowRequests, Shader clearShader) { - Material clearMaterial = CoreUtils.CreateEngineMaterial(clearShader); + m_ClearShadowMaterial = CoreUtils.CreateEngineMaterial(clearShader); // Prevent the list from resizing their internal container when we add shadow requests m_ShadowDatas.Capacity = Math.Max(maxShadowRequests, m_ShadowDatas.Capacity); @@ -282,13 +284,13 @@ public void InitShadowManager(RenderPipelineResources renderPipelineResources, D } // The cascade atlas will be allocated only if there is a directional light - m_Atlas = new HDShadowAtlas(renderPipelineResources, punctualLightAtlasInfo.shadowAtlasResolution, punctualLightAtlasInfo.shadowAtlasResolution, HDShaderIDs._ShadowmapAtlas, HDShaderIDs._ShadowAtlasSize, clearMaterial, maxShadowRequests, depthBufferBits: punctualLightAtlasInfo.shadowAtlasDepthBits, name: "Shadow Map Atlas"); + m_Atlas = new HDShadowAtlas(renderPipelineResources, punctualLightAtlasInfo.shadowAtlasResolution, punctualLightAtlasInfo.shadowAtlasResolution, HDShaderIDs._ShadowmapAtlas, HDShaderIDs._ShadowAtlasSize, m_ClearShadowMaterial, maxShadowRequests, depthBufferBits: punctualLightAtlasInfo.shadowAtlasDepthBits, name: "Shadow Map Atlas"); // Cascade atlas render texture will only be allocated if there is a shadow casting directional light HDShadowAtlas.BlurAlgorithm cascadeBlur = GetDirectionalShadowAlgorithm() == DirectionalShadowAlgorithm.IMS ? HDShadowAtlas.BlurAlgorithm.IM : HDShadowAtlas.BlurAlgorithm.None; - m_CascadeAtlas = new HDShadowAtlas(renderPipelineResources, 1, 1, HDShaderIDs._ShadowmapCascadeAtlas, HDShaderIDs._CascadeShadowAtlasSize, clearMaterial, maxShadowRequests, cascadeBlur, depthBufferBits: directionalShadowDepthBits, name: "Cascade Shadow Map Atlas"); + m_CascadeAtlas = new HDShadowAtlas(renderPipelineResources, 1, 1, HDShaderIDs._ShadowmapCascadeAtlas, HDShaderIDs._CascadeShadowAtlasSize, m_ClearShadowMaterial, maxShadowRequests, cascadeBlur, depthBufferBits: directionalShadowDepthBits, name: "Cascade Shadow Map Atlas"); if (ShaderConfig.s_AreaLights == 1) - m_AreaLightShadowAtlas = new HDShadowAtlas(renderPipelineResources, areaLightAtlasInfo.shadowAtlasResolution, areaLightAtlasInfo.shadowAtlasResolution, HDShaderIDs._AreaLightShadowmapAtlas, HDShaderIDs._AreaShadowAtlasSize, clearMaterial, maxShadowRequests, HDShadowAtlas.BlurAlgorithm.EVSM, depthBufferBits: areaLightAtlasInfo.shadowAtlasDepthBits, name: "Area Light Shadow Map Atlas", momentAtlasShaderID: HDShaderIDs._AreaShadowmapMomentAtlas); + m_AreaLightShadowAtlas = new HDShadowAtlas(renderPipelineResources, areaLightAtlasInfo.shadowAtlasResolution, areaLightAtlasInfo.shadowAtlasResolution, HDShaderIDs._AreaLightShadowmapAtlas, HDShaderIDs._AreaShadowAtlasSize, m_ClearShadowMaterial, maxShadowRequests, HDShadowAtlas.BlurAlgorithm.EVSM, depthBufferBits: areaLightAtlasInfo.shadowAtlasDepthBits, name: "Area Light Shadow Map Atlas", momentAtlasShaderID: HDShaderIDs._AreaShadowmapMomentAtlas); m_ShadowDataBuffer = new ComputeBuffer(maxShadowRequests, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDShadowData))); m_DirectionalShadowDataBuffer = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDDirectionalShadowData))); @@ -822,6 +824,8 @@ public void Dispose() if (ShaderConfig.s_AreaLights == 1) m_AreaLightShadowAtlas.Release(); m_CascadeAtlas.Release(); + + CoreUtils.Destroy(m_ClearShadowMaterial); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 1f419daff06..b90037944c2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -269,6 +269,8 @@ public void Cleanup() RTHandles.Release(m_InternalLogLut); CoreUtils.Destroy(m_FinalPassMaterial); CoreUtils.Destroy(m_ClearBlackMaterial); + CoreUtils.Destroy(m_SMAAMaterial); + CoreUtils.Destroy(m_TemporalAAMaterial); CoreUtils.SafeRelease(m_BokehNearKernel); CoreUtils.SafeRelease(m_BokehFarKernel); CoreUtils.SafeRelease(m_BokehIndirectCmd); @@ -285,6 +287,8 @@ public void Cleanup() m_InternalLogLut = null; m_FinalPassMaterial = null; m_ClearBlackMaterial = null; + m_SMAAMaterial = null; + m_TemporalAAMaterial = null; m_BokehNearKernel = null; m_BokehFarKernel = null; m_BokehIndirectCmd = null; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 01125b2863d..00f371f12f6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -940,6 +940,8 @@ void DisposeProbeCameraPool() } CameraCaptureBridge.enabled = false; + + HDUtils.ReleaseComponentSingletons(); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs index d16186a2d52..f413e1df6ad 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MipGenerator.cs @@ -39,6 +39,8 @@ public void Release() RTHandles.Release(m_TempDownsamplePyramid[i]); m_TempDownsamplePyramid[i] = null; } + + CoreUtils.Destroy(m_ColorPyramidPSMat); } private int tmpTargetCount @@ -222,4 +224,4 @@ public int RenderColorGaussianPyramid(CommandBuffer cmd, Vector2Int size, Textur return srcMipLevel + 1; } } -} \ No newline at end of file +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs index b6001e50768..fc6c7378698 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/HDUtils.cs @@ -24,7 +24,7 @@ public class HDUtils static internal HDAdditionalLightData s_DefaultHDAdditionalLightData { get { return ComponentSingleton.instance; } } /// Default HDAdditionalCameraData static internal HDAdditionalCameraData s_DefaultHDAdditionalCameraData { get { return ComponentSingleton.instance; } } - + static List m_TempCustomPassVolumeList = new List(); static Texture3D m_ClearTexture3D; @@ -473,7 +473,7 @@ internal static RenderPipelineAsset SwitchToBuiltinRenderPipeline(out bool asset } // Set the renderPipelineAsset, either on the quality settings if it was unset from there or in GraphicsSettings. - // IMPORTANT: RenderPipelineManager.currentPipeline won't be HDRP until a camera.Render() call is made. + // IMPORTANT: RenderPipelineManager.currentPipeline won't be HDRP until a camera.Render() call is made. internal static void RestoreRenderPipelineAsset(bool wasUnsetFromQuality, RenderPipelineAsset renderPipelineAsset) { if(wasUnsetFromQuality) @@ -1002,6 +1002,13 @@ internal static void DisplayUnsupportedAPIMessage(string graphicAPI = null) DisplayUnsupportedMessage(msg); } + internal static void ReleaseComponentSingletons() + { + ComponentSingleton.Release(); + ComponentSingleton.Release(); + ComponentSingleton.Release(); + } + internal static void DisplayUnsupportedXRMessage() { string msg = "AR/VR devices are not supported, no rendering will occur"; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs index a9f1a4b69e7..6c206f55888 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs @@ -32,7 +32,7 @@ public enum PbrSkyConfig static ComputeShader s_GroundIrradiancePrecomputationCS; static ComputeShader s_InScatteredRadiancePrecomputationCS; - static Material s_PbrSkyMaterial; + Material s_PbrSkyMaterial; static MaterialPropertyBlock s_PbrSkyMaterialProperties; static GraphicsFormat s_ColorFormat = GraphicsFormat.R16G16B16A16_SFloat; @@ -80,8 +80,7 @@ public override void Build() s_InScatteredRadiancePrecomputationCS = hdrpResources.shaders.inScatteredRadiancePrecomputationCS; s_PbrSkyMaterialProperties = new MaterialPropertyBlock(); - if (s_PbrSkyMaterial == null) // Material instance is static. - s_PbrSkyMaterial = CoreUtils.CreateEngineMaterial(hdrpResources.shaders.physicallyBasedSkyPS); + s_PbrSkyMaterial = CoreUtils.CreateEngineMaterial(hdrpResources.shaders.physicallyBasedSkyPS); Debug.Assert(s_GroundIrradiancePrecomputationCS != null); Debug.Assert(s_InScatteredRadiancePrecomputationCS != null); @@ -126,6 +125,8 @@ public override void Cleanup() RTHandles.Release(m_InScatteredRadianceTables[3]); m_InScatteredRadianceTables[3] = null; RTHandles.Release(m_InScatteredRadianceTables[4]); m_InScatteredRadianceTables[4] = null; + CoreUtils.Destroy(s_PbrSkyMaterial); + m_LastPrecomputedBounce = 0; } From 359afb499c61071006fd5dcbc268b5a989320f0e Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Wed, 15 Apr 2020 12:55:11 +0200 Subject: [PATCH 11/81] [7.x.x backport] Follow references when deleting unloading unused assets on shader graph save (case 1230996) (#128) * Follow references when unloading unneeded assets * changelog Co-authored-by: sebastienlagarde --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/AssetProcessors/ShaderGraphMaterialsUpdater.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index f6b0b47887d..96b07dec894 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for range compression factor for probes going negative (now clamped to positive values). - Fixed path validation when creating new volume profile (case 1229933) - Fixed various object leaks in HDRP. +- Fix for assertion triggering sometimes when saving a newly created lit shader graph (case 1230996) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/ShaderGraphMaterialsUpdater.cs b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/ShaderGraphMaterialsUpdater.cs index 3a3f94a9084..770e36cd1ef 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/ShaderGraphMaterialsUpdater.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/ShaderGraphMaterialsUpdater.cs @@ -55,13 +55,13 @@ static void OnShaderGraphSaved(Shader shader, object saveContext) // Free the materials every 200 iterations, on big project loading all materials in memory can lead to a crash if ((i % 200 == 0) && i != 0) - EditorUtility.UnloadUnusedAssetsImmediate(false); + EditorUtility.UnloadUnusedAssetsImmediate(true); } } finally { EditorUtility.ClearProgressBar(); - EditorUtility.UnloadUnusedAssetsImmediate(false); + EditorUtility.UnloadUnusedAssetsImmediate(true); } } } From 9993a1cc1944425b032eeb2ba0023734cd5aa0e4 Mon Sep 17 00:00:00 2001 From: anisunity <42026998+anisunity@users.noreply.github.com> Date: Thu, 16 Apr 2020 10:19:22 +0200 Subject: [PATCH 12/81] [7.x.x Backport] Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). (#21) * Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). * update ssr screenshot Co-authored-by: sebastienlagarde --- .../Linear/WindowsEditor/Direct3D11/2551_SSR.png | 4 ++-- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Material/Lit/Lit.hlsl | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2551_SSR.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2551_SSR.png index 76b6f8cc094..11d290bcef7 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2551_SSR.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/2551_SSR.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f1ce98030ef6df4810de3d39dbb963c8b53137597ba47f47fb628c51dbf89ea9 -size 147472 +oid sha256:235f591a18ba1f53e0144f5996fcfb91b3a2704ae65459618ece20bafcffd284 +size 146936 diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 96b07dec894..5573fe9c090 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed path validation when creating new volume profile (case 1229933) - Fixed various object leaks in HDRP. - Fix for assertion triggering sometimes when saving a newly created lit shader graph (case 1230996) +- Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index d4dcfc77194..7da9be1d3ed 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -1710,7 +1710,12 @@ IndirectLighting EvaluateBSDF_ScreenSpaceReflection(PositionInputs posInput, ApplyScreenSpaceReflectionWeight(ssrLighting); // TODO: we should multiply all indirect lighting by the FGD value only ONCE. - lighting.specularReflected = ssrLighting.rgb * preLightData.specularFGD; + // In case this material has a clear coat, we shou not be using the specularFGD. The condition for it is a combination + // of a materia feature and the coat mask. + float clampedNdotV = ClampNdotV(preLightData.NdotV); + lighting.specularReflected = ssrLighting.rgb * (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) ? + lerp(preLightData.specularFGD, F_Schlick(CLEAR_COAT_F0, clampedNdotV), bsdfData.coatMask) + : preLightData.specularFGD); reflectionHierarchyWeight = ssrLighting.a; return lighting; From f4c7b7f262cfbc08e0f13d0690301dc012ef1108 Mon Sep 17 00:00:00 2001 From: Adrien de Tocqueville Date: Tue, 14 Apr 2020 12:57:05 +0200 Subject: [PATCH 13/81] d Fix MSAA resolve when there is no motion vectors #1 --- .../CHANGELOG.md | 3 +- .../Runtime/Material/SharedRTManager.cs | 32 +++++++++++++------ .../RenderPass/MSAA/DepthValues.shader | 13 ++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 5573fe9c090..45cffff074e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -42,7 +42,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed various object leaks in HDRP. - Fix for assertion triggering sometimes when saving a newly created lit shader graph (case 1230996) - Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). - +- Fixed MSAA depth resolve when there is no motion vectors + ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. - Renamed "Environment" to "Reflection Probes" in tile/cluster debug menu. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs index f9b4a7f732b..4c261ced47d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs @@ -94,6 +94,8 @@ public void InitSharedBuffers(GBufferManager gbufferManager, RenderPipelineSetti // Create the required resolve materials m_DepthResolveMaterial = CoreUtils.CreateEngineMaterial(resources.shaders.depthValuesPS); m_ColorResolveMaterial = CoreUtils.CreateEngineMaterial(resources.shaders.colorResolvePS); + + CoreUtils.SetKeyword(m_DepthResolveMaterial, "_HAS_MOTION_VECTORS", m_MotionVectorsSupport); } AllocateCoarseStencilBuffer(RTHandles.maxWidth, RTHandles.maxHeight, TextureXR.slices); @@ -342,18 +344,30 @@ public void ResolveSharedRT(CommandBuffer cmd, HDCamera hdCamera) Debug.Assert(m_MSAASupported); using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ResolveMSAADepth))) { - // Grab the RTIs and set the output render targets - m_RTIDs3[0] = m_CameraDepthValuesBuffer.nameID; - m_RTIDs3[1] = m_NormalRT.nameID; - m_RTIDs3[2] = m_MotionVectorsRT.nameID; - CoreUtils.SetRenderTarget(cmd, m_RTIDs3, m_CameraDepthStencilBuffer); - - // Set the input textures + if (m_MotionVectorsSupport) + { + // Grab the RTIs and set the output render targets + m_RTIDs3[0] = m_CameraDepthValuesBuffer.nameID; + m_RTIDs3[1] = m_NormalRT.nameID; + m_RTIDs3[2] = m_MotionVectorsRT.nameID; + CoreUtils.SetRenderTarget(cmd, m_RTIDs3, m_CameraDepthStencilBuffer); + + // Set the motion vector input texture + Shader.SetGlobalTexture(HDShaderIDs._MotionVectorTextureMS, m_MotionVectorsMSAART); + } + else + { + // Grab the RTIs and set the output render targets + m_RTIDs2[0] = m_CameraDepthValuesBuffer.nameID; + m_RTIDs2[1] = m_NormalRT.nameID; + CoreUtils.SetRenderTarget(cmd, m_RTIDs2, m_CameraDepthStencilBuffer); + } + + // Set the depth and normal input textures Shader.SetGlobalTexture(HDShaderIDs._NormalTextureMS, m_NormalMSAART); Shader.SetGlobalTexture(HDShaderIDs._DepthTextureMS, m_DepthAsColorMSAART); - Shader.SetGlobalTexture(HDShaderIDs._MotionVectorTextureMS, m_MotionVectorsMSAART); - // Resolve the depth and normal buffers + // Resolve the buffers cmd.DrawProcedural(Matrix4x4.identity, m_DepthResolveMaterial, SampleCountToPassIndex(m_MSAASamples), MeshTopology.Triangles, 3, 1); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/DepthValues.shader b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/DepthValues.shader index 219e122d14c..d835b39de48 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/DepthValues.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/DepthValues.shader @@ -3,6 +3,7 @@ Shader "Hidden/HDRP/DepthValues" HLSLINCLUDE #pragma target 4.5 #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch + #pragma multi_compile _ _HAS_MOTION_VECTORS #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" // #pragma enable_d3d11_debug_symbols @@ -10,7 +11,9 @@ Shader "Hidden/HDRP/DepthValues" // Target multisampling textures TEXTURE2D_X_MSAA(float, _DepthTextureMS); TEXTURE2D_X_MSAA(float4, _NormalTextureMS); + #ifdef _HAS_MOTION_VECTORS TEXTURE2D_X_MSAA(float2, _MotionVectorTextureMS); + #endif struct Attributes { @@ -29,7 +32,9 @@ Shader "Hidden/HDRP/DepthValues" { float4 depthValues : SV_Target0; float4 normal : SV_Target1; + #ifdef _HAS_MOTION_VECTORS float2 motionVectors : SV_Target2; + #endif float actualDepth : SV_Depth; }; @@ -51,7 +56,9 @@ Shader "Hidden/HDRP/DepthValues" float depthVal = LOAD_TEXTURE2D_X_MSAA(_DepthTextureMS, pixelCoords, 0).x; fragO.depthValues = float4(depthVal, depthVal, depthVal, 0.0f); fragO.normal = LOAD_TEXTURE2D_X_MSAA(_NormalTextureMS, pixelCoords, 0); + #ifdef _HAS_MOTION_VECTORS fragO.motionVectors = LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, 0); + #endif fragO.actualDepth = fragO.depthValues.x; return fragO; } @@ -77,8 +84,10 @@ Shader "Hidden/HDRP/DepthValues" fragO.depthValues.z *= 0.5; fragO.actualDepth = fragO.depthValues.x; fragO.normal = LOAD_TEXTURE2D_X_MSAA(_NormalTextureMS, pixelCoords, 0); + #ifdef _HAS_MOTION_VECTORS // We pick the closest sample to camera, not really a great solution, but resolving motion vectors is ill defined. fragO.motionVectors = LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, closestSample); + #endif return fragO; } @@ -103,8 +112,10 @@ Shader "Hidden/HDRP/DepthValues" fragO.depthValues.z *= 0.25; fragO.actualDepth = fragO.depthValues.x; fragO.normal = LOAD_TEXTURE2D_X_MSAA(_NormalTextureMS, pixelCoords, 0); + #ifdef _HAS_MOTION_VECTORS // We pick the closest sample to camera, not really a great solution, but resolving motion vectors is ill defined. fragO.motionVectors = LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, closestSample); + #endif return fragO; } @@ -129,8 +140,10 @@ Shader "Hidden/HDRP/DepthValues" fragO.depthValues.z *= 0.125; fragO.actualDepth = fragO.depthValues.x; fragO.normal = LOAD_TEXTURE2D_X_MSAA(_NormalTextureMS, pixelCoords, 0); + #ifdef _HAS_MOTION_VECTORS // We pick the closest sample to camera, not really a great solution, but resolving motion vectors is ill defined. fragO.motionVectors = LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, closestSample); + #endif return fragO; } ENDHLSL From 8cb689f6a832be48597034efd76f6c580a5cad89 Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:08:38 +0200 Subject: [PATCH 14/81] Fix issues causing planar probes to be broken with multiple cameras in the scene #4 --- .../CHANGELOG.md | 1 + .../Runtime/Lighting/Reflection/HDProbe.cs | 11 +++- .../RenderPipeline/HDRenderPipeline.cs | 52 +++++++++++++++---- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 45cffff074e..bbb7efb745f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix for assertion triggering sometimes when saving a newly created lit shader graph (case 1230996) - Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). - Fixed MSAA depth resolve when there is no motion vectors +- Fix issue causing wrong planar reflection rendering when more than one camera is present. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. 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 9704c75d253..d7acda444b7 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 @@ -248,7 +248,11 @@ public Texture SetTexture(ProbeSettings.Mode targetMode, Texture texture) /// public RenderData renderData => GetRenderData(mode); /// - /// Get the render data of a specific mode + /// Get the render data of a specific mode. + /// + /// Note: The HDProbe stores only one RenderData per mode, even for view dependent probes with multiple viewers. + /// In that case, make sure that you have set the RenderData relative to the expected viewer before rendering. + /// Otherwise the data retrieved by this function will be wrong. /// /// The mode to query /// The requested render data @@ -264,7 +268,10 @@ public RenderData GetRenderData(ProbeSettings.Mode targetMode) } } /// - /// Set the render data for a specific mode + /// Set the render data for a specific mode. + /// + /// Note: The HDProbe stores only one RenderData per mode, even for view dependent probes with multiple viewers. + /// In that case, make sure that you have set the RenderData relative to the expected viewer before rendering. /// /// The mode to update /// The data to set diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 00f371f12f6..95ef43699c3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1149,6 +1149,7 @@ public struct Target // Indices of render request to render before this one public List dependsOnRenderRequestIndices; public CameraSettings cameraSettings; + public List<(HDProbe.RenderData, HDProbe)> viewDependentProbesData; } struct HDCullingResults { @@ -1368,7 +1369,8 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c }, dependsOnRenderRequestIndices = ListPool.Get(), index = renderRequests.Count, - cameraSettings = CameraSettings.From(hdCamera) + cameraSettings = CameraSettings.From(hdCamera), + viewDependentProbesData = ListPool<(HDProbe.RenderData, HDProbe)>.Get() // TODO: store DecalCullResult }; renderRequests.Add(request); @@ -1452,6 +1454,8 @@ float ComputeVisibility(int visibleInIndex, HDProbe visibleProbe) parentCamera = visibleInRenderRequest.hdCamera.camera; + var renderDatas = ListPool.Get(); + AddHDProbeRenderRequests( visibleProbe, viewerTransform, @@ -1459,8 +1463,16 @@ float ComputeVisibility(int visibleInIndex, HDProbe visibleProbe) HDUtils.GetSceneCullingMaskFromCamera(visibleInRenderRequest.hdCamera.camera), parentCamera, visibleInRenderRequest.hdCamera.camera.fieldOfView, - visibleInRenderRequest.hdCamera.camera.aspect + visibleInRenderRequest.hdCamera.camera.aspect, + ref renderDatas ); + + foreach (var renderData in renderDatas) + { + visibleInRenderRequest.viewDependentProbesData.Add((renderData, visibleProbe)); + } + + ListPool.Release(renderDatas); } } else @@ -1475,7 +1487,11 @@ float ComputeVisibility(int visibleInIndex, HDProbe visibleProbe) visibleInOneViewer = true; } if (visibleInOneViewer) - AddHDProbeRenderRequests(visibleProbe, null, visibilities, 0, parentCamera); + { + var renderDatas = ListPool.Get(); + AddHDProbeRenderRequests(visibleProbe, null, visibilities, 0, parentCamera, referenceFieldOfView: 90, referenceAspect: 1, ref renderDatas); + ListPool.Release(renderDatas); + } } } foreach (var pair in renderRequestIndicesWhereTheProbeIsVisible) @@ -1489,8 +1505,9 @@ void AddHDProbeRenderRequests( List<(int index, float weight)> visibilities, ulong overrideSceneCullingMask, Camera parentCamera, - float referenceFieldOfView = 90, - float referenceAspect = 1 + float referenceFieldOfView, + float referenceAspect, + ref List renderDatas ) { var position = ProbeCapturePositionSettings.ComputeFrom( @@ -1589,16 +1606,20 @@ ref _cullingResults if (!visibleProbe.realtimeTexture.IsCreated()) visibleProbe.realtimeTexture.Create(); - visibleProbe.SetRenderData( - ProbeSettings.Mode.Realtime, - new HDProbe.RenderData( + var renderData = new HDProbe.RenderData( camera.worldToCameraMatrix, camera.projectionMatrix, camera.transform.position, camera.transform.rotation, cameraSettings[j].frustum.fieldOfView, cameraSettings[j].frustum.aspect - ) + ); + + renderDatas.Add(renderData); + + visibleProbe.SetRenderData( + ProbeSettings.Mode.Realtime, + renderData ); // TODO: Assign the actual final target to render to. @@ -1615,7 +1636,8 @@ ref _cullingResults clearCameraSettings = true, dependsOnRenderRequestIndices = ListPool.Get(), index = renderRequests.Count, - cameraSettings = cameraSettings[j] + cameraSettings = cameraSettings[j], + viewDependentProbesData = ListPool<(HDProbe.RenderData, HDProbe)>.Get() // TODO: store DecalCullResult }; @@ -1738,6 +1760,15 @@ ref _cullingResults target.id = m_TemporaryTargetForCubemaps; } + // The HDProbe store only one RenderData per probe, however RenderData can be view dependent (e.g. planar probes). + // To avoid that the render data for the wrong view is used, we previously store a copy of the render data + // for each viewer and we are going to set it on the probe right before said viewer is rendered. + foreach (var probeDataPair in renderRequest.viewDependentProbesData) + { + var probe = probeDataPair.Item2; + var probeRenderData = probeDataPair.Item1; + probe.SetRenderData(ProbeSettings.Mode.Realtime, probeRenderData); + } // var aovRequestIndex = 0; foreach (var aovRequest in renderRequest.hdCamera.aovRequests) @@ -1777,6 +1808,7 @@ ref _cullingResults renderRequest.hdCamera.camera.targetTexture = null; ListPool.Release(renderRequest.dependsOnRenderRequestIndices); + ListPool<(HDProbe.RenderData, HDProbe)>.Release(renderRequest.viewDependentProbesData); // Culling results can be shared between render requests: clear only when required if (!skipClearCullingResults.Contains(renderRequest.index)) From 7d010f4dcfc09b1a1fced0964b195db8b44394c0 Mon Sep 17 00:00:00 2001 From: slunity <37302815+slunity@users.noreply.github.com> Date: Wed, 8 Apr 2020 08:09:39 -0400 Subject: [PATCH 15/81] Pospow and SG triplanar fix #40 --- .../ShaderLibrary/Common.hlsl | 45 +++++++++++++++++++ com.unity.shadergraph/CHANGELOG.md | 1 + .../Documentation~/Triplanar-Node.md | 2 +- .../Editor/Data/Nodes/UV/TriplanarNode.cs | 14 +++++- 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl index 43eb4f8b722..60449601be5 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl @@ -499,6 +499,51 @@ uint FastLog2(uint x) // Note: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509636(v=vs.85).aspx pow(0, >0) == 0 TEMPLATE_2_REAL(PositivePow, base, power, return pow(abs(base), power)) +// SafePositivePow: Same as pow(x,y) but considers x always positive and never exactly 0 such that +// SafePositivePow(0,y) will numerically converge to 1 as y -> 0, including SafePositivePow(0,0) returning 1. +// +// First, like PositivePow, SafePositivePow removes this warning for when you know the x value is positive or 0 and you know +// you avoid a NaN: +// ie you know that x == 0 and y > 0, such that pow(x,y) == pow(0, >0) == 0 +// SafePositivePow(0, y) will however return close to 1 as y -> 0, see below. +// +// Also, pow(x,y) is most probably approximated as exp2(log2(x) * y), so pow(0,0) will give exp2(-inf * 0) == exp2(NaN) == NaN. +// +// SafePositivePow avoids NaN in allowing SafePositivePow(x,y) where (x,y) == (0,y) for any y including 0 by clamping x to a +// minimum of FLT_EPS. The consequences are: +// +// -As a replacement for pow(0,y) where y >= 1, the result of SafePositivePow(x,y) should be close enough to 0. +// -For cases where we substitute for pow(0,y) where 0 < y < 1, SafePositivePow(x,y) will quickly reach 1 as y -> 0, while +// normally pow(0,y) would give 0 instead of 1 for all 0 < y. +// eg: if we #define FLT_EPS 5.960464478e-8 (for fp32), +// SafePositivePow(0, 0.1) = 0.1894646 +// SafePositivePow(0, 0.01) = 0.8467453 +// SafePositivePow(0, 0.001) = 0.9835021 +// +// Depending on the intended usage of pow(), this difference in behavior might be a moot point since: +// 1) by leaving "y" free to get to 0, we get a NaNs +// 2) the behavior of SafePositivePow() has more continuity when both x and y get closer together to 0, since +// when x is assured to be positive non-zero, pow(x,x) -> 1 as x -> 0. +// +// TL;DR: SafePositivePow(x,y) avoids NaN and is safe for positive (x,y) including (x,y) == (0,0), +// but SafePositivePow(0, y) will return close to 1 as y -> 0, instead of 0, so watch out +// for behavior depending on pow(0, y) giving always 0, especially for 0 < y < 1. +// +// Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/bb509636(v=vs.85).aspx +TEMPLATE_2_REAL(SafePositivePow, base, power, return pow(max(abs(base), real(REAL_EPS)), power)) + +// Helpers for making shadergraph functions consider precision spec through the same $precision token used for variable types +TEMPLATE_2_FLT(SafePositivePow_float, base, power, return pow(max(abs(base), float(FLT_EPS)), power)) +TEMPLATE_2_HALF(SafePositivePow_half, base, power, return pow(max(abs(base), half(HALF_EPS)), power)) + +float Eps_float() { return FLT_EPS; } +float Min_float() { return FLT_MIN; } +float Max_float() { return FLT_MAX; } +half Eps_half() { return HALF_EPS; } +half Min_half() { return HALF_MIN; } +half Max_half() { return HALF_MAX; } + + // Composes a floating point value with the magnitude of 'x' and the sign of 's'. // See the comment about FastSign() below. float CopySign(float x, float s, bool ignoreNegZero = true) diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index 220dae52178..ec555002f54 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a bug where fog density node always returns 0 in the shader preview window when connected to an Unlit Master node. - Fixed a bug with the `Transform` node where converting from `Absolute World` space in a sub graph causes invalid subscript errors. [1190813](https://issuetracker.unity3d.com/issues/shadergraph-invalid-subscript-errors-are-thrown-when-connecting-a-subgraph-with-transform-node-with-unlit-master-node) - Optimized loading a large Shader Graph. [1209047](https://issuetracker.unity3d.com/issues/shader-graph-unresponsive-editor-when-using-large-graphs) +- Fixed NaN issue in triplanar SG node when blend goes to 0. ## [7.2.0] - 2020-02-10 diff --git a/com.unity.shadergraph/Documentation~/Triplanar-Node.md b/com.unity.shadergraph/Documentation~/Triplanar-Node.md index 32a633197be..7f385ac8d58 100644 --- a/com.unity.shadergraph/Documentation~/Triplanar-Node.md +++ b/com.unity.shadergraph/Documentation~/Triplanar-Node.md @@ -2,7 +2,7 @@ ## Description -Triplanar is a method of generating UVs and sampling a texture by projecting in world space. The input **Texture** is sampled 3 times, once in each of the world x, y and z axises, and the resulting information is planar projected onto the model, blended by the normal, or surface angle. The generated UVs can be scaled with the input **Tile** and the final blending strength can be controlled with the input **Blend**. The projection can be modified by overriding the inputs **Position** and **Normal**. This is commonly used to texture large models such as terrain, where hand authoring UV coordinates would be problematic or not performant. +Triplanar is a method of generating UVs and sampling a texture by projecting in world space. The input **Texture** is sampled 3 times, once in each of the world x, y and z axes, and the resulting information is planar projected onto the model, blended by the normal, or surface angle. The generated UVs can be scaled with the input **Tile** and the final blending strength can be controlled with the input **Blend**. **Blend** controls the way the normal affects the blending of each plane sample and should be greater or equal to 0. The larger **blend** is, the more contribution will be given to the sample from the plane towards which the normal is most oriented. (The maximum blend exponent is between 17 and 158 depending on platform and the precision of the node.) A blend of 0 makes each plane get equal weight regardless of normal orientation. The projection can be modified by overriding the inputs **Position** and **Normal**. This is commonly used to texture large models such as terrain, where hand authoring UV coordinates would be problematic or not performant. The expected type of the input **Texture** can be switched with the dropdown **Type**. If set to **Normal** the normals will be converted into world space so new tangents can be constructed then converted back to tangent space before output. diff --git a/com.unity.shadergraph/Editor/Data/Nodes/UV/TriplanarNode.cs b/com.unity.shadergraph/Editor/Data/Nodes/UV/TriplanarNode.cs index 4686c5b36d1..824d156538c 100644 --- a/com.unity.shadergraph/Editor/Data/Nodes/UV/TriplanarNode.cs +++ b/com.unity.shadergraph/Editor/Data/Nodes/UV/TriplanarNode.cs @@ -92,7 +92,8 @@ public virtual void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode gene // Whiteout blend method // https://medium.com/@bgolus/normal-mapping-for-a-triplanar-shader-10bf39dca05a case TextureType.Normal: - sb.AppendLine("$precision3 {0}_Blend = max(pow(abs({1}), {2}), 0);" + // See comment for default case. + sb.AppendLine("$precision3 {0}_Blend = SafePositivePow_$precision({1}, min({2}, floor(log2(Min_$precision())/log2(1/sqrt(3)))) );" , GetVariableNameForNode() , GetSlotValue(NormalInputId, generationMode) , GetSlotValue(BlendInputId, generationMode)); @@ -134,7 +135,16 @@ public virtual void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode gene , GetVariableNameForNode()); break; default: - sb.AppendLine("$precision3 {0}_Blend = pow(abs({1}), {2});" + // We want the sum of the 3 blend weights (by which we normalize them) to be > 0. + // Max safe exponent is log2(REAL_MIN)/log2(1/sqrt(3)): + // Take the set of all possible normalized vectors, make a set from selecting the maximum component of each 3-vectors from the previous set, + // the minimum (:= min_of_max) of that new set is 1/sqrt(3) (by the fact vectors are normalized). + // We then want a maximum exponent such that + // precision_min < min_of_max^exponent_max + // where exponent_max is blend, + // log(precision_min) < log(min_of_max) * exponent_max + // log(precision_min) / log(min_of_max) > exponent_max + sb.AppendLine("$precision3 {0}_Blend = SafePositivePow_$precision({1}, min({2}, floor(log2(Min_$precision())/log2(1/sqrt(3)))) );" , GetVariableNameForNode() , GetSlotValue(NormalInputId, generationMode) , GetSlotValue(BlendInputId, generationMode)); From 4410bd115f949de806ddcc402feb9472efc50e80 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Thu, 9 Apr 2020 11:36:20 +0200 Subject: [PATCH 16/81] Hdrp/fix/custom pass msaa rendering info #42 --- .../CHANGELOG.md | 1 + .../DrawRenderersCustomPassDrawer.cs | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index bbb7efb745f..c8a35b8b242 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - Add XR setting to control camera jitter for temporal effects #6259 - Added an error message in the DrawRenderers custom pass when rendering opaque objects with an HDRP asset in DeferredOnly mode. +- Added an info box to warn about depth test artifacts when rendering object twice in custom passes with MSAA. ### Fixed - Fixed an issue where a dynamic sky changing any frame may not update the ambient probe. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs index 63d835a7615..0d28dd585c9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs @@ -56,10 +56,11 @@ private class Styles public static string unlitShaderMessage = "HDRP Unlit shaders will force the shader passes to \"ForwardOnly\""; public static string hdrpLitShaderMessage = "HDRP Lit shaders are not supported in a custom pass"; public static string opaqueObjectWithDeferred = "Your HDRP settings does not support ForwardOnly, some object might not render."; + public static string objectRendererTwiceWithMSAA = "MSAA is enabled, re-rendering same object twice will cause depth test artifacts in Before/After Post Process injection points"; } //Headers and layout - private int m_FilterLines = 3; + private int m_FilterLines = 2; private int m_MaterialLines = 2; // Foldouts @@ -86,6 +87,8 @@ private class Styles ReorderableList m_ShaderPassesList; + CustomPassVolume m_Volume; + bool customDepthIsNone => (CustomPass.TargetBuffer)m_TargetDepthBuffer.intValue == CustomPass.TargetBuffer.None; protected override void Initialize(SerializedProperty customPass) @@ -112,6 +115,8 @@ protected override void Initialize(SerializedProperty customPass) m_DepthCompareFunction = customPass.FindPropertyRelative("depthCompareFunction"); m_DepthWrite = customPass.FindPropertyRelative("depthWrite"); + m_Volume = customPass.serializedObject.targetObject as CustomPassVolume; + m_ShaderPassesList = new ReorderableList(null, m_ShaderPasses, true, true, true, true); m_ShaderPassesList.drawElementCallback = @@ -132,6 +137,14 @@ protected override void Initialize(SerializedProperty customPass) protected override void DoPassGUI(SerializedProperty customPass, Rect rect) { + if (ShowMsaaObjectInfo()) + { + Rect helpBoxRect = rect; + helpBoxRect.height = Styles.helpBoxHeight; + EditorGUI.HelpBox(helpBoxRect, Styles.objectRendererTwiceWithMSAA, MessageType.Info); + rect.y += Styles.helpBoxHeight; + } + DoFilters(ref rect); m_RendererFoldout.boolValue = EditorGUI.Foldout(rect, m_RendererFoldout.boolValue, Styles.renderHeader, true); @@ -156,7 +169,7 @@ protected override void DoPassGUI(SerializedProperty customPass, Rect rect) } } - // Tel if we need to show a warning for rendering opaque object and we're in deferred. + // Tell if we need to show a warning for rendering opaque object and we're in deferred. bool ShowOpaqueObjectWarning() { // Only opaque objects are concerned @@ -173,6 +186,18 @@ bool ShowOpaqueObjectWarning() return true; } + // Tell if we need to show the MSAA message info + bool ShowMsaaObjectInfo() + { + if (!HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.supportMSAA) + return false; + + if (m_Volume.injectionPoint != CustomPassInjectionPoint.AfterPostProcess && m_Volume.injectionPoint != CustomPassInjectionPoint.BeforePostProcess) + return false; + + return true; + } + void DoFilters(ref Rect rect) { m_FilterFoldout.boolValue = EditorGUI.Foldout(rect, m_FilterFoldout.boolValue, Styles.filtersHeader, true); @@ -296,9 +321,11 @@ protected override float GetPassHeight(SerializedProperty customPass) { float height = Styles.defaultLineSpace; + height += ShowMsaaObjectInfo() ? Styles.helpBoxHeight : 0; + if (m_FilterFoldout.boolValue) { - height *= m_FilterLines; + height += Styles.defaultLineSpace * m_FilterLines; height += ShowOpaqueObjectWarning() ? Styles.helpBoxHeight : 0; } From 67e7c738bb7ed9223d67d391615bdb4e2f91b2d7 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 9 Apr 2020 11:33:43 +0100 Subject: [PATCH 17/81] Added disocclusion and ghosting to the glossary (#75) --- .../Documentation~/Glossary.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md b/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md index 65bbdd53b8e..698fd6ac263 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Glossary.md @@ -137,3 +137,12 @@ A function that describes a wave that represents the human eye’s relative sens #### punctual lights: A light is considered to be punctual if it emits light from a single point. HDRPs Spot and Point Lights are punctual. +## Rendering Artifacts + + +#### disocclusion +A rendering artifact that describes the situation where a GameObject that was previously occluded becomes visible. + + +#### ghosting +A rendering artifact that describes the situation where a moving GameObject leaves a trail of pixels behind it. \ No newline at end of file From 6e624d2b2a02dd1f7973b0c7e8458729213f6749 Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Thu, 16 Apr 2020 10:40:10 +0200 Subject: [PATCH 18/81] Update the scripting API for FrameSettings, FrameSettingsOverrideMask and IBitArray (#110) --- .../Runtime/Utilities/BitArray.cs | 20 ++++---- .../RenderPipeline/Settings/FrameSettings.cs | 47 +++++++++---------- 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/com.unity.render-pipelines.core/Runtime/Utilities/BitArray.cs b/com.unity.render-pipelines.core/Runtime/Utilities/BitArray.cs index 252c36efed9..ad773481f85 100644 --- a/com.unity.render-pipelines.core/Runtime/Utilities/BitArray.cs +++ b/com.unity.render-pipelines.core/Runtime/Utilities/BitArray.cs @@ -9,35 +9,35 @@ namespace UnityEngine.Rendering /// public interface IBitArray { - /// Number of elements in the bit array. + /// Gets the capacity of this BitArray. This is the number of bits that are usable. uint capacity { get; } - /// True if all bits are 0. + /// Return `true` if all the bits of this BitArray are set to 0. Returns `false` otherwise. bool allFalse { get; } - /// True if all bits are 1. + /// Return `true` if all the bits of this BitArray are set to 1. Returns `false` otherwise. bool allTrue { get; } /// - /// Returns the state of the bit at a specific index. + /// An indexer that allows access to the bit at a given index. This provides both read and write access. /// /// Index of the bit. /// State of the bit at the provided index. bool this[uint index] { get; set; } - /// Returns the bit array in a human readable form. + /// Writes the bits in the array in a human-readable form. This is as a string of 0s and 1s packed by 8 bits. This is useful for debugging. string humanizedData { get; } /// - /// Bit-wise And operation. + /// Perform an AND bitwise operation between this BitArray and the one you pass into the function and return the result. Both BitArrays must have the same capacity. This will not change current BitArray values. /// - /// Bit array with which to the And operation. + /// BitArray with which to the And operation. /// The resulting bit array. IBitArray BitAnd(IBitArray other); /// - /// Bit-wise Or operation. + /// Perform an OR bitwise operation between this BitArray and the one you pass into the function and return the result. Both BitArrays must have the same capacity. This will not change current BitArray values. /// - /// Bit array with which to the Or operation. + /// BitArray with which to the Or operation. /// The resulting bit array. IBitArray BitOr(IBitArray other); /// - /// Invert the bit array. + /// Return the BitArray with every bit inverted. /// /// IBitArray BitNot(); 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 1bad98da64e..b0757bcbf66 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 @@ -318,7 +318,9 @@ public enum FrameSettingsField [DebuggerDisplay("{mask.humanizedData}")] public struct FrameSettingsOverrideMask { - /// Mask of overridden values. + /// Gets the underlying BitArray HDRP uses to store the override mask and thus specific which field is overridden or not. + /// Note: BitArray128 is implements IBitArray and therefore has the scripting API described below. It is recomended to use the interface as the exact BitArray con evolve from one version of the package to another as the we need more capacity here. + /// [SerializeField] public BitArray128 mask; } @@ -501,59 +503,54 @@ partial struct FrameSettings BitArray128 bitDatas; /// - /// if lodBiasMode == LODBiasMode.Fixed, then this value will overwrite QualitySettings.lodBias - /// if lodBiasMode == LODBiasMode.ScaleQualitySettings, then this value will scale QualitySettings.lodBias + /// If lodBiasMode is LODBiasMode.Fixed, then this value overwrites QualitySettings.lodBias. + /// If lodBiasMode is LODBiasMode.ScaleQualitySettings, then this value scales QualitySettings.lodBias. /// [SerializeField] public float lodBias; - /// Define how the QualitySettings.lodBias value is set. + /// Specifies how HDRP calculates QualitySettings.lodBias. [SerializeField] public LODBiasMode lodBiasMode; - /// The quality level to use when fetching the quality setting value. + /// The quality level the rendering component uses when it fetches the quality setting value. [SerializeField] public int lodBiasQualityLevel; /// - /// if maximumLODLevelMode == MaximumLODLevelMode.FromQualitySettings, then this value will overwrite QualitySettings.maximumLODLevel - /// if maximumLODLevelMode == MaximumLODLevelMode.OffsetQualitySettings, then this value will offset QualitySettings.maximumLODLevel + /// If maximumLODLevelMode is MaximumLODLevelMode.FromQualitySettings, then this value overwrites QualitySettings.maximumLODLevel + /// If maximumLODLevelMode is MaximumLODLevelMode.OffsetQualitySettings, then this value offsets QualitySettings.maximumLODLevel /// [SerializeField] public int maximumLODLevel; - /// Define how the QualitySettings.maximumLODLevel value is set. + /// Specifies how HDRP calculates QualitySettings.maximumLODLevel. [SerializeField] public MaximumLODLevelMode maximumLODLevelMode; - /// The quality level to use when fetching the quality setting value. + /// The maximum quality level the rendering component uses when it fetches the quality setting value. [SerializeField] public int maximumLODLevelQualityLevel; /// - /// The material quality level to use for this rendering. - /// if materialQuality == 0, then the material quality from the current quality settings - /// (in HDRP Asset) will be used. + /// The material quality level this rendering component uses. + /// If materialQuality == 0, the rendering component uses the material quality from the current quality settings in the HDRP Asset. /// public MaterialQuality materialQuality; - /// Helper to see binary saved data on LitShaderMode as a LitShaderMode enum. + /// Specifies the rendering path this rendering component uses. Here you can use the LitShaderMode enum to specify whether the rendering component uses forward or deferred rendering. public LitShaderMode litShaderMode { get => bitDatas[(uint)FrameSettingsField.LitShaderMode] ? LitShaderMode.Deferred : LitShaderMode.Forward; set => bitDatas[(uint)FrameSettingsField.LitShaderMode] = value == LitShaderMode.Deferred; } - /// - /// Get stored data for this field. - /// + /// Gets the stored override value for the passed in Frame Setting. Use this to access boolean values. /// Requested field. /// True if the field is enabled. public bool IsEnabled(FrameSettingsField field) => bitDatas[(uint)field]; - /// - /// Set stored data for this field. - /// + /// Sets the stored override value for the passed in Frame Setting. Use this to access boolean values. /// Requested field. /// State to set to the field. public void SetEnabled(FrameSettingsField field, bool value) => bitDatas[(uint)field] = value; /// - /// Compute the LOD bias value to use + /// Calculates the LOD bias value to use. /// /// The HDRP Assets to use /// The LOD Bias to use @@ -570,7 +567,7 @@ public float GetResolvedLODBias(HDRenderPipelineAsset hdrp) } /// - /// Compute the Maximum LOD level to use + /// Calculates the Maximum LOD level to use. /// /// The HDRP Asset to use /// The Maximum LOD level to use. @@ -732,7 +729,7 @@ internal static void AggregateFrameSettings(ref FrameSettings aggregatedFrameSet } /// - /// Equality operator. + /// Equality operator between two FrameSettings. Return `true` if equivalent. (comparison of content). /// /// First frame settings. /// Second frame settings. @@ -748,7 +745,7 @@ internal static void AggregateFrameSettings(ref FrameSettings aggregatedFrameSet && a.materialQuality == b.materialQuality; /// - /// Inequality operator. + /// Inequality operator between two FrameSettings. Return `true` if different. (comparison of content). /// /// First frame settings. /// Second frame settings. @@ -764,7 +761,7 @@ internal static void AggregateFrameSettings(ref FrameSettings aggregatedFrameSet || a.materialQuality != b.materialQuality; /// - /// Equality operator. + /// Equality operator between two FrameSettings. Return `true` if equivalent. (comparison of content). /// /// Frame Settings to compare to. /// True if both settings are equal. @@ -780,7 +777,7 @@ public override bool Equals(object obj) && materialQuality.Equals(((FrameSettings)obj).materialQuality); /// - /// Returns the hash code of the frame settings. + /// Returns the hash code of this object. /// /// Hash code of the frame settings. public override int GetHashCode() From bf34a59ba5cddf6f188d5cbf23123d0b397e0f97 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 14 Apr 2020 15:46:51 +0200 Subject: [PATCH 19/81] fix switch shader compilation (#111) --- .../Material/GGXConvolution/ComputeGgxIblSampleData.compute | 6 +++--- .../Runtime/Material/GGXConvolution/IBLFilterGGX.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/ComputeGgxIblSampleData.compute b/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/ComputeGgxIblSampleData.compute index 35ee3556f23..9da7381cebe 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/ComputeGgxIblSampleData.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/ComputeGgxIblSampleData.compute @@ -11,7 +11,7 @@ #define MAX_IBL_SAMPLE_CNT 89 #endif -RWTexture2D output; // [MAX_SAMPLE_CNT x UNITY_SPECCUBE_LOD_STEPS] +RWTexture2D outputResult; // [MAX_SAMPLE_CNT x UNITY_SPECCUBE_LOD_STEPS] #pragma kernel ComputeGgxIblSampleData @@ -33,7 +33,7 @@ void ComputeGgxIblSampleData(uint3 groupThreadId : SV_GroupThreadID) if (sampleIndex >= sampleCount) { - output[texCoord] = float4(0, 0, 0, 0); + outputResult[texCoord] = float4(0, 0, 0, 0); return; } @@ -82,6 +82,6 @@ void ComputeGgxIblSampleData(uint3 groupThreadId : SV_GroupThreadID) float pdf = 0.25 * D_GGX(NdotH, roughness); float omegaS = rcp(sampleCount) * rcp(pdf); - output[texCoord] = float4(localL, omegaS); + outputResult[texCoord] = float4(localL, omegaS); } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/IBLFilterGGX.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/IBLFilterGGX.cs index 1f3df886b42..5ef402930e4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/IBLFilterGGX.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/GGXConvolution/IBLFilterGGX.cs @@ -67,7 +67,7 @@ public override void Initialize(CommandBuffer cmd) void InitializeGgxIblSampleData(CommandBuffer cmd) { - m_ComputeGgxIblSampleDataCS.SetTexture(m_ComputeGgxIblSampleDataKernel, "output", m_GgxIblSampleData); + m_ComputeGgxIblSampleDataCS.SetTexture(m_ComputeGgxIblSampleDataKernel, "outputResult", m_GgxIblSampleData); cmd.DispatchCompute(m_ComputeGgxIblSampleDataCS, m_ComputeGgxIblSampleDataKernel, 1, 1, 1); } From 417b5d173eb27b679bb7cf516965561b50d70ee1 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Tue, 14 Apr 2020 17:59:03 +0200 Subject: [PATCH 20/81] Update SceneViewDrawMode.cs (#118) --- .../Runtime/RenderPipeline/SceneViewDrawMode.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs index 507732895d6..72613d64978 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs @@ -19,8 +19,7 @@ static private bool RejectDrawMode(SceneView.CameraMode cameraMode) cameraMode.drawMode == DrawCameraMode.DeferredSmoothness || cameraMode.drawMode == DrawCameraMode.DeferredNormal || cameraMode.drawMode == DrawCameraMode.ValidateAlbedo || - cameraMode.drawMode == DrawCameraMode.ValidateMetalSpecular || - cameraMode.drawMode == DrawCameraMode.LightOverlap + cameraMode.drawMode == DrawCameraMode.ValidateMetalSpecular ) return false; From dd03aa32065c4b4af473a2abf8442271adb8c01d Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Wed, 15 Apr 2020 12:51:53 +0200 Subject: [PATCH 21/81] Fix culling of reflection probes that change position #121 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Lighting/Reflection/HDProbeSystem.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index c8a35b8b242..9a9f9c26c3f 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). - Fixed MSAA depth resolve when there is no motion vectors - Fix issue causing wrong planar reflection rendering when more than one camera is present. +- Fixed culling of planar reflection probes that change position (case 1218651) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs index 4dab12b248a..5a2bcc6dac5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs @@ -246,7 +246,7 @@ internal HDProbeCullState PrepareCull(Camera camera) if (m_PlanarProbeCullingGroup == null) return default; - RemoveDestroyedProbes(m_PlanarProbes, m_PlanarProbeBounds, ref m_PlanarProbeCount); + UpdateBoundsAndRemoveDestroyedProbes(m_PlanarProbes, m_PlanarProbeBounds, ref m_PlanarProbeCount); m_PlanarProbeCullingGroup.targetCamera = camera; m_PlanarProbeCullingGroup.SetBoundingSpheres(m_PlanarProbeBounds); @@ -286,7 +286,7 @@ static void RemoveDestroyedProbes(List probes) } } - static void RemoveDestroyedProbes(PlanarReflectionProbe[] probes, BoundingSphere[] bounds, ref int count) + static void UpdateBoundsAndRemoveDestroyedProbes(PlanarReflectionProbe[] probes, BoundingSphere[] bounds, ref int count) { for (int i = 0; i < count; ++i) { @@ -297,6 +297,11 @@ static void RemoveDestroyedProbes(PlanarReflectionProbe[] probes, BoundingSphere probes[count - 1] = null; --count; } + + if (probes[i]) + { + bounds[i] = probes[i].boundingSphere; + } } } From 5111f69425998293b3cf2794b0aac337a3bc293b Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Wed, 15 Apr 2020 14:48:44 +0200 Subject: [PATCH 22/81] Fix null reference when processing light probe #131 --- .../CHANGELOG.md | 1 + .../Runtime/Lighting/LightLoop/LightLoop.cs | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 9a9f9c26c3f..693841dea7e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed MSAA depth resolve when there is no motion vectors - Fix issue causing wrong planar reflection rendering when more than one camera is present. - Fixed culling of planar reflection probes that change position (case 1218651) +- Fixed null reference when processing lightprobe (case 1235285) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 253b45ecd8a..a1b12726020 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -2409,17 +2409,17 @@ int PreprocessVisibleProbes(HDCamera hdCamera, CullingResults cullResults, HDPro { var probe = cullResults.visibleReflectionProbes[probeIndex]; + if (probe.reflectionProbe == null + || probe.reflectionProbe.Equals(null) || !probe.reflectionProbe.isActiveAndEnabled + || !aovRequest.IsLightEnabled(probe.reflectionProbe.gameObject)) + continue; + ref ProcessedProbeData processedData = ref m_ProcessedReflectionProbeData[probeIndex]; PreprocessReflectionProbeData(ref processedData, probe, hdCamera); if (TrivialRejectProbe(processedData, hdCamera)) continue; - if (probe.reflectionProbe == null - || probe.reflectionProbe.Equals(null) || !probe.reflectionProbe.isActiveAndEnabled - || !aovRequest.IsLightEnabled(probe.reflectionProbe.gameObject)) - continue; - // Work around the data issues. if (probe.localToWorldMatrix.determinant == 0) { From 61886f3cdd0633797f19e9e0d997be97c42ad1e3 Mon Sep 17 00:00:00 2001 From: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com> Date: Wed, 15 Apr 2020 12:05:56 -0400 Subject: [PATCH 23/81] Fix black screen in XR when HDRP package is present but not used #137 --- .../CHANGELOG.md | 94 +++++++++++++++++++ .../Runtime/RenderPipeline/XR/XRSystem.cs | 2 + 2 files changed, 96 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 693841dea7e..e1b21147245 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix issue causing wrong planar reflection rendering when more than one camera is present. - Fixed culling of planar reflection probes that change position (case 1218651) - Fixed null reference when processing lightprobe (case 1235285) +- Fix black screen in XR when HDRP package is present but not used. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. @@ -271,6 +272,99 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue with MipRatio debug mode showing _DebugMatCapTexture not being set. - Fixed missing initialization of input params in Blit for VR. - Fix Inf source in LTC for area lights. +<<<<<<< HEAD +======= +- Fix issue with AO being misaligned when multiple view are visible. +- Fix issue that caused the clamp of camera rotation motion for motion blur to be ineffective. +- Fixed issue with AssetPostprocessors dependencies causing models to be imported twice when upgrading the package version. +- Fixed culling of lights with XR SDK +- Fixed memory stomp in shadow caching code, leading to overflow of Shadow request array and runtime errors. +- Fixed an issue related to transparent objects reading the ray traced indirect diffuse buffer +- Fixed an issue with filtering ray traced area lights when the intensity is high or there is an exposure. +- Fixed ill-formed include path in Depth Of Field shader. +- Fixed shader graph and ray tracing after the shader target PR. +- Fixed a bug in semi-transparent shadows (object further than the light casting shadows) +- Fix state enabled of default volume profile when in package. +- Fixed removal of MeshRenderer and MeshFilter on adding Light component. +- Fixed Ray Traced SubSurface Scattering not working with ray traced area lights +- Fixed Ray Traced SubSurface Scattering not working in forward mode. +- Fixed a bug in debug light volumes. +- Fixed a bug related to ray traced area light shadow history. +- Fixed an issue where fog sky color mode could sample NaNs in the sky cubemap. +- Fixed a leak in the PBR sky renderer. +- Added a tooltip to the Ambient Mode parameter in the Visual Envionment volume component. +- Static lighting sky now takes the default volume into account (this fixes discrepancies between baked and realtime lighting). +- Fixed a leak in the sky system. +- Removed MSAA Buffers allocation when lit shader mode is set to "deferred only". +- Fixed invalid cast for realtime reflection probes (case 1220504) +- Fixed invalid game view rendering when disabling all cameras in the scene (case 1105163) +- Hide reflection probes in the renderer components. +- Fixed infinite reload loop while displaying Light's Shadow's Link Light Layer in Inspector of Prefab Asset. +- Fixed the culling was not disposed error in build log. +- Fixed the cookie atlas size and planar atlas size being too big after an upgrade of the HDRP asset. +- Fixed transparent SSR for shader graph. +- Fixed an issue with emissive light meshes not being in the RAS. +- Fixed DXR player build +- Fixed the HDRP asset migration code not being called after an upgrade of the package +- Fixed draw renderers custom pass out of bound exception +- Fixed the PBR shader rendering in deferred +- Fixed some typos in debug menu (case 1224594) +- Fixed ray traced point and spot lights shadows not rejecting istory when semi-transparent or colored. +- Fixed a warning due to StaticLightingSky when reloading domain in some cases. +- Fixed the MaxLightCount being displayed when the light volume debug menu is on ColorAndEdge. +- Fixed issue with unclear naming of debug menu for decals. +- Fixed z-fighting in scene view when scene lighting is off (case 1203927) +- Fixed issue that prevented cubemap thumbnails from rendering. +- Fixed ray tracing with VR single-pass +- Fix an exception in ray tracing that happens if two LOD levels are using the same mesh renderer. +- Fixed error in the console when switching shader to decal in the material UI. +- Fixed an issue with refraction model and ray traced recursive rendering (case 1198578). +- Fixed an issue where a dynamic sky changing any frame may not update the ambient probe. +- Fixed cubemap thumbnail generation at project load time. +- Fixed cubemap thumbnail generation at project load time. +- Fixed XR culling with multiple cameras +- Fixed XR single-pass with Mock HMD plugin +- Fixed sRGB mismatch with XR SDK +- Fixed an issue where default volume would not update when switching profile. +- Fixed issue with uncached reflection probe cameras reseting the debug mode (case 1224601) +- Fixed an issue where AO override would not override specular occlusion. +- Fixed an issue where Volume inspector might not refresh correctly in some cases. +- Fixed render texture with XR +- Fixed issue with resources being accessed before initialization process has been performed completely. +- Half fixed shuriken particle light that cast shadows (only the first one will be correct) +- Fixed issue with atmospheric fog turning black if a planar reflection probe is placed below ground level. (case 1226588) +- Fixed custom pass GC alloc issue in CustomPassVolume.GetActiveVolumes(). +- Fixed a bug where instanced shadergraph shaders wouldn't compile on PS4. +- Fixed an issue related to the envlightdatasrt not being bound in recursive rendering. +- Fixed shadow cascade tooltip when using the metric mode (case 1229232) +- Fixed how the area light influence volume is computed to match rasterization. +- Focus on Decal uses the extends of the projectors +- Fixed usage of light size data that are not available at runtime. +- Fixed the depth buffer copy made before custom pass after opaque and normal injection point. +- Fix for issue that prevented scene from being completely saved when baked reflection probes are present and lighting is set to auto generate. +- Fixed drag area width at left of Light's intensity field in Inspector. +- Fixed light type resolution when performing a reset on HDAdditionalLightData (case 1220931) +- Fixed reliance on atan2 undefined behavior in motion vector debug shader. +- Fixed an usage of a a compute buffer not bound (1229964) +- Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. +- Fix issues in the post process system with RenderTexture being invalid in some cases, causing rendering problems. +- Fixed an issue where unncessarily serialized members in StaticLightingSky component would change each time the scene is changed. +- Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). +- Fixed a regression in the ray traced indirect diffuse due to the new probe system. +- Fix for range compression factor for probes going negative (now clamped to positive values). +- Fixed path validation when creating new volume profile (case 1229933) +- Fix reflection hierarchy for CARPAINT in AxF. +- Fix precise fresnel for delta lights for SVBRDF in AxF. +- Fixed the debug exposure mode for display sky reflection and debug view baked lighting +- Fixed MSAA depth resolve when there is no motion vectors +- Fixed various object leaks in HDRP. +- Fixed compile error with XR SubsystemManager. +- Fix for assertion triggering sometimes when saving a newly created lit shader graph (case 1230996) +- Fixed culling of planar reflection probes that change position (case 1218651) +- Fixed null reference when processing lightprobe (case 1235285) +- Fix issue causing wrong planar reflection rendering when more than one camera is present. +- Fix black screen in XR when HDRP package is present but not used. +>>>>>>> 0cea810ead... fix black screen in XR when HDRP package is present but not used (#137) ### Changed - Hide unused LOD settings in Quality Settings legacy window. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs index b4e3147a246..0a7cd235b4a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/XR/XRSystem.cs @@ -74,6 +74,8 @@ internal XRSystem(RenderPipelineResources.ShaderResources shaders) [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)] internal static void XRSystemInit() { + if (GraphicsSettings.currentRenderPipeline == null) + return; SubsystemManager.GetInstances(displayList); for (int i = 0; i < displayList.Count; i++) From 9d9eb878b6ca8e79882bb62479b750e57e7af6d6 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Thu, 16 Apr 2020 15:48:50 +0200 Subject: [PATCH 24/81] Fix default volume profile collapse #138 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index e1b21147245..3cb2215abbc 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed culling of planar reflection probes that change position (case 1218651) - Fixed null reference when processing lightprobe (case 1235285) - Fix black screen in XR when HDRP package is present but not used. + - Fixed an issue that was collapsing the volume components in the HDRP default settings ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs index b244d14d284..35167715150 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs @@ -45,7 +45,7 @@ public class Styles ReorderableList m_BeforeTransparentCustomPostProcesses; ReorderableList m_BeforePostProcessCustomPostProcesses; ReorderableList m_AfterPostProcessCustomPostProcesses; - int m_CurrentVolumeProfileHash; + int m_CurrentVolumeProfileInstanceID; public void OnGUI(string searchContext) { @@ -209,9 +209,9 @@ void Draw_VolumeInspector() EditorGUILayout.EndHorizontal(); // The state of the profile can change without the asset reference changing so in this case we need to reset the editor. - if (m_CurrentVolumeProfileHash != asset.GetHashCode() && m_CachedDefaultVolumeProfileEditor != null) + if (m_CurrentVolumeProfileInstanceID != asset.GetInstanceID() && m_CachedDefaultVolumeProfileEditor != null) { - m_CurrentVolumeProfileHash = asset.GetHashCode(); + m_CurrentVolumeProfileInstanceID = asset.GetInstanceID(); m_CachedDefaultVolumeProfileEditor = null; } From 8c0e270f13d407e94b759f76c727f3d3cad7a1d5 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Thu, 16 Apr 2020 14:22:11 +0200 Subject: [PATCH 25/81] Fix for white flash happening when changing lighting condition (like teleport) #140 --- .../CHANGELOG.md | 1 + .../Lighting/LightLoop/LightLoopDef.hlsl | 3 +++ .../Lighting/Shadow/ScreenSpaceShadows.shader | 1 + .../PostProcessing/PostProcessSystem.cs | 23 ++++++++++++++----- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3cb2215abbc..9d78793fe67 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed null reference when processing lightprobe (case 1235285) - Fix black screen in XR when HDRP package is present but not used. - Fixed an issue that was collapsing the volume components in the HDRP default settings + - Fixed NaN which can appear with real time reflection and inf value ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl index db345b63d26..873dbb2195f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl @@ -130,6 +130,9 @@ float4 SampleEnv(LightLoopContext lightLoopContext, int index, float3 texCoord, color.rgb = SampleSkyTexture(texCoord, lod, sliceIdx).rgb; } + // Planar, Reflection Probes and Sky aren't pre-expose, so best to clamp to max16 here in case of inf + color.rgb = ClampToFloat16Max(color.rgb); + return color; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader index 86e607c8a37..8f13fe422ab 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadows.shader @@ -7,6 +7,7 @@ Shader "Hidden/HDRP/ScreenSpaceShadows" #pragma target 4.5 #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonLighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Builtin/BuiltinData.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl" diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index b90037944c2..8de6b3fc387 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -372,7 +372,11 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn } else { - if (IsExposureFixed()) + // Fix exposure is store in Exposure Textures at the beginning of the frame as there is no need for color buffer + // Dynamic exposure (Auto, curve) is store in Exposure Textures at the end of the frame (as it rely on color buffer) + // Texture current and previous are swapped at the beginning of the frame. + bool isFixedExposure = IsExposureFixed(); + if (isFixedExposure) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.FixedExposure))) { @@ -380,7 +384,14 @@ public void BeginFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline hdIn } } - cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, GetExposureTexture(camera)); + // Note: GetExposureTexture(camera) must be call AFTER the call of DoFixedExposure to be correctly taken into account + // When we use Dynamic Exposure and we reset history we can't use pre-exposure (as there is no information) + // For this reasons we put neutral value at the beginning of the frame in Exposure textures and + // apply processed exposure from color buffer at the end of the Frame, only for a single frame. + // After that we re-use the pre-exposure system + RTHandle currentExposureTexture = (camera.resetPostProcessingHistory && !isFixedExposure) ? m_EmptyExposureTexture : GetExposureTexture(camera); + + cmd.SetGlobalTexture(HDShaderIDs._ExposureTexture, currentExposureTexture); cmd.SetGlobalTexture(HDShaderIDs._PrevExposureTexture, GetPreviousExposureTexture(camera)); } } @@ -485,9 +496,9 @@ void PoolSource(ref RTHandle src, RTHandle dst) cmd.DispatchCompute(cs, kernel, (camera.actualWidth + 7) / 8, (camera.actualHeight + 7) / 8, camera.viewCount); PoolSource(ref source, destination); + } } } - } if (m_PostProcessEnabled) { @@ -876,9 +887,9 @@ void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer, if (camera.resetPostProcessingHistory) { - kernel = cs.FindKernel("KReset"); - cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputTexture, prevExposure); - cmd.DispatchCompute(cs, kernel, 1, 1, 1); + // For Dynamic Exposure, we need to undo the pre-exposure from the color buffer to calculate the correct one + // When we reset history we must setup neutral value + prevExposure = m_EmptyExposureTexture; // Use neutral texture } m_ExposureVariants[0] = 1; // (int)exposureSettings.luminanceSource.value; From 5b4fce159884ffb8ec15a728c10c68a6011958e1 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 16 Apr 2020 11:57:47 +0100 Subject: [PATCH 26/81] Added baked GI rp support caveat and made setting shadow filter quality clearer for deferred high. (#145) --- .../Documentation~/Shadows-in-HDRP.md | 5 +++-- com.unity.shadergraph/Documentation~/Baked-GI-Node.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md b/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md index 4ecd5cdca8b..2dede000014 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md @@ -53,9 +53,10 @@ Using high shadow bias values may result in light "leaking" through Meshes. This After HDRP captures a shadow map, it processes filtering on the map in order to decrease the aliasing effect that occurs on low resolution shadow maps. Different filters affect the perceived sharpness of shadows. -To change which filter HDRP uses, change the **Filtering Quality** property in your Unity Project’s [HDRP Asset](HDRP-Asset.html). There are currently four filter quality presets for directional and punctual lights. For information on the available filter qualities, see the [Filtering Qualities table](HDRP-Asset.html#FilteringQualities). +To change which filter HDRP uses, the method depends on which filter quality you want to use and whether your HDRP Project uses [forward or deferred rendering](Forward-And-Deferred-Rendering.md). -Currently, if you want to use **High** quality (PCSS) filtering in [deferred](Forward-And-Deferred-Rendering.html) mode, you need to enable it in the [HDRP Config package](HDRP-Config-Package.html). For information on how to do this, see the [Example section](HDRP-Config-Package.html#Example) of the Config package documentation. +* **Forward rendering**: Change the **Filtering Quality** property in your Unity Project’s [HDRP Asset](HDRP-Asset.html). This method works for every filter quality. There are currently three filter quality presets for directional and punctual lights. For information on the available filter qualities, see the [Filtering Qualities table](HDRP-Asset.html#FilteringQualities). +* **Deferred rendering**: For **Low** and **Medium** filter qualities, use the same method as forward rendering. If you want to use **High** quality (PCSS) filtering, you need to enable it in the [HDRP Config package](HDRP-Config-Package.html). For information on how to do this, see the [Example section](HDRP-Config-Package.html#Example) of the Config package documentation. ## Shadowmasks diff --git a/com.unity.shadergraph/Documentation~/Baked-GI-Node.md b/com.unity.shadergraph/Documentation~/Baked-GI-Node.md index 1b29650f742..e4c27f44dfa 100644 --- a/com.unity.shadergraph/Documentation~/Baked-GI-Node.md +++ b/com.unity.shadergraph/Documentation~/Baked-GI-Node.md @@ -9,7 +9,7 @@ Note: The behavior of this [Node](Node.md) is undefined globally. Shader Graph d Different Render Pipelines may produce different results. If you're building a shader in one Render Pipeline that you want to use in both, try checking it in both pipelines before production. A [Node](Node.md) might be defined in one Render Pipeline and undefined in the other. If this [Node](Node.md) is undefined, it returns 0 (black). #### Unity Render Pipelines Support -- High Definition Render Pipeline +- High Definition Render Pipeline. Although, this Node does not work in a Shader Graph that targets HDRP's [Unlit Master Node](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/Master-Node-Unlit.html). - Universal Render Pipeline ## Ports From ffc58cde833dc2981ff96a225db1491a3747fbae Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 16 Apr 2020 15:26:38 +0100 Subject: [PATCH 27/81] Update AxF-Shader.md (#152) --- .../Documentation~/AxF-Shader.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md index 0d5cb0b20ee..5a346878a38 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/AxF-Shader.md @@ -25,7 +25,7 @@ This process does not duplicate the Textures and other resources that the origin ### Creating AxF Materials from scratch -New Materials in HDRP use the [Lit Shader](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@7.1/manual/Lit-Shader.html) by default. To create an AxF Material from scratch, create a Material and then make it use the AxF Shader. To do this: +New Materials in HDRP use the [Lit Shader](Lit-Shader.md) by default. To create an AxF Material from scratch, create a Material and then make it use the AxF Shader. To do this: 1. In the Unity Editor, navigate to your Project's Asset window. 2. Right-click the Asset Window and select **Create > Material**. This adds a new Material to your Unity Project’s Asset folder. @@ -60,8 +60,9 @@ Note: The AxF Importer imports every Texture as half float, linear, sRGB gamut ( | --------------------- | ------------------------------------------------------------ | | **Material Tiling U** | Sets the tile rate along the x-axis for every Texture in the **Surface Inputs** section. HDRP uses this value to tile the Textures along the x-axis of the Material’s surface, in object space. | | **Material Tiling V** | Sets the tile rate along the y-axis for every Texture in the **Surface Inputs** section. HDRP uses this value to tile the Textures along the y-axis of the Material’s surface, in object space. | -| **BRDF Type** | Controls the main AxF Material representation.
• **SVBRDF**: For information on the properties Unity makes visible when you select this option, see [BRDF Type - SVBRDF](https://docs.google.com/document/d/1_Oq2hsx3J7h8GHKoQM_8qf6Ip5VlHv_31K7dYYVOEmU/edit#heading=h.f1msh9g44mev).
•**CAR_PAINT**: For information on the properties Unity makes visible when you select this option, see [BRDF Type - CAR_PAINT](https://docs.google.com/document/d/1_Oq2hsx3J7h8GHKoQM_8qf6Ip5VlHv_31K7dYYVOEmU/edit#heading=h.eorkre6buegg). | +| **BRDF Type** | Controls the main AxF Material representation.
• **SVBRDF**: For information on the properties Unity makes visible when you select this option, see [BRDF Type - SVBRDF](#SVBRDF).
•**CAR_PAINT**: For information on the properties Unity makes visible when you select this option, see [BRDF Type - CAR_PAINT](#CAR_PAINT). | + #### BRDF Type - SVBRDF | **Property** | **Description** | @@ -86,6 +87,7 @@ Note: The AxF Importer imports every Texture as half float, linear, sRGB gamut ( | **- Enable Refraction** | Indicates whether the clear coat is refractive. If you enable this checkbox, HDRP uses angles refracted by the clear coat to evaluate the undercoat of the Material surface. | | **- - Clearcoat IOR** | Specifies a Texture (red channel only) that implicitly defines the index of refraction (IOR) for the clear coat by encoding it to a monochromatic (single value) F0 (aka as specular color or Fresnel reflectance at 0 degree incidence. This also assumes the coat interfaces with air). As such, the value is in the range of **0** to **1** and HDRP calculates the final IOR as:
`IOR = (1.0 + squareRoot(R) ) / (1.0 - squareRoot(R))`
Where **R** is the normalized value in the red color channel of this Texture. Note: HDRP uses this IOR for both coat refraction and, if enabled, transmission and reflectance calculations through and on the coat. Therefore, you must always assign a Texture to this property when you enable clear coat. | + #### BRDF Type - CAR_PAINT | **Property** | **Description** | From 4f787c2be983fabf829acaae29bced39be2ad7dd Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 16 Apr 2020 10:20:46 -0700 Subject: [PATCH 28/81] Bind missing buffer #159 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 7 ++++--- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 9d78793fe67..a76ba94d522 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -48,9 +48,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed culling of planar reflection probes that change position (case 1218651) - Fixed null reference when processing lightprobe (case 1235285) - Fix black screen in XR when HDRP package is present but not used. - - Fixed an issue that was collapsing the volume components in the HDRP default settings - - Fixed NaN which can appear with real time reflection and inf value - +- Fixed an issue that was collapsing the volume components in the HDRP default settings +- Fixed NaN which can appear with real time reflection and inf value +- Fixed warning about missing bound decal buffer + ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. - Renamed "Environment" to "Reflection Probes" in tile/cluster debug menu. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 95ef43699c3..f7b34ebf18f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -3103,6 +3103,10 @@ void RenderDBuffer(HDCamera hdCamera, CommandBuffer cmd, ScriptableRenderContext { // We still bind black textures to make sure that something is bound (can be a problem on some platforms) m_DbufferManager.BindBlackTextures(cmd); + + // Bind buffer to make sure that something is bound . + cmd.SetGlobalBuffer(HDShaderIDs._DecalPropertyMaskBufferSRV, m_DbufferManager.propertyMaskBuffer); + return; } From f3218d63ed8b4f478c566756c78cbcc3f34e2196 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Mon, 20 Apr 2020 10:40:33 +0200 Subject: [PATCH 29/81] [Backport 7.x.x] Diffusion Profile and Material references in HDRP materials are now correctly exported to unity packages. (#179) * Added external references inside a material to diffusion profiles and materials in order to handle Material export to a package correctly. # Conflicts: # com.unity.render-pipelines.high-definition/Editor/Material/PBR/HDPBRLit.cs * Update changelog --- .../CHANGELOG.md | 1 + .../DiffusionProfileMaterialUI.cs | 12 +++- .../Material/MaterialExternalReferences.cs | 70 +++++++++++++++++++ .../MaterialExternalReferences.cs.meta | 11 +++ .../Editor/Material/PBR/HDPBRLit.cs | 3 +- .../Material/UIBlocks/LayerListUIBlock.cs | 12 +++- .../UIBlocks/LitSurfaceInputsUIBlock.cs | 2 +- .../Material/UIBlocks/ShaderGraphUIBlock.cs | 4 +- 8 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs create mode 100644 com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs.meta diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6d5ec57997d..823168e0026 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed NaN which can appear with real time reflection and inf value - Fixed warning about missing bound decal buffer - Fix black screen in XR when HDRP package is present but not used. +- Diffusion Profile and Material references in HDRP materials are now correctly exported to unity packages. Note that the diffusion profile or the material references need to be edited once before this can work properly. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileMaterialUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileMaterialUI.cs index 726379b1193..b879b15367f 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileMaterialUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/DiffusionProfile/DiffusionProfileMaterialUI.cs @@ -18,7 +18,7 @@ public static bool IsSupported(MaterialEditor materialEditor) }); } - public static void OnGUI(MaterialProperty diffusionProfileAsset, MaterialProperty diffusionProfileHash) + public static void OnGUI(MaterialEditor materialEditor, MaterialProperty diffusionProfileAsset, MaterialProperty diffusionProfileHash, int profileIndex) { // We can't cache these fields because of several edge cases like undo/redo or pressing escape in the object picker string guid = HDUtils.ConvertVector4ToGUID(diffusionProfileAsset.vectorValue); @@ -42,6 +42,16 @@ public static void OnGUI(MaterialProperty diffusionProfileAsset, MaterialPropert // encode back GUID and it's hash diffusionProfileAsset.vectorValue = newGuid; diffusionProfileHash.floatValue = hash; + + // Update external reference. + foreach (var target in materialEditor.targets) + { + MaterialExternalReferences matExternalRefs = MaterialExternalReferences.GetMaterialExternalReferences(target as Material); + if (matExternalRefs != null) + { + matExternalRefs.SetDiffusionProfileReference(profileIndex, diffusionProfile); + } + } } DrawDiffusionProfileWarning(diffusionProfile); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs b/com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs new file mode 100644 index 00000000000..4466369d138 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs @@ -0,0 +1,70 @@ +using UnityEngine; +using UnityEngine.Rendering.HighDefinition; + +namespace UnityEditor.Rendering.HighDefinition +{ + // This class only purpose is to be used as a sub-asset to a material and store references to other assets. + // The goal is to be able to export the material as a package and not miss those referenced assets. + class MaterialExternalReferences : ScriptableObject + { + [SerializeField] + DiffusionProfileSettings[] m_DiffusionProfileReferences = new DiffusionProfileSettings[0]; + [SerializeField] + Material[] m_MaterialReferences = new Material[0]; + + public void SetDiffusionProfileReference(int index, DiffusionProfileSettings profile) + { + if (index >= m_DiffusionProfileReferences.Length) + { + var newList = new DiffusionProfileSettings[index + 1]; + for (int i = 0; i < m_DiffusionProfileReferences.Length; ++i) + newList[i] = m_DiffusionProfileReferences[i]; + + m_DiffusionProfileReferences = newList; + } + + m_DiffusionProfileReferences[index] = profile; + EditorUtility.SetDirty(this); + } + + public void SetMaterialReference(int index, Material mat) + { + if (index >= m_MaterialReferences.Length) + { + var newList = new Material[index + 1]; + for (int i = 0; i < m_MaterialReferences.Length; ++i) + newList[i] = m_MaterialReferences[i]; + + m_MaterialReferences = newList; + } + + m_MaterialReferences[index] = mat; + EditorUtility.SetDirty(this); + } + + public static MaterialExternalReferences GetMaterialExternalReferences(Material material) + { + var subAssets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(material)); + MaterialExternalReferences matExternalRefs = null; + foreach (var subAsset in subAssets) + { + if (subAsset.GetType() == typeof(MaterialExternalReferences)) + { + matExternalRefs = subAsset as MaterialExternalReferences; + break; + } + } + + if (matExternalRefs == null) + { + matExternalRefs = CreateInstance(); + matExternalRefs.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable; + AssetDatabase.AddObjectToAsset(matExternalRefs, material); + EditorUtility.SetDirty(matExternalRefs); + EditorUtility.SetDirty(material); + } + + return matExternalRefs; + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs.meta b/com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs.meta new file mode 100644 index 00000000000..30af94f1846 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/MaterialExternalReferences.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: aa486462e6be1764e89c788ba30e61f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/PBR/HDPBRLit.cs b/com.unity.render-pipelines.high-definition/Editor/Material/PBR/HDPBRLit.cs index 7fe5e89df34..81c2edf1c96 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/PBR/HDPBRLit.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/PBR/HDPBRLit.cs @@ -13,6 +13,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro materialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true, true); } + // Make sure all selected materials are initialized. string materialTag = "MotionVector"; foreach (var obj in materialEditor.targets) @@ -42,7 +43,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro } if (DiffusionProfileMaterialUI.IsSupported(materialEditor)) - DiffusionProfileMaterialUI.OnGUI(FindProperty("_DiffusionProfileAsset", props), FindProperty("_DiffusionProfileHash", props)); + DiffusionProfileMaterialUI.OnGUI(materialEditor, FindProperty("_DiffusionProfileAsset", props), FindProperty("_DiffusionProfileHash", props), 0); } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LayerListUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LayerListUIBlock.cs index 2053093ebfe..2db7c6e96b5 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LayerListUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LayerListUIBlock.cs @@ -154,8 +154,18 @@ void DrawLayerListGUI() Undo.RecordObjects(new UnityEngine.Object[] { material, m_MaterialImporter }, "Change layer material"); LayeredLitGUI.SynchronizeLayerProperties(material, m_MaterialLayers, layerIndex, true); layersChanged = true; + + // Update external reference. + foreach (var target in materialEditor.targets) + { + MaterialExternalReferences matExternalRefs = MaterialExternalReferences.GetMaterialExternalReferences(target as Material); + if (matExternalRefs != null) + { + matExternalRefs.SetMaterialReference(layerIndex, m_MaterialLayers[layerIndex]); + } + } } - + EditorGUI.DrawRect(colorRect, kLayerColors[layerIndex]); m_WithUV[layerIndex] = EditorGUI.Toggle(uvRect, m_WithUV[layerIndex]); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitSurfaceInputsUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitSurfaceInputsUIBlock.cs index 2dfda3f8b14..004228f7c63 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitSurfaceInputsUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/LitSurfaceInputsUIBlock.cs @@ -557,7 +557,7 @@ void ShaderSSSAndTransmissionInputGUI() if (hdPipeline == null) return; - DiffusionProfileMaterialUI.OnGUI(diffusionProfileAsset[m_LayerIndex], diffusionProfileHash[m_LayerIndex]); + DiffusionProfileMaterialUI.OnGUI(materialEditor, diffusionProfileAsset[m_LayerIndex], diffusionProfileHash[m_LayerIndex], m_LayerIndex); // TODO: does not work with multi-selection if ((int)materialID.floatValue == (int)MaterialId.LitSSS && materials[0].GetSurfaceType() != SurfaceType.Transparent) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs index 0648baabce4..a7befa8a171 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/ShaderGraphUIBlock.cs @@ -96,7 +96,7 @@ void DrawShaderGraphGUI() // Filter out properties we don't want to draw: PropertiesDefaultGUI(properties); - // If we change a property in a shadergraph, we trigger a material keyword reset + // If we change a property in a shadergraph, we trigger a material keyword reset if (CheckPropertyChanged(properties)) { foreach (var material in materials) @@ -221,7 +221,7 @@ void DrawShadowMatteToggle() void DrawDiffusionProfileUI() { if (DiffusionProfileMaterialUI.IsSupported(materialEditor)) - DiffusionProfileMaterialUI.OnGUI(FindProperty("_DiffusionProfileAsset"), FindProperty("_DiffusionProfileHash")); + DiffusionProfileMaterialUI.OnGUI(materialEditor, FindProperty("_DiffusionProfileAsset"), FindProperty("_DiffusionProfileHash"), 0); } } } From 976cd19659b63334ae788f184580512c2bbbb102 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 24 Apr 2020 10:55:20 +0200 Subject: [PATCH 30/81] Catch and handle NRefactory parser exceptions #6392 --- .../Editor/ShaderGenerator/CSharpToHLSL.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.core/Editor/ShaderGenerator/CSharpToHLSL.cs b/com.unity.render-pipelines.core/Editor/ShaderGenerator/CSharpToHLSL.cs index 5585be5d2b7..76391051c57 100644 --- a/com.unity.render-pipelines.core/Editor/ShaderGenerator/CSharpToHLSL.cs +++ b/com.unity.render-pipelines.core/Editor/ShaderGenerator/CSharpToHLSL.cs @@ -201,7 +201,16 @@ static void LoadTypes(string fileName) }*/ parser.Lexer.EvaluateConditionalCompilation = true; - parser.Parse(); + try + { + parser.Parse(); + } + catch + { + Debug.LogWarning($"Unable to parse {fileName}. Please not that C# 6.0 syntax is not yet supported by this tool."); + return; + } + try { var visitor = new NamespaceVisitor(); From 56ace1e20fd22b52e0997fe40a11def02011f85d Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 27 Apr 2020 13:44:17 +0200 Subject: [PATCH 31/81] [7.x.x backport] Fix quality settings UI and shadow mask UI #122 (#123) * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs * Update CHANGELOG.md * fix typo * fix typo 2 --- .../CHANGELOG.md | 1 + .../RenderPipeline/HDRenderPipeline.cs | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 4d42664096c..1834d9c413b 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed unneeded cookie texture allocation for cone stop lights. - Fixed issue when toggling anything in HDRP asset that will produce an error (case 1238155) - Diffusion Profile and Material references in HDRP materials are now correctly exported to unity packages. Note that the diffusion profile or the material references need to be edited once before this can work properly. +- Fixed shadowmask UI now correctly showing shadowmask disable ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 87653382fb0..343437a868e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -103,6 +103,12 @@ internal static Volume GetOrCreateDefaultVolume() readonly PostProcessSystem m_PostProcessSystem; readonly XRSystem m_XRSystem; + // Keep track of previous Graphic and QualitySettings value to reset when switching to another pipeline + bool m_PreviousLightsUseLinearIntensity; + bool m_PreviousLightsUseColorTemperature; + bool m_PreviousSRPBatcher; + ShadowmaskMode m_PreviousShadowMaskMode; + bool m_FrameSettingsHistoryEnabled = false; /// @@ -660,16 +666,22 @@ void SetRenderingFeatures() Shader.globalRenderPipeline = "HDRenderPipeline"; // HD use specific GraphicsSettings + m_PreviousLightsUseLinearIntensity = GraphicsSettings.lightsUseLinearIntensity; GraphicsSettings.lightsUseLinearIntensity = true; + m_PreviousLightsUseColorTemperature = GraphicsSettings.lightsUseColorTemperature; GraphicsSettings.lightsUseColorTemperature = true; - + m_PreviousSRPBatcher = GraphicsSettings.useScriptableRenderPipelineBatching; GraphicsSettings.useScriptableRenderPipelineBatching = m_Asset.enableSRPBatcher; + // In case shadowmask mode isn't setup correctly, force it to correct usage (as there is no UI to fix it) + m_PreviousShadowMaskMode = QualitySettings.shadowmaskMode; + QualitySettings.shadowmaskMode = ShadowmaskMode.DistanceShadowmask; + SupportedRenderingFeatures.active = new SupportedRenderingFeatures() { reflectionProbeModes = SupportedRenderingFeatures.ReflectionProbeModes.Rotation, defaultMixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeModes.IndirectOnly, - mixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeModes.IndirectOnly | SupportedRenderingFeatures.LightmapMixedBakeModes.Shadowmask, + mixedLightingModes = SupportedRenderingFeatures.LightmapMixedBakeModes.IndirectOnly | (m_Asset.currentPlatformRenderPipelineSettings.supportShadowMask ? SupportedRenderingFeatures.LightmapMixedBakeModes.Shadowmask : 0), lightmapBakeTypes = LightmapBakeType.Baked | LightmapBakeType.Mixed | LightmapBakeType.Realtime, lightmapsModes = LightmapsMode.NonDirectional | LightmapsMode.CombinedDirectional, lightProbeProxyVolumes = true, @@ -774,10 +786,12 @@ void UnsetRenderingFeatures() { Shader.globalRenderPipeline = ""; - SupportedRenderingFeatures.active = new SupportedRenderingFeatures(); + GraphicsSettings.lightsUseLinearIntensity = m_PreviousLightsUseLinearIntensity; + GraphicsSettings.lightsUseColorTemperature = m_PreviousLightsUseColorTemperature; + GraphicsSettings.useScriptableRenderPipelineBatching = m_PreviousSRPBatcher; + QualitySettings.shadowmaskMode = m_PreviousShadowMaskMode; - // Reset srp batcher state just in case - GraphicsSettings.useScriptableRenderPipelineBatching = false; + SupportedRenderingFeatures.active = new SupportedRenderingFeatures(); Lightmapping.ResetDelegate(); } From 4f14500595877c319d571922f2fbbbfb16e9dbfd Mon Sep 17 00:00:00 2001 From: anisunity <42026998+anisunity@users.noreply.github.com> Date: Mon, 27 Apr 2020 17:33:21 +0200 Subject: [PATCH 32/81] Fixed the indirect diffuse texture not being ignored when it should (ray tracing disabled). (#284) --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/RenderPipeline/HDRenderPipeline.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1834d9c413b..71ba1db8fe2 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed issue when toggling anything in HDRP asset that will produce an error (case 1238155) - Diffusion Profile and Material references in HDRP materials are now correctly exported to unity packages. Note that the diffusion profile or the material references need to be edited once before this can work properly. - Fixed shadowmask UI now correctly showing shadowmask disable +- Fixed the indirect diffuse texture not being ignored when it should (ray tracing disabled). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 343437a868e..0ac757e2b14 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1059,6 +1059,10 @@ void PushGlobalParams(HDCamera hdCamera, CommandBuffer cmd) // Bind the camera's ray tracing frame index cmd.SetGlobalInt(HDShaderIDs._RaytracingFrameIndex, RayTracingFrameIndex(hdCamera)); } + else + { + cmd.SetGlobalInt(HDShaderIDs._RaytracedIndirectDiffuse, 0); + } cmd.SetGlobalFloat(HDShaderIDs._ContactShadowOpacity, m_ContactShadows.opacity.value); } } From f1d45cf3dfe13c2def812c8f8261fa1650aebae2 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Tue, 5 May 2020 20:02:05 +0200 Subject: [PATCH 33/81] [7.x.x Backport] Fix pre/post pass sg properties #82 (#85) * Fix depth pre/post passes not correctly enabled when switching shaders on the material # Conflicts: # com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitMasterNode.cs # com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs # com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDSubShaderUtilities.cs * Hide prepass and postpass in the material UI # Conflicts: # com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs Co-authored-by: sebastienlagarde --- .../CHANGELOG.md | 1 + .../Editor/Material/Eye/ShaderGraph/EyeGUI.cs | 3 ++- .../Editor/Material/Eye/ShaderGraph/EyeMasterNode.cs | 1 + .../Editor/Material/Fabric/ShaderGraph/FabricGUI.cs | 3 ++- .../Material/Fabric/ShaderGraph/FabricMasterNode.cs | 1 + .../Editor/Material/Hair/ShaderGraph/HairGUI.cs | 3 ++- .../Material/Hair/ShaderGraph/HairMasterNode.cs | 1 + .../Editor/Material/Lit/ShaderGraph/HDLitGUI.cs | 3 ++- .../Material/Lit/ShaderGraph/HDLitMasterNode.cs | 1 + .../Material/StackLit/ShaderGraph/StackLitGUI.cs | 3 ++- .../StackLit/ShaderGraph/StackLitMasterNode.cs | 1 + .../Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs | 12 ++++++++---- .../Editor/Material/Unlit/HDShaderGUI.cs | 3 ++- .../Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs | 3 ++- .../Material/Unlit/ShaderGraph/HDUnlitMasterNode.cs | 1 + .../Editor/ShaderGraph/HDSubShaderUtilities.cs | 6 ++++++ 16 files changed, 35 insertions(+), 11 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 71ba1db8fe2..5b12f75f7d1 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Diffusion Profile and Material references in HDRP materials are now correctly exported to unity packages. Note that the diffusion profile or the material references need to be edited once before this can work properly. - Fixed shadowmask UI now correctly showing shadowmask disable - Fixed the indirect diffuse texture not being ignored when it should (ray tracing disabled). +- Fixed depth prepass and postpass being disabled after changing the shader in the material UI. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs index 083a42d386d..d3070c798a7 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs @@ -14,7 +14,8 @@ class EyeGUI : HDShaderGUI // For surface option shader graph we only want all unlit features but alpha clip, back then front rendering and SSR const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass + ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeMasterNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeMasterNode.cs index db67c7bdc70..bc1fca3d904 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeMasterNode.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeMasterNode.cs @@ -783,6 +783,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode); + HDSubShaderUtilities.AddPrePostPassProperties(collector, alphaTestDepthPrepass.isOn, alphaTestDepthPostpass.isOn); base.CollectShaderProperties(collector, generationMode); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs index adf7cf976e7..f94a62156f2 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs @@ -15,7 +15,8 @@ class FabricGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass + ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricMasterNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricMasterNode.cs index dcdbacbe89f..070f81ac458 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricMasterNode.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricMasterNode.cs @@ -794,6 +794,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode); + HDSubShaderUtilities.AddPrePostPassProperties(collector, false, false); base.CollectShaderProperties(collector, generationMode); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs index fefeb3f5b21..e354ec5f0c0 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs @@ -15,7 +15,8 @@ class HairGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass + ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairMasterNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairMasterNode.cs index 9d7c6df5740..700b2149105 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairMasterNode.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairMasterNode.cs @@ -899,6 +899,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, alphaTestShadow.isOn); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode); + HDSubShaderUtilities.AddPrePostPassProperties(collector, alphaTestDepthPrepass.isOn, alphaTestDepthPostpass.isOn); base.CollectShaderProperties(collector, generationMode); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs index f0f3d03b87d..e41bc36ed26 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs @@ -15,7 +15,8 @@ class HDLitGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass + ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitMasterNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitMasterNode.cs index 4a416f917a6..e5062d7e708 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitMasterNode.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitMasterNode.cs @@ -1119,6 +1119,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, alphaTestShadow.isOn); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode); + HDSubShaderUtilities.AddPrePostPassProperties(collector, alphaTestDepthPrepass.isOn, alphaTestDepthPostpass.isOn); base.CollectShaderProperties(collector, generationMode); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs index dba83b9b46a..aec2a60c1b8 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs @@ -15,7 +15,8 @@ class StackLitGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass + ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitMasterNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitMasterNode.cs index 5a26461c754..6a212a98848 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitMasterNode.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitMasterNode.cs @@ -1424,6 +1424,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode); + HDSubShaderUtilities.AddPrePostPassProperties(collector, false, false); base.CollectShaderProperties(collector, generationMode); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs index 053bac86cbd..86bc32c050e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs @@ -26,6 +26,7 @@ public enum Features ReceiveSSR = 1 << 8, ShowAfterPostProcessPass = 1 << 9, Unlit = Surface | BlendMode | DoubleSided | DoubleSidedNormalMode | AlphaCutoff | AlphaCutoffShadowThreshold | AlphaCutoffThreshold | BackThenFrontRendering | ShowAfterPostProcessPass, + ShowPrePassAndPostPass = 1 << 11, Lit = All, All = ~0, } @@ -483,11 +484,14 @@ void DrawSurfaceGUI() if (transparentBackfaceEnable != null) materialEditor.ShaderProperty(transparentBackfaceEnable, Styles.transparentBackfaceEnableText); - if (transparentDepthPrepassEnable != null) - materialEditor.ShaderProperty(transparentDepthPrepassEnable, Styles.transparentDepthPrepassEnableText); + if ((m_Features & Features.ShowPrePassAndPostPass) != 0) + { + if (transparentDepthPrepassEnable != null) + materialEditor.ShaderProperty(transparentDepthPrepassEnable, Styles.transparentDepthPrepassEnableText); - if (transparentDepthPostpassEnable != null) - materialEditor.ShaderProperty(transparentDepthPostpassEnable, Styles.transparentDepthPostpassEnableText); + if (transparentDepthPostpassEnable != null) + materialEditor.ShaderProperty(transparentDepthPostpassEnable, Styles.transparentDepthPostpassEnableText); + } if (transparentWritingMotionVec != null) materialEditor.ShaderProperty(transparentWritingMotionVec, Styles.transparentWritingMotionVecText); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs index 0c887989336..01994b5ccc1 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs @@ -90,7 +90,8 @@ protected static void ResetMaterialCustomRenderQueue(Material material) } readonly static string[] floatPropertiesToSynchronize = { - "_UseShadowThreshold", kReceivesSSR, kUseSplitLighting + "_UseShadowThreshold", kReceivesSSR, kUseSplitLighting, + kTransparentDepthPrepassEnable, kTransparentDepthPostpassEnable }; protected static void SynchronizeShaderGraphProperties(Material material) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs index a3f577a6075..9d91aadf2a9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs @@ -16,7 +16,8 @@ class HDUnlitGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.DoubleSidedNormalMode - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; + ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering + ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitMasterNode.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitMasterNode.cs index 796960e98f0..3ad1dc98b42 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitMasterNode.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitMasterNode.cs @@ -495,6 +495,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSided.isOn ? DoubleSidedMode.Enabled : DoubleSidedMode.Disabled); + HDSubShaderUtilities.AddPrePostPassProperties(collector, false, false); base.CollectShaderProperties(collector, generationMode); } diff --git a/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDSubShaderUtilities.cs b/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDSubShaderUtilities.cs index 84e9a9d41a4..166a63de43e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDSubShaderUtilities.cs +++ b/com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDSubShaderUtilities.cs @@ -1336,6 +1336,12 @@ public static void AddDoubleSidedProperty(PropertyCollector collector, DoubleSid }); } + public static void AddPrePostPassProperties(PropertyCollector collector, bool prepass, bool postpass) + { + collector.AddToggleProperty(kTransparentDepthPrepassEnable, prepass); + collector.AddToggleProperty(kTransparentDepthPostpassEnable, postpass); + } + public static string RenderQueueName(HDRenderQueue.RenderQueueType value) { switch (value) From 2f7ebef61b852c298d9fab820f8c8967c5484fbc Mon Sep 17 00:00:00 2001 From: anisunity <42026998+anisunity@users.noreply.github.com> Date: Wed, 6 May 2020 00:05:18 +0200 Subject: [PATCH 34/81] Fixed a performance issue with stochastic ray traced area shadows. (#306) Co-authored-by: sebastienlagarde --- .../CHANGELOG.md | 1 + .../Shaders/Shadows/SphericalQuad.hlsl | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 5b12f75f7d1..a7ff1030e5a 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed shadowmask UI now correctly showing shadowmask disable - Fixed the indirect diffuse texture not being ignored when it should (ray tracing disabled). - Fixed depth prepass and postpass being disabled after changing the shader in the material UI. +- Fixed a performance issue with stochastic ray traced area shadows. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/SphericalQuad.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/SphericalQuad.hlsl index a2edee5e38f..77c34e66343 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/SphericalQuad.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/SphericalQuad.hlsl @@ -1,13 +1,17 @@ +// I am not sure why exactly, by a lower epsilon generates ray that even if they give a valid result with ray tracing +// nuke the performance. Changing the epsilon from 1e-6 to 1e-5 seems to solve the issue. +#define PLANE_INTERSECTION_EPSILON 1e-5 + bool IntersectPlane(float3 ray_origin, float3 ray_dir, float3 pos, float3 normal, out float t) { - float denom = dot(normal, ray_dir); - if (abs(denom) > 1e-6) - { - float3 d = pos - ray_origin; - t = dot(d, normal) / denom; - return (t >= 0); - } - return false; + float denom = dot(normal, ray_dir); + if (abs(denom) > PLANE_INTERSECTION_EPSILON) + { + float3 d = pos - ray_origin; + t = dot(d, normal) / denom; + return (t >= 0); + } + return false; } struct SphQuad @@ -72,7 +76,7 @@ void SphQuadInit(float3 s, float3 ex, float3 ey, float3 o, inout SphQuad squad) squad.b0 = n0.z; squad.b1 = n2.z; squad.b0sq = squad.b0 * squad.b0; - squad.k = 2.0f * PI - g2 - g3; + squad.k = 2.0f * PI - g2 - g3; // compute solid angle from internal angles squad.S = g0 + g1 - squad.k; From 774383d43c92c74762b565a4af842168d021bfa9 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Wed, 6 May 2020 10:04:14 +0200 Subject: [PATCH 35/81] [Backport 7.x.x] Updated raytracing async compute warning. (#304) * Made more explicit the warning about raytracing and asynchronous compute. Also fixed the condition in which it appears. * Update changelog Co-authored-by: sebastienlagarde --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../RenderPipeline/Settings/FrameSettingsUI.Drawers.cs | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index a7ff1030e5a..da70c6d9b45 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the indirect diffuse texture not being ignored when it should (ray tracing disabled). - Fixed depth prepass and postpass being disabled after changing the shader in the material UI. - Fixed a performance issue with stochastic ray traced area shadows. +- Made more explicit the warning about raytracing and asynchronous compute. Also fixed the condition in which it appears. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs index 3a5972baca5..38e6edc192a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs @@ -105,8 +105,11 @@ internal static CED.IDrawer InspectorInnerbox(bool withOverride = true) => CED.G RenderPipelineSettings hdrpSettings = GetHDRPAssetFor(owner).currentPlatformRenderPipelineSettings; if (hdrpSettings.supportRayTracing) { - if (serialized.IsEnabled(FrameSettingsField.AsyncCompute) ?? false) - EditorGUILayout.HelpBox("With Raytracing, the Asynchronous Execution will be forced to false", MessageType.Warning); + bool rtEffectUseAsync = (serialized.IsEnabled(FrameSettingsField.SSRAsync) ?? false) || (serialized.IsEnabled(FrameSettingsField.SSAOAsync) ?? false) + //|| (serialized.IsEnabled(FrameSettingsField.ContactShadowsAsync) ?? false) // Contact shadow async is not visible in the UI for now and defaults to true. + ; + if (rtEffectUseAsync) + EditorGUILayout.HelpBox("Asynchronous execution of Raytracing effects is not supported. Asynchronous Execution will be forced to false for them", MessageType.Warning); } })); From f5d67f14b491308d37e6751e25c0fae82af3a8f6 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Wed, 6 May 2020 10:07:49 +0200 Subject: [PATCH 36/81] [Backport 7.x.x] Fixed a null ref exception in static sky when the default volume profile is invalid. (#303) * Fixed a null ref exception in static sky when the default volume profile is invalid. * Update changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Sky/StaticLightingSky.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index da70c6d9b45..02111021a0e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed depth prepass and postpass being disabled after changing the shader in the material UI. - Fixed a performance issue with stochastic ray traced area shadows. - Made more explicit the warning about raytracing and asynchronous compute. Also fixed the condition in which it appears. +- Fixed a null ref exception in static sky when the default volume profile is invalid. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs index 38611f3af22..4dcaa52fabf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/StaticLightingSky.cs @@ -125,7 +125,9 @@ void UpdateCurrentStaticLightingSky() var profileSkyParameters = m_SkySettingsFromProfile.parameters; var defaultVolume = HDRenderPipeline.GetOrCreateDefaultVolume(); - defaultVolume.sharedProfile.TryGet(skyType, out SkySettings defaultSky); + SkySettings defaultSky = null; + if (defaultVolume.sharedProfile != null) // This can happen with old projects. + defaultVolume.sharedProfile.TryGet(skyType, out defaultSky); var defaultSkyParameters = defaultSky != null ? defaultSky.parameters : null; // Can be null if the profile does not contain the component. // Seems to inexplicably happen sometimes on domain reload. From 1731dedb27d8c1326b685625ff179e2ba3b3252f Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Wed, 6 May 2020 10:08:47 +0200 Subject: [PATCH 37/81] [Backport 7.x.x] Fixed an error about procedural sky being logged by mistake. (#307) * Fixed an error about procedural sky being logged by mistake. * Update changelog Co-authored-by: sebastienlagarde --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Sky/VisualEnvironment.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 02111021a0e..6bc9f3a247e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a performance issue with stochastic ray traced area shadows. - Made more explicit the warning about raytracing and asynchronous compute. Also fixed the condition in which it appears. - Fixed a null ref exception in static sky when the default volume profile is invalid. +- Fixed an error about procedural sky being logged by mistake. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/VisualEnvironment.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/VisualEnvironment.cs index 531e03b333f..94618852e64 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/VisualEnvironment.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/VisualEnvironment.cs @@ -11,7 +11,7 @@ namespace UnityEngine.Rendering.HighDefinition public sealed class VisualEnvironment : VolumeComponent { /// Type of sky that should be used for rendering. - public IntParameter skyType = new IntParameter(0); + public NoInterpIntParameter skyType = new NoInterpIntParameter(0); /// Defines the way the ambient probe should be computed. public SkyAmbientModeParameter skyAmbientMode = new SkyAmbientModeParameter(SkyAmbientMode.Static); From 6876810b337285afae8421d2f7a71b7e5ee43508 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Wed, 6 May 2020 14:29:40 +0200 Subject: [PATCH 38/81] [Backport 7.x.x] Fix flickering lighting in the scene and game view when lookdev is open. (#379) * Fixed flickering of the game/scene view when lookdev is running. * Update changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Sky/SkyManager.cs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 6bc9f3a247e..8a3b62f0e58 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Made more explicit the warning about raytracing and asynchronous compute. Also fixed the condition in which it appears. - Fixed a null ref exception in static sky when the default volume profile is invalid. - Fixed an error about procedural sky being logged by mistake. +- Fixed flickering of the game/scene view when lookdev is running. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. 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 52bb03f685c..1192bc4e189 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -697,7 +697,7 @@ public void UpdateEnvironment( HDCamera hdCamera, // This is to avoid cases in which the probe camera is below ground and the parent is not, leading to // in case of PBR sky to a black sky. All other parameters are left as is. // This can introduce inaccuracies, but they should be acceptable if the distance parent camera - probe camera is - // small. + // small. if (hdCamera.camera.cameraType == CameraType.Reflection && hdCamera.parentCamera != null) { worldSpaceCameraPos = hdCamera.parentCamera.transform.position; @@ -794,13 +794,14 @@ public void UpdateEnvironment(HDCamera hdCamera, ScriptableRenderContext renderC // because we only maintain one static sky. Since we don't care that the static lighting may be a bit different in the preview we never recompute // and we use the one from the main camera. bool forceStaticUpdate = false; + StaticLightingSky staticLightingSky = GetStaticLightingSky(); #if UNITY_EDITOR - // In the editor, we might need the static sky ready for baking lightmaps/lightprobes regardless of the current ambient mode so we force it to update in this case. - forceStaticUpdate = true; + // In the editor, we might need the static sky ready for baking lightmaps/lightprobes regardless of the current ambient mode so we force it to update in this case if it's not been computed yet.. + // We don't test if the hash of the static sky has changed here because it depends on the sun direction and in the case of LookDev, sun will be different from the main rendering so it will induce improper recomputation. + forceStaticUpdate = staticLightingSky != null && m_StaticLightingSky.skyParametersHash == -1; ; #endif if ((ambientMode == SkyAmbientMode.Static || forceStaticUpdate) && hdCamera.camera.cameraType != CameraType.Preview) { - StaticLightingSky staticLightingSky = GetStaticLightingSky(); if (staticLightingSky != null) { m_StaticLightingSky.skySettings = staticLightingSky.skySettings; From 722d7b172213895d6056372758b14f0dad378984 Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Wed, 6 May 2020 14:38:33 +0200 Subject: [PATCH 39/81] [7.x.x Backport] Fix issue with ambient probe not being correct with OnEnable/OnDemand probes (#317) * render until ambient probe is ready * remove comment * changelog --- .../CHANGELOG.md | 1 + .../Runtime/Lighting/Reflection/HDProbe.cs | 7 +++ .../RenderPipeline/HDRenderPipeline.cs | 44 ++++++++++++------- .../Runtime/Sky/SkyManager.cs | 18 ++++++++ .../Runtime/Sky/SkyRenderingContext.cs | 4 ++ 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 8a3b62f0e58..9903b4a87e8 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -629,6 +629,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added a fix script to handle the warning 'referenced script in (GameObject 'SceneIDMap') is missing' - Fix Wizard load when none selected for RenderPipelineAsset - Fixed issue with unclear naming of debug menu for decals. +- Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047). ### Changed - Color buffer pyramid is not allocated anymore if neither refraction nor distortion are enabled 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 d7acda444b7..145981a32b3 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 @@ -428,6 +428,13 @@ public virtual void PrepareCulling() { } /// public void RequestRenderNextUpdate() => m_WasRenderedSinceLastOnDemandRequest = false; + // Forces the re-rendering for both OnDemand and OnEnable + internal void ForceRenderingNextUpdate() + { + m_WasRenderedSinceLastOnDemandRequest = false; + wasRenderedAfterOnEnable = false; + } + void UpdateProbeName() { // TODO: ask if this is ok: diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 0ac757e2b14..7d3d93693fa 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1620,6 +1620,14 @@ ref _cullingResults continue; } + // HACK! We render the probe until we know the ambient probe for the associated sky context is ready. + // For one-off rendering the dynamic ambient probe will be set to black until they are not processed, leading to faulty rendering. + // So we enqueue another rendering and then we will not set the probe texture until we have rendered with valid ambient probe. + if (!m_SkyManager.HasSetValidAmbientProbe(hdCamera)) + { + visibleProbe.ForceRenderingNextUpdate(); + } + hdCamera.parentCamera = parentCamera; // Used to inherit the properties of the view HDAdditionalCameraData hdCam; @@ -1666,26 +1674,30 @@ ref _cullingResults // TODO: store DecalCullResult }; - // As we render realtime texture on GPU side, we must tag the texture so our texture array cache detect that something have change - visibleProbe.realtimeTexture.IncrementUpdateCount(); - - if (cameraSettings.Count > 1) + if (m_SkyManager.HasSetValidAmbientProbe(hdCamera)) { - var face = (CubemapFace)j; - request.target = new RenderRequest.Target + // As we render realtime texture on GPU side, we must tag the texture so our texture array cache detect that something have change + visibleProbe.realtimeTexture.IncrementUpdateCount(); + + if (cameraSettings.Count > 1) { - copyToTarget = visibleProbe.realtimeTexture, - face = face - }; - } - else - { - request.target = new RenderRequest.Target + var face = (CubemapFace)j; + request.target = new RenderRequest.Target + { + copyToTarget = visibleProbe.realtimeTexture, + face = face + }; + } + else { - id = visibleProbe.realtimeTexture, - face = CubemapFace.Unknown - }; + request.target = new RenderRequest.Target + { + id = visibleProbe.realtimeTexture, + face = CubemapFace.Unknown + }; + } } + renderRequests.Add(request); 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 1192bc4e189..ba9ba4d50de 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyManager.cs @@ -413,6 +413,24 @@ internal SphericalHarmonicsL2 GetAmbientProbe(HDCamera hdCamera) return GetAmbientProbe(hdCamera.lightingSky); } + internal bool HasSetValidAmbientProbe(HDCamera hdCamera) + { + SkyAmbientMode ambientMode = hdCamera.volumeStack.GetComponent().skyAmbientMode.value; + if (ambientMode == SkyAmbientMode.Static) + return true; + + if (hdCamera.skyAmbientMode == SkyAmbientMode.Dynamic && hdCamera.lightingSky != null && + hdCamera.lightingSky.IsValid() && IsCachedContextValid(hdCamera.lightingSky)) + { + ref CachedSkyContext cachedContext = ref m_CachedSkyContexts[hdCamera.lightingSky.cachedSkyRenderingContextId]; + var renderingContext = cachedContext.renderingContext; + return renderingContext.ambientProbeIsReady; + } + + return false; + + } + internal void SetupAmbientProbe(HDCamera hdCamera) { // Working around GI current system diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderingContext.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderingContext.cs index d03791d1d2b..9016477b396 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderingContext.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyRenderingContext.cs @@ -14,6 +14,8 @@ internal class SkyRenderingContext public CubemapArray skyboxBSDFCubemapArray { get; private set; } public bool supportsConvolution { get; private set; } = false; + internal bool ambientProbeIsReady = false; + public SkyRenderingContext(int resolution, int bsdfCount, bool supportsConvolution, SphericalHarmonicsL2 ambientProbe, string name) { m_AmbientProbe = ambientProbe; @@ -71,6 +73,8 @@ public void OnComputeAmbientProbeDone(AsyncGPUReadbackRequest request) m_AmbientProbe[channel, coeff] = result[channel * 9 + coeff]; } } + + ambientProbeIsReady = true; } } } From c4bbd9f9fe6b59b5a46bf925db0b2afad612f567 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Thu, 14 May 2020 14:00:07 +0200 Subject: [PATCH 40/81] [Backport 7.x.x] Fixed some gcalloc in the debug window (#464) * Fixed some GCAlloc in the debug window # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/Debug/VolumeDebug.cs * Update changelog --- .../Editor/Debugging/DebugUIDrawer.cs | 4 +++- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs index 2dd6c162e83..38845ceeda3 100644 --- a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs @@ -36,10 +36,12 @@ protected T Cast(object o) where T : class { var casted = o as T; - string typeName = o == null ? "null" : o.GetType().ToString(); if (casted == null) + { + string typeName = o == null ? "null" : o.GetType().ToString(); throw new InvalidOperationException("Can't cast " + typeName + " to " + typeof(T)); + } return casted; } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 9903b4a87e8..250273c181b 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a null ref exception in static sky when the default volume profile is invalid. - Fixed an error about procedural sky being logged by mistake. - Fixed flickering of the game/scene view when lookdev is running. +- Fixed some GCAlloc in the debug window. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. From b2117a4443774762dd71d2a5cee42b7b86549709 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Thu, 14 May 2020 14:00:50 +0200 Subject: [PATCH 41/81] [Backport 7.x.x] Hdrp/small ui update (#466) * Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. # Conflicts: # com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs # com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs * update changelog --- .../CHANGELOG.md | 1 + .../Lighting/Shadow/ContactShadowsEditor.cs | 21 +++++++-------- .../Sky/AtmosphericScattering/FogEditor.cs | 26 +++++++++---------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 250273c181b..3128065c300 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an error about procedural sky being logged by mistake. - Fixed flickering of the game/scene view when lookdev is running. - Fixed some GCAlloc in the debug window. +- Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs index 3e49aee4062..d53a14c64c3 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Shadow/ContactShadowsEditor.cs @@ -37,18 +37,15 @@ public override void OnInspectorGUI() if (!m_Enable.value.hasMultipleDifferentValues) { - using (new EditorGUI.DisabledGroupScope(!m_Enable.value.boolValue)) - { - PropertyField(m_Length, EditorGUIUtility.TrTextContent("Length", "Controls the length of the rays HDRP uses to calculate Contact Shadows. Uses meters.")); - PropertyField(m_DistanceScaleFactor, EditorGUIUtility.TrTextContent("Distance Scale Factor", "Dampens the scale up effect HDRP process with distance from the Camera.")); - PropertyField(m_MaxDistance, EditorGUIUtility.TrTextContent("Max Distance", "Sets The distance from the Camera at which HDRP begins to fade out Contact Shadows. Uses meters.")); - PropertyField(m_FadeDistance, EditorGUIUtility.TrTextContent("Fade Distance", "Sets the distance over which HDRP fades Contact Shadows out when at the Max Distance. Uses meters.")); - PropertyField(m_Opacity, EditorGUIUtility.TrTextContent("Opacity", "Controls the opacity of the Contact Shadow.")); - base.OnInspectorGUI(); - GUI.enabled = useCustomValue; - PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Controls the number of samples HDRP uses for ray casting.")); - GUI.enabled = true; - } + PropertyField(m_Length, EditorGUIUtility.TrTextContent("Length", "Controls the length of the rays HDRP uses to calculate Contact Shadows. Uses meters.")); + PropertyField(m_DistanceScaleFactor, EditorGUIUtility.TrTextContent("Distance Scale Factor", "Dampens the scale up effect HDRP process with distance from the Camera.")); + PropertyField(m_MaxDistance, EditorGUIUtility.TrTextContent("Max Distance", "Sets The distance from the Camera at which HDRP begins to fade out Contact Shadows. Uses meters.")); + PropertyField(m_FadeDistance, EditorGUIUtility.TrTextContent("Fade Distance", "Sets the distance over which HDRP fades Contact Shadows out when at the Max Distance. Uses meters.")); + PropertyField(m_Opacity, EditorGUIUtility.TrTextContent("Opacity", "Controls the opacity of the Contact Shadow.")); + base.OnInspectorGUI(); + GUI.enabled = useCustomValue; + PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Controls the number of samples HDRP uses for ray casting.")); + GUI.enabled = true; } } } diff --git a/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs index ce918bb696b..26a6e07fb47 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Sky/AtmosphericScattering/FogEditor.cs @@ -106,22 +106,20 @@ public override void OnInspectorGUI() if (volumetricLightingAvailable) { PropertyField(m_EnableVolumetricFog, s_EnableVolumetricFog); - if (m_EnableVolumetricFog.value.boolValue) + + EditorGUI.indentLevel++; + PropertyField(m_Albedo, s_AlbedoLabel); + PropertyField(m_Anisotropy, s_AnisotropyLabel); + PropertyField(m_GlobalLightProbeDimmer, s_GlobalLightProbeDimmerLabel); + + if (isInAdvancedMode) { - EditorGUI.indentLevel++; - PropertyField(m_Albedo, s_AlbedoLabel); - PropertyField(m_Anisotropy, s_AnisotropyLabel); - PropertyField(m_GlobalLightProbeDimmer, s_GlobalLightProbeDimmerLabel); - - if (isInAdvancedMode) - { - PropertyField(m_DepthExtent); - PropertyField(m_SliceDistributionUniformity); - PropertyField(m_Filter); - } - - EditorGUI.indentLevel--; + PropertyField(m_DepthExtent); + PropertyField(m_SliceDistributionUniformity); + PropertyField(m_Filter); } + + EditorGUI.indentLevel--; } } } From 390355086635fb4798ff7586b54664c0c02e17ae Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Thu, 14 May 2020 16:04:25 +0200 Subject: [PATCH 42/81] [Backport 7.x.x] PBR Sky renderer now shares its internal precomputation table between different instances. (#482) * PBR Sky renderer now shares its internal precomputation table between different instances. # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs * Doc update * Update changelog --- .../CHANGELOG.md | 1 + .../Documentation~/Creating-a-Custom-Sky.md | 10 + .../Runtime/RenderPipeline/Camera/HDCamera.cs | 2 + .../PhysicallyBasedSky/PhysicallyBasedSky.cs | 44 -- .../PhysicallyBasedSkyRenderer.cs | 516 ++++++++++-------- .../Runtime/Sky/SkyUpdateContext.cs | 16 +- 6 files changed, 324 insertions(+), 265 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3128065c300..1ff07e6456a 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed flickering of the game/scene view when lookdev is running. - Fixed some GCAlloc in the debug window. - Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. +- Fixed over consumption of GPU memory by the Physically Based Sky. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Creating-a-Custom-Sky.md b/com.unity.render-pipelines.high-definition/Documentation~/Creating-a-Custom-Sky.md index 35ed85d4180..d2c7f8a1a87 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Creating-a-Custom-Sky.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Creating-a-Custom-Sky.md @@ -59,6 +59,12 @@ public class NewSky : SkySettings } return hash; } + + public override int GetHashCode(Camera camera) + { + // Implement if your sky depends on the camera settings (like position for instance) + return GetHashCode(); + } } ``` @@ -159,6 +165,10 @@ class NewSkyRenderer : SkyRenderer } ``` +### Important note: +If your sky renderer has to manage heavy data (like precomputed textures or similar things) then particular care has to be taken. Indeed, one instance of the renderer will exist per camera so by default if this data is a member of the renderer, it willl also be duplicated in memory. +Since each sky renderer can have very different needs, the responsbility to share this kind of data is the renderer's and need to be implemented by the user. + ## Sky rendering Shader diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 3bad967b950..cf01f7c97be 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Collections.Generic; using System.Linq; using Utilities; @@ -18,6 +19,7 @@ namespace UnityEngine.Rendering.HighDefinition /// HDCamera class. /// This class holds all information for a given camera. Constants used for shading as well as buffers persistent from one frame to another etc. /// + [DebuggerDisplay("({camera.name})")] public class HDCamera { #region Public API diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs index 202f4be7312..03bb3b49385 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSky.cs @@ -289,24 +289,6 @@ internal int GetPrecomputationHashCode() unchecked { #if UNITY_2019_3 // In 2019.3, when we call GetHashCode on a VolumeParameter it generate garbage (due to the boxing of the generic parameter) - // These parameters affect precomputation. - hash = hash * 23 + earthPreset.value.GetHashCode(); - hash = hash * 23 + planetaryRadius.value.GetHashCode(); - hash = hash * 23 + groundTint.value.GetHashCode(); - - hash = hash * 23 + airMaximumAltitude.value.GetHashCode(); - hash = hash * 23 + airDensityR.value.GetHashCode(); - hash = hash * 23 + airDensityG.value.GetHashCode(); - hash = hash * 23 + airDensityB.value.GetHashCode(); - hash = hash * 23 + airTint.value.GetHashCode(); - - hash = hash * 23 + aerosolMaximumAltitude.value.GetHashCode(); - hash = hash * 23 + aerosolDensity.value.GetHashCode(); - hash = hash * 23 + aerosolTint.value.GetHashCode(); - hash = hash * 23 + aerosolAnisotropy.value.GetHashCode(); - - hash = hash * 23 + numberOfBounces.value.GetHashCode(); - // These parameters affect precomputation. hash = hash * 23 + earthPreset.overrideState.GetHashCode(); hash = hash * 23 + planetaryRadius.overrideState.GetHashCode(); @@ -376,32 +358,6 @@ public override int GetHashCode() { #if UNITY_2019_3 // In 2019.3, when we call GetHashCode on a VolumeParameter it generate garbage (due to the boxing of the generic parameter) // These parameters do NOT affect precomputation. - hash = hash * 23 + sphericalMode.value.GetHashCode(); - hash = hash * 23 + seaLevel.value.GetHashCode(); - hash = hash * 23 + planetCenterPosition.value.GetHashCode(); - hash = hash * 23 + planetRotation.value.GetHashCode(); - - if (groundColorTexture.value != null) - hash = hash * 23 + groundColorTexture.value.GetHashCode(); - - if (groundEmissionTexture.value != null) - hash = hash * 23 + groundEmissionTexture.value.GetHashCode(); - - hash = hash * 23 + groundEmissionMultiplier.value.GetHashCode(); - - hash = hash * 23 + spaceRotation.value.GetHashCode(); - - if (spaceEmissionTexture.value != null) - hash = hash * 23 + spaceEmissionTexture.value.GetHashCode(); - - hash = hash * 23 + spaceEmissionMultiplier.value.GetHashCode(); - hash = hash * 23 + colorSaturation.value.GetHashCode(); - hash = hash * 23 + alphaSaturation.value.GetHashCode(); - hash = hash * 23 + alphaMultiplier.value.GetHashCode(); - hash = hash * 23 + horizonTint.value.GetHashCode(); - hash = hash * 23 + zenithTint.value.GetHashCode(); - hash = hash * 23 + horizonZenithShift.value.GetHashCode(); - hash = hash * 23 + sphericalMode.overrideState.GetHashCode(); hash = hash * 23 + seaLevel.overrideState.GetHashCode(); hash = hash * 23 + planetCenterPosition.overrideState.GetHashCode(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs index 6c206f55888..03767aec550 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/PhysicallyBasedSky/PhysicallyBasedSkyRenderer.cs @@ -1,10 +1,291 @@ using System; +using System.Collections.Generic; using UnityEngine.Experimental.Rendering; namespace UnityEngine.Rendering.HighDefinition { class PhysicallyBasedSkyRenderer : SkyRenderer { + class PrecomputationCache + { + class RefCountedData + { + public int refCount; + public PrecomputationData data = new PrecomputationData(); + } + + ObjectPool m_DataPool = new ObjectPool(null, null); + Dictionary m_CachedData = new Dictionary(); + + public PrecomputationData Get(int hash) + { + RefCountedData result; + if (m_CachedData.TryGetValue(hash, out result)) + { + result.refCount++; + return result.data; + } + else + { + result = m_DataPool.Get(); + result.refCount = 1; + result.data.Allocate(); + m_CachedData.Add(hash, result); + return result.data; + } + } + + public void Release(int hash) + { + if (m_CachedData.TryGetValue(hash, out var result)) + { + result.refCount--; + if (result.refCount == 0) + { + result.data.Release(); + m_CachedData.Remove(hash); + m_DataPool.Release(result); + } + } + } + } + + class PrecomputationData + { + // We compute at most one bounce per frame for perf reasons. + // We need to store the frame index because more than one render can happen during a frame (cubemap update + regular rendering). + int m_LastPrecomputedBounce; + int m_LastFrameComputation; + + RTHandle[] m_GroundIrradianceTables; // All orders, one order + RTHandle[] m_InScatteredRadianceTables; // Air SS, Aerosol SS, Atmosphere MS, Atmosphere one order, Temp + + RTHandle AllocateGroundIrradianceTable(int index) + { + var table = RTHandles.Alloc((int)PbrSkyConfig.GroundIrradianceTableSize, 1, + colorFormat: s_ColorFormat, + enableRandomWrite: true, + name: string.Format("GroundIrradianceTable{0}", index)); + + Debug.Assert(table != null); + + return table; + } + + RTHandle AllocateInScatteredRadianceTable(int index) + { + // Emulate a 4D texture with a "deep" 3D texture. + var table = RTHandles.Alloc((int)PbrSkyConfig.InScatteredRadianceTableSizeX, + (int)PbrSkyConfig.InScatteredRadianceTableSizeY, + (int)PbrSkyConfig.InScatteredRadianceTableSizeZ * + (int)PbrSkyConfig.InScatteredRadianceTableSizeW, + dimension: TextureDimension.Tex3D, + colorFormat: s_ColorFormat, + enableRandomWrite: true, + name: string.Format("InScatteredRadianceTable{0}", index)); + + Debug.Assert(table != null); + + return table; + } + + public void Allocate() + { + m_LastFrameComputation = -1; + m_LastPrecomputedBounce = 0; + + // No temp tables. + m_GroundIrradianceTables = new RTHandle[2]; + m_GroundIrradianceTables[0] = AllocateGroundIrradianceTable(0); + + m_InScatteredRadianceTables = new RTHandle[5]; + m_InScatteredRadianceTables[0] = AllocateInScatteredRadianceTable(0); + m_InScatteredRadianceTables[1] = AllocateInScatteredRadianceTable(1); + m_InScatteredRadianceTables[2] = AllocateInScatteredRadianceTable(2); + } + + public void Release() + { + RTHandles.Release(m_GroundIrradianceTables[0]); m_GroundIrradianceTables[0] = null; + RTHandles.Release(m_GroundIrradianceTables[1]); m_GroundIrradianceTables[1] = null; + RTHandles.Release(m_InScatteredRadianceTables[0]); m_InScatteredRadianceTables[0] = null; + RTHandles.Release(m_InScatteredRadianceTables[1]); m_InScatteredRadianceTables[1] = null; + RTHandles.Release(m_InScatteredRadianceTables[2]); m_InScatteredRadianceTables[2] = null; + RTHandles.Release(m_InScatteredRadianceTables[3]); m_InScatteredRadianceTables[3] = null; + RTHandles.Release(m_InScatteredRadianceTables[4]); m_InScatteredRadianceTables[4] = null; + } + + void PrecomputeTables(CommandBuffer cmd) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.InScatteredRadiancePrecomputation))) + { + int order = m_LastPrecomputedBounce + 1; + { + // For efficiency reasons, multiple scattering is computed in 2 passes: + // 1. Gather the in-scattered radiance over the entire sphere of directions. + // 2. Accumulate the in-scattered radiance along the ray. + // Single scattering performs both steps during the same pass. + + int firstPass = Math.Min(order - 1, 2); + int accumPass = 3; + int numPasses = Math.Min(order, 2); + + for (int i = 0; i < numPasses; i++) + { + int pass = (i == 0) ? firstPass : accumPass; + + switch (pass) + { + case 0: + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AirSingleScatteringTable, m_InScatteredRadianceTables[0]); + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AerosolSingleScatteringTable, m_InScatteredRadianceTables[1]); + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[2]); // MS orders + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTableOrder, m_InScatteredRadianceTables[3]); // One order + break; + case 1: + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._GroundIrradianceTexture, m_GroundIrradianceTables[1]); // One order + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[4]); // Temp + break; + case 2: + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[3]); // One order + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._GroundIrradianceTexture, m_GroundIrradianceTables[1]); // One order + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[4]); // Temp + break; + case 3: + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[4]); // Temp + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTableOrder, m_InScatteredRadianceTables[3]); // One order + cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[2]); // MS orders + break; + default: + Debug.Assert(false); + break; + } + + // Re-illuminate the sky with each bounce. + // Emulate a 4D dispatch with a "deep" 3D dispatch. + cmd.DispatchCompute(s_InScatteredRadiancePrecomputationCS, pass, (int)PbrSkyConfig.InScatteredRadianceTableSizeX / 4, + (int)PbrSkyConfig.InScatteredRadianceTableSizeY / 4, + (int)PbrSkyConfig.InScatteredRadianceTableSizeZ / 4 * + (int)PbrSkyConfig.InScatteredRadianceTableSizeW); + } + + { + // Used by all passes. + cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._GroundIrradianceTable, m_GroundIrradianceTables[0]); // All orders + cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._GroundIrradianceTableOrder, m_GroundIrradianceTables[1]); // One order + } + + switch (firstPass) + { + case 0: + break; + case 1: + cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); + cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); + break; + case 2: + cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[3]); // One order + break; + default: + Debug.Assert(false); + break; + } + + // Re-illuminate the ground with each bounce. + cmd.DispatchCompute(s_GroundIrradiancePrecomputationCS, firstPass, (int)PbrSkyConfig.GroundIrradianceTableSize / 64, 1, 1); + } + } + } + + public void BindGlobalBuffers(CommandBuffer cmd) + { + // TODO: ground irradiance table? Volume SH? Something else? + if (m_LastPrecomputedBounce > 0) + { + cmd.SetGlobalTexture(HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); + cmd.SetGlobalTexture(HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); + cmd.SetGlobalTexture(HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[2]); + } + else + { + cmd.SetGlobalTexture(HDShaderIDs._AirSingleScatteringTexture, CoreUtils.blackVolumeTexture); + cmd.SetGlobalTexture(HDShaderIDs._AerosolSingleScatteringTexture, CoreUtils.blackVolumeTexture); + cmd.SetGlobalTexture(HDShaderIDs._MultipleScatteringTexture, CoreUtils.blackVolumeTexture); + } + } + + public void BindBuffers(CommandBuffer cmd, MaterialPropertyBlock mpb) + { + if (m_LastPrecomputedBounce != 0) + { + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._GroundIrradianceTexture, m_GroundIrradianceTables[0]); + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[2]); + } + else + { + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._GroundIrradianceTexture, Texture2D.blackTexture); + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AirSingleScatteringTexture, CoreUtils.blackVolumeTexture); + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AerosolSingleScatteringTexture, CoreUtils.blackVolumeTexture); + s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._MultipleScatteringTexture, CoreUtils.blackVolumeTexture); + } + + } + + public bool Update(BuiltinSkyParameters builtinParams, PhysicallyBasedSky pbrSky) + { + if (builtinParams.frameIndex <= m_LastFrameComputation) + return false; + + m_LastFrameComputation = builtinParams.frameIndex; + + if (m_LastPrecomputedBounce == 0) + { + // Allocate temp tables if needed + if (m_GroundIrradianceTables[1] == null) + { + m_GroundIrradianceTables[1] = AllocateGroundIrradianceTable(1); + } + + if (m_InScatteredRadianceTables[3] == null) + { + m_InScatteredRadianceTables[3] = AllocateInScatteredRadianceTable(3); + } + + if (m_InScatteredRadianceTables[4] == null) + { + m_InScatteredRadianceTables[4] = AllocateInScatteredRadianceTable(4); + } + } + + if (m_LastPrecomputedBounce == pbrSky.numberOfBounces.value) + { + // Free temp tables. + // This is a deferred release (one frame late)! + RTHandles.Release(m_GroundIrradianceTables[1]); + RTHandles.Release(m_InScatteredRadianceTables[3]); + RTHandles.Release(m_InScatteredRadianceTables[4]); + m_GroundIrradianceTables[1] = null; + m_InScatteredRadianceTables[3] = null; + m_InScatteredRadianceTables[4] = null; + } + + if (m_LastPrecomputedBounce < pbrSky.numberOfBounces.value) + { + PrecomputeTables(builtinParams.commandBuffer); + m_LastPrecomputedBounce++; + + // If the sky is realtime, an upcoming update will update the sky lighting. Otherwise we need to force an update. + return builtinParams.skySettings.updateMode != EnvironmentUpdateMode.Realtime; + } + + return false; + } + } + [GenerateHLSL] public enum PbrSkyConfig { @@ -22,49 +303,18 @@ public enum PbrSkyConfig // If the hash does not match, we must recompute our data. int m_LastPrecomputationParamHash; - // We compute at most one bounce per frame for perf reasons. - // We need to store the frame index because more than one render can happen during a frame (cubemap update + regular rendering). - int m_LastPrecomputedBounce; - // Precomputed data below. - RTHandle[] m_GroundIrradianceTables; // All orders, one order - RTHandle[] m_InScatteredRadianceTables; // Air SS, Aerosol SS, Atmosphere MS, Atmosphere one order, Temp + PrecomputationData m_PrecomputedData; static ComputeShader s_GroundIrradiancePrecomputationCS; static ComputeShader s_InScatteredRadiancePrecomputationCS; - Material s_PbrSkyMaterial; + Material m_PbrSkyMaterial; static MaterialPropertyBlock s_PbrSkyMaterialProperties; - static GraphicsFormat s_ColorFormat = GraphicsFormat.R16G16B16A16_SFloat; - - RTHandle AllocateGroundIrradianceTable(int index) - { - var table = RTHandles.Alloc((int)PbrSkyConfig.GroundIrradianceTableSize, 1, - colorFormat: s_ColorFormat, - enableRandomWrite: true, - name: string.Format("GroundIrradianceTable{0}", index)); + static PrecomputationCache s_PrecomputaionCache = new PrecomputationCache(); - Debug.Assert(table != null); - - return table; - } + static GraphicsFormat s_ColorFormat = GraphicsFormat.R16G16B16A16_SFloat; - RTHandle AllocateInScatteredRadianceTable(int index) - { - // Emulate a 4D texture with a "deep" 3D texture. - var table = RTHandles.Alloc((int)PbrSkyConfig.InScatteredRadianceTableSizeX, - (int)PbrSkyConfig.InScatteredRadianceTableSizeY, - (int)PbrSkyConfig.InScatteredRadianceTableSizeZ * - (int)PbrSkyConfig.InScatteredRadianceTableSizeW, - dimension: TextureDimension.Tex3D, - colorFormat: s_ColorFormat, - enableRandomWrite: true, - name: string.Format("InScatteredRadianceTable{0}", index)); - - Debug.Assert(table != null); - - return table; - } public PhysicallyBasedSkyRenderer() { @@ -80,54 +330,28 @@ public override void Build() s_InScatteredRadiancePrecomputationCS = hdrpResources.shaders.inScatteredRadiancePrecomputationCS; s_PbrSkyMaterialProperties = new MaterialPropertyBlock(); - s_PbrSkyMaterial = CoreUtils.CreateEngineMaterial(hdrpResources.shaders.physicallyBasedSkyPS); + m_PbrSkyMaterial = CoreUtils.CreateEngineMaterial(hdrpResources.shaders.physicallyBasedSkyPS); Debug.Assert(s_GroundIrradiancePrecomputationCS != null); Debug.Assert(s_InScatteredRadiancePrecomputationCS != null); - - // No temp tables. - m_GroundIrradianceTables = new RTHandle[2]; - m_GroundIrradianceTables[0] = AllocateGroundIrradianceTable(0); - - m_InScatteredRadianceTables = new RTHandle[5]; - m_InScatteredRadianceTables[0] = AllocateInScatteredRadianceTable(0); - m_InScatteredRadianceTables[1] = AllocateInScatteredRadianceTable(1); - m_InScatteredRadianceTables[2] = AllocateInScatteredRadianceTable(2); } public override void SetGlobalSkyData(CommandBuffer cmd, BuiltinSkyParameters builtinParams) { UpdateGlobalConstantBuffer(cmd, builtinParams); - - // TODO: ground irradiance table? Volume SH? Something else? - if (m_LastPrecomputedBounce > 0) - { - cmd.SetGlobalTexture(HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); - cmd.SetGlobalTexture(HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); - cmd.SetGlobalTexture(HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[2]); - } - else - { - cmd.SetGlobalTexture(HDShaderIDs._AirSingleScatteringTexture, CoreUtils.blackVolumeTexture); - cmd.SetGlobalTexture(HDShaderIDs._AerosolSingleScatteringTexture, CoreUtils.blackVolumeTexture); - cmd.SetGlobalTexture(HDShaderIDs._MultipleScatteringTexture, CoreUtils.blackVolumeTexture); - } - + if (m_PrecomputedData != null) + m_PrecomputedData.BindGlobalBuffers(builtinParams.commandBuffer); } public override void Cleanup() { - RTHandles.Release(m_GroundIrradianceTables[0]); m_GroundIrradianceTables[0] = null; - RTHandles.Release(m_GroundIrradianceTables[1]); m_GroundIrradianceTables[1] = null; - RTHandles.Release(m_InScatteredRadianceTables[0]); m_InScatteredRadianceTables[0] = null; - RTHandles.Release(m_InScatteredRadianceTables[1]); m_InScatteredRadianceTables[1] = null; - RTHandles.Release(m_InScatteredRadianceTables[2]); m_InScatteredRadianceTables[2] = null; - RTHandles.Release(m_InScatteredRadianceTables[3]); m_InScatteredRadianceTables[3] = null; - RTHandles.Release(m_InScatteredRadianceTables[4]); m_InScatteredRadianceTables[4] = null; - - CoreUtils.Destroy(s_PbrSkyMaterial); - - m_LastPrecomputedBounce = 0; + if (m_PrecomputedData != null) + { + s_PrecomputaionCache.Release(m_LastPrecomputationParamHash); + m_LastPrecomputationParamHash = 0; + m_PrecomputedData = null; + } + CoreUtils.Destroy(m_PbrSkyMaterial); } static float CornetteShanksPhasePartConstant(float anisotropy) @@ -197,90 +421,6 @@ void UpdateGlobalConstantBuffer(CommandBuffer cmd, BuiltinSkyParameters builtinP cmd.SetGlobalFloat( HDShaderIDs._HorizonZenithShiftScale, expParams.y); } - void PrecomputeTables(CommandBuffer cmd) - { - using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.InScatteredRadiancePrecomputation))) - { - int order = m_LastPrecomputedBounce + 1; - { - // For efficiency reasons, multiple scattering is computed in 2 passes: - // 1. Gather the in-scattered radiance over the entire sphere of directions. - // 2. Accumulate the in-scattered radiance along the ray. - // Single scattering performs both steps during the same pass. - - int firstPass = Math.Min(order - 1, 2); - int accumPass = 3; - int numPasses = Math.Min(order, 2); - - for (int i = 0; i < numPasses; i++) - { - int pass = (i == 0) ? firstPass : accumPass; - - switch (pass) - { - case 0: - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AirSingleScatteringTable, m_InScatteredRadianceTables[0]); - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AerosolSingleScatteringTable, m_InScatteredRadianceTables[1]); - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[2]); // MS orders - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTableOrder, m_InScatteredRadianceTables[3]); // One order - break; - case 1: - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._GroundIrradianceTexture, m_GroundIrradianceTables[1]); // One order - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[4]); // Temp - break; - case 2: - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[3]); // One order - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._GroundIrradianceTexture, m_GroundIrradianceTables[1]); // One order - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[4]); // Temp - break; - case 3: - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[4]); // Temp - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTableOrder, m_InScatteredRadianceTables[3]); // One order - cmd.SetComputeTextureParam(s_InScatteredRadiancePrecomputationCS, pass, HDShaderIDs._MultipleScatteringTable, m_InScatteredRadianceTables[2]); // MS orders - break; - default: - Debug.Assert(false); - break; - } - - // Re-illuminate the sky with each bounce. - // Emulate a 4D dispatch with a "deep" 3D dispatch. - cmd.DispatchCompute(s_InScatteredRadiancePrecomputationCS, pass, (int)PbrSkyConfig.InScatteredRadianceTableSizeX / 4, - (int)PbrSkyConfig.InScatteredRadianceTableSizeY / 4, - (int)PbrSkyConfig.InScatteredRadianceTableSizeZ / 4 * - (int)PbrSkyConfig.InScatteredRadianceTableSizeW); - } - - { - // Used by all passes. - cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._GroundIrradianceTable, m_GroundIrradianceTables[0]); // All orders - cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._GroundIrradianceTableOrder, m_GroundIrradianceTables[1]); // One order - } - - switch (firstPass) - { - case 0: - break; - case 1: - cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); - cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); - break; - case 2: - cmd.SetComputeTextureParam(s_GroundIrradiancePrecomputationCS, firstPass, HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[3]); // One order - break; - default: - Debug.Assert(false); - break; - } - - // Re-illuminate the ground with each bounce. - cmd.DispatchCompute(s_GroundIrradiancePrecomputationCS, firstPass, (int)PbrSkyConfig.GroundIrradianceTableSize / 64, 1, 1); - } - } - } - protected override bool Update(BuiltinSkyParameters builtinParams) { UpdateGlobalConstantBuffer(builtinParams.commandBuffer, builtinParams); @@ -289,54 +429,13 @@ protected override bool Update(BuiltinSkyParameters builtinParams) int currPrecomputationParamHash = pbrSky.GetPrecomputationHashCode(); if (currPrecomputationParamHash != m_LastPrecomputationParamHash) { - // Hash does not match, have to restart the precomputation from scratch. - m_LastPrecomputedBounce = 0; - } - - if (m_LastPrecomputedBounce == 0) - { - // Allocate temp tables if needed - if (m_GroundIrradianceTables[1] == null) - { - m_GroundIrradianceTables[1] = AllocateGroundIrradianceTable(1); - } - - if (m_InScatteredRadianceTables[3] == null) - { - m_InScatteredRadianceTables[3] = AllocateInScatteredRadianceTable(3); - } - - if (m_InScatteredRadianceTables[4] == null) - { - m_InScatteredRadianceTables[4] = AllocateInScatteredRadianceTable(4); - } - } - - if (m_LastPrecomputedBounce == pbrSky.numberOfBounces.value) - { - // Free temp tables. - // This is a deferred release (one frame late)! - RTHandles.Release(m_GroundIrradianceTables[1]); - RTHandles.Release(m_InScatteredRadianceTables[3]); - RTHandles.Release(m_InScatteredRadianceTables[4]); - m_GroundIrradianceTables[1] = null; - m_InScatteredRadianceTables[3] = null; - m_InScatteredRadianceTables[4] = null; - } - - if (m_LastPrecomputedBounce < pbrSky.numberOfBounces.value) - { - PrecomputeTables(builtinParams.commandBuffer); - m_LastPrecomputedBounce++; - - // Update the hash for the current bounce. + if (m_LastPrecomputationParamHash != 0) + s_PrecomputaionCache.Release(m_LastPrecomputationParamHash); + m_PrecomputedData = s_PrecomputaionCache.Get(currPrecomputationParamHash); m_LastPrecomputationParamHash = currPrecomputationParamHash; - - // If the sky is realtime, an upcoming update will update the sky lighting. Otherwise we need to force an update. - return builtinParams.skySettings.updateMode != EnvironmentUpdateMode.Realtime; } - return false; + return m_PrecomputedData.Update(builtinParams, pbrSky); } // 'renderSunDisk' parameter is not supported. @@ -370,20 +469,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._PlanetRotation, Matrix4x4.Rotate(planetRotation)); s_PbrSkyMaterialProperties.SetMatrix(HDShaderIDs._SpaceRotation, Matrix4x4.Rotate(spaceRotation)); - if (m_LastPrecomputedBounce != 0) - { - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._GroundIrradianceTexture, m_GroundIrradianceTables[0]); - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AirSingleScatteringTexture, m_InScatteredRadianceTables[0]); - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AerosolSingleScatteringTexture, m_InScatteredRadianceTables[1]); - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._MultipleScatteringTexture, m_InScatteredRadianceTables[2]); - } - else - { - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._GroundIrradianceTexture, Texture2D.blackTexture); - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AirSingleScatteringTexture, CoreUtils.blackVolumeTexture); - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._AerosolSingleScatteringTexture, CoreUtils.blackVolumeTexture); - s_PbrSkyMaterialProperties.SetTexture(HDShaderIDs._MultipleScatteringTexture, CoreUtils.blackVolumeTexture); - } + m_PrecomputedData.BindBuffers(cmd, s_PbrSkyMaterialProperties); int hasGroundAlbedoTexture = 0; @@ -418,7 +504,7 @@ public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderFo int pass = (renderForCubemap ? 0 : 2) + (isPbrSkyActive ? 0 : 1); - CoreUtils.DrawFullScreen(builtinParams.commandBuffer, s_PbrSkyMaterial, s_PbrSkyMaterialProperties, pass); + CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_PbrSkyMaterial, s_PbrSkyMaterialProperties, pass); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUpdateContext.cs b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUpdateContext.cs index 3ae3591daa4..9127a4824f0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUpdateContext.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/SkyUpdateContext.cs @@ -16,6 +16,15 @@ public SkySettings skySettings get { return m_SkySettings; } set { + // We cleanup the renderer first here because in some cases, after scene unload, the skySettings field will be "null" because the object got destroyed. + // In this case, the renderer might stay allocated until a non null value is set. To avoid a lingering allocation, we cleanup first before anything else. + // So next frame after scene unload, renderer will be freed. + if (skyRenderer != null && (value == null || value.GetSkyRendererType() != skyRenderer.GetType())) + { + skyRenderer.Cleanup(); + skyRenderer = null; + } + if (m_SkySettings == value) return; @@ -23,13 +32,8 @@ public SkySettings skySettings m_SkySettings = value; currentUpdateTime = 0.0f; - if (m_SkySettings != null && (skyRenderer == null || m_SkySettings.GetSkyRendererType() != skyRenderer.GetType())) + if (m_SkySettings != null && skyRenderer == null) { - if (skyRenderer != null) - { - skyRenderer.Cleanup(); - } - var rendererType = m_SkySettings.GetSkyRendererType(); skyRenderer = (SkyRenderer)Activator.CreateInstance(rendererType); skyRenderer.Build(); From 762012c151ddf347715533b81020469a5490e60d Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Thu, 14 May 2020 16:05:51 +0200 Subject: [PATCH 43/81] [Backport 7.x.x] New tooltip for camera background and fixed exposure when switching the background mode. (#480) * Put more information in Camera background type tooltip and fixed inconsistent exposure behavior when changing bg type. # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs * Update changelog --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/RenderPipeline/Camera/HDCameraUI.Skin.cs | 2 +- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1ff07e6456a..261f5ee3f55 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed some GCAlloc in the debug window. - Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. - Fixed over consumption of GPU memory by the Physically Based Sky. +- Put more information in Camera background type tooltip and fixed inconsistent exposure behavior when changing bg type. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Skin.cs index 1cc4d712f6e..93d18076184 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Camera/HDCameraUI.Skin.cs @@ -14,7 +14,7 @@ static partial class HDCameraUI const string msaaWarningMessage = "Manual MSAA target set with deferred rendering. This will lead to undefined behavior."; - static readonly GUIContent clearModeContent = EditorGUIUtility.TrTextContent("Background Type", "Specifies the type of background the Camera applies when it clears the screen before rendering a frame."); + static readonly GUIContent clearModeContent = EditorGUIUtility.TrTextContent("Background Type", "Specifies the type of background the Camera applies when it clears the screen before rendering a frame. Be aware that when setting this to None, the background is never cleared and since HDRP shares render texture between cameras, you may end up with garbage from previous rendering."); static readonly GUIContent backgroundColorContent = EditorGUIUtility.TrTextContent("Background Color", "The Background Color used to clear the screen when selecting Background Color before rendering."); static readonly GUIContent cullingMaskContent = EditorGUIUtility.TrTextContent("Culling Mask"); static readonly GUIContent volumeLayerMaskContent = EditorGUIUtility.TrTextContent("Volume Layer Mask"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index cf01f7c97be..799fb4659b9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -256,6 +256,9 @@ internal HDAdditionalCameraData.ClearColorMode clearColorMode } } + HDAdditionalCameraData.ClearColorMode m_PreviousClearColorMode = HDAdditionalCameraData.ClearColorMode.None; + + internal Color backgroundColorHDR { get @@ -865,9 +868,11 @@ void UpdateAntialiasing() } // When changing antialiasing mode to TemporalAA we must reset the history, otherwise we get one frame of garbage - if (previousAntialiasing != antialiasing && antialiasing == AntialiasingMode.TemporalAntialiasing) + if ( (previousAntialiasing != antialiasing && antialiasing == AntialiasingMode.TemporalAntialiasing) + || (m_PreviousClearColorMode != clearColorMode)) { resetPostProcessingHistory = true; + m_PreviousClearColorMode = clearColorMode; } } From eec0506a77e5780b5f13cd96e89c97061a964cc5 Mon Sep 17 00:00:00 2001 From: JulienIgnace-Unity Date: Thu, 14 May 2020 16:07:01 +0200 Subject: [PATCH 44/81] [Backport 7.x.x] Fixed asset preview being rendered white because of static lighting sky. (#479) * Fixed an issue where asset preview could be rendered white because of static lighting sky. Also fixed an issue where static lighting was not updated when removing the static lighting sky profile. # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs * Update changelog --- .../CHANGELOG.md | 2 ++ .../Sky/HDLightingWindowEnvironmentSection.cs | 16 ++++++---------- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 261f5ee3f55..d31b0b6eb0e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -71,6 +71,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. - Fixed over consumption of GPU memory by the Physically Based Sky. - Put more information in Camera background type tooltip and fixed inconsistent exposure behavior when changing bg type. +- Fixed an issue where asset preview could be rendered white because of static lighting sky. +- Fixed an issue where static lighting was not updated when removing the static lighting sky profile. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs b/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs index 813fdf8a5cd..682cba36804 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs @@ -32,17 +32,13 @@ class SerializedStaticLightingSky { SerializedObject serializedObject; public SerializedProperty skyUniqueID; - - public VolumeProfile volumeProfile - { - get => (serializedObject.targetObject as StaticLightingSky).profile; - set => (serializedObject.targetObject as StaticLightingSky).profile = value; - } + public SerializedProperty profile; public SerializedStaticLightingSky(StaticLightingSky staticLightingSky) { serializedObject = new SerializedObject(staticLightingSky); skyUniqueID = serializedObject.FindProperty("m_StaticLightingSkyUniqueID"); + profile = serializedObject.FindProperty("m_Profile"); } public void Apply() => serializedObject.ApplyModifiedProperties(); @@ -174,10 +170,10 @@ void DrawGUI() ++EditorGUI.indentLevel; //cannot use SerializeProperty due to logic in the property - var profile = m_SerializedActiveSceneLightingSky.volumeProfile; - var newProfile = EditorGUILayout.ObjectField(EditorGUIUtility.TrTextContent("Profile"), profile, typeof(VolumeProfile), allowSceneObjects: false) as VolumeProfile; + var profile = m_SerializedActiveSceneLightingSky.profile.objectReferenceValue; + var newProfile = EditorGUILayout.ObjectField(EditorGUIUtility.TrTextContent("Profile"), m_SerializedActiveSceneLightingSky.profile.objectReferenceValue, typeof(VolumeProfile), allowSceneObjects: false) as VolumeProfile; if (profile != newProfile) - m_SerializedActiveSceneLightingSky.volumeProfile = newProfile; + m_SerializedActiveSceneLightingSky.profile.objectReferenceValue = newProfile; using (new EditorGUI.DisabledScope(m_SkyClassNames.Count == 1)) // Only "None" { @@ -204,7 +200,7 @@ void UpdateSkyIntPopupData() m_SkyClassNames.Add(new GUIContent("None")); m_SkyUniqueIDs.Add(0); - VolumeProfile profile = m_SerializedActiveSceneLightingSky.volumeProfile; + VolumeProfile profile = m_SerializedActiveSceneLightingSky.profile.objectReferenceValue as VolumeProfile; if (profile != null) { var skyTypesDict = SkyManager.skyTypesDict; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 7d3d93693fa..370a5ba6377 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1975,7 +1975,6 @@ AOVRequestData aovRequest m_PostProcessSystem.BeginFrame(cmd, hdCamera, this); ApplyDebugDisplaySettings(hdCamera, cmd); - m_SkyManager.UpdateCurrentSkySettings(hdCamera); SetupCameraProperties(hdCamera, renderContext, cmd); @@ -2755,6 +2754,7 @@ ref HDCullingResults cullingResults hdProbeCullState = HDProbeSystem.PrepareCull(camera); // We need to set the ambient probe here because it's passed down to objects during the culling process. + skyManager.UpdateCurrentSkySettings(hdCamera); skyManager.SetupAmbientProbe(hdCamera); using (new ProfilingScope(null, ProfilingSampler.Get(HDProfileId.CullResultsCull))) From 03dbd4d7a865755fb020c945280522105eb44513 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 23 Apr 2020 13:44:00 +0100 Subject: [PATCH 45/81] Changed UI name, tooltip, and doc for maximum decals on screen (#232) Implements feedback from https://fogbugz.unity3d.com/f/cases/1189618/ --- .../Documentation~/HDRP-Asset.md | 2 +- .../Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md index ba666e6311b..73ff57b6263 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Asset.md @@ -65,7 +65,7 @@ These settings control the draw distance and resolution of the decals atlas that | **- Atlas Width** | The Decal Atlas width. This atlas stores all decals that project onto transparent surfaces. | | **- Atlas Height** | The Decal Atlas height. This atlas stores all decals that project onto transparent surfaces. | | **- Metal and Ambient Occlusion properties** | Enable the checkbox to allow decals to affect metallic and ambient occlusion Material properties. Enabling this feature has a performance impact. | -| **- Maximum** **Decals on Screen** | The maximum number of decals you can have on screen at one time. | +| **- Maximum Clustered Decals on Screen** | The maximum number of clustered decals that can affect transparent GameObjects on screen. Clustered decals refer to a list of decals that HDRP uses when it renders transparent GameObjects. | diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index c1aedeca879..d019df5a07b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -145,7 +145,7 @@ public class GeneralSection public static readonly GUIContent maxPonctualContent = EditorGUIUtility.TrTextContent("Maximum Punctual on Screen", "Sets the maximum number of Point and Spot Lights HDRP can handle on screen at once."); public static readonly GUIContent maxAreaContent = EditorGUIUtility.TrTextContent("Maximum Area on Screen", "Sets the maximum number of area Lights HDRP can handle on screen at once."); public static readonly GUIContent maxEnvContent = EditorGUIUtility.TrTextContent("Maximum Reflection Probes on Screen", "Sets the maximum number of Planar and Reflection Probes HDRP can handle on screen at once."); - public static readonly GUIContent maxDecalContent = EditorGUIUtility.TrTextContent("Maximum Decals on Screen", "Sets the maximum number of Decals HDRP can handle on screen at once."); + public static readonly GUIContent maxDecalContent = EditorGUIUtility.TrTextContent("Maximum Clustered Decals on Screen", "Sets the maximum number of decals that can affect transparent GameObjects on screen."); public static readonly GUIContent resolutionContent = EditorGUIUtility.TrTextContent("Resolution", "Specifies the resolution of the shadow Atlas."); public static readonly GUIContent directionalShadowPrecisionContent = EditorGUIUtility.TrTextContent("Directional Shadow Precision", "Select the shadow map bit depth, this forces HDRP to use selected bit depth for shadow maps."); From aac437efff655da6d81aa1a1764406956d4d47f3 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Fri, 24 Apr 2020 20:22:53 +0100 Subject: [PATCH 46/81] Update Custom-Post-Process.md (#233) --- .../Documentation~/Custom-Post-Process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Custom-Post-Process.md b/com.unity.render-pipelines.high-definition/Documentation~/Custom-Post-Process.md index 034e97190f7..f27913d847b 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Custom-Post-Process.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Custom-Post-Process.md @@ -113,7 +113,7 @@ Now there are the **Setup**, **Render**, and **Cleanup** functions. These are he ### GrayScale Shader -HDRP gives you total control over the vertex and fragment Shader so you can edit both of them to suit your needs. Note that there are a number of utility functions in [Common.hlsl](https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl) and [Color.hlsl](https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl) that the Shader includes by default. This means that you have access to these utility functions in your effect. For example, the GrayScale Shader uses the Luminance() function to convert a linear RGB value to its luminance equivalent. +HDRP gives you total control over the vertex and fragment Shader so you can edit both of them to suit your needs. Note that there are a number of utility functions in [Common.hlsl](https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl) and [Color.hlsl](https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl) that the Shader includes by default. This means that you have access to these utility functions in your effect. For example, the GrayScale Shader uses the Luminance() function to convert a linear RGB value to its luminance equivalent. ``` Shader "Hidden/Shader/GrayScale" From fb68069eae12435fb936d86e3dcd63433f7b788c Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Fri, 24 Apr 2020 20:22:15 +0100 Subject: [PATCH 47/81] Update HDRP-Features.md (#235) --- .../Documentation~/HDRP-Features.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md index feb8105994e..73f8f3bbe18 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md @@ -92,19 +92,19 @@ The StackLit Shader improves on the Lit Shader in favor of quality over performa ![](Images/HDRPFeatures-HairShader.png) -The Hair Shader is purpose-built to accurately render realistic hair in your Unity Project. It uses an improved Kajiya Kay lighting model which features better energy conservation and provides you with more flexibility. +The Hair Shader is purpose-built to accurately render realistic hair in your Unity Project. It uses an improved Kajiya Kay lighting model which features better energy conservation and provides you with more flexibility. For more information, including a full list of Shader properties, see the [Hair Shader documentation](Master-Node-Hair). ### Fabric Shader ![](Images/HDRPFeatures-FabricShader.png) -The Fabric Shader allows you to render realistic fabric Materials in HDRP. You can use the cotton wool or silk lighting model to create a wide variety of fabrics. +The Fabric Shader allows you to render realistic fabric Materials in HDRP. You can use the cotton wool or silk lighting model to create a wide variety of fabrics. For more information, including a full list of Shader properties, see the [Fabric Shader documentation](Master-Node-Fabric). ### AxF Shader ![](Images/HDRPFeatures-AxFShader.png) -The AxF Shader supports the [X-Rite AxF](https://www.xrite.com/axf) measured Material format. The AxF importer, available in [Unity Enterprise for Product Lifecylce](https://unity.com/products/unity-enterprise-product-lifecycle), automatically populates an AxF Material when it imports AxF Assets. +The AxF Shader supports the [X-Rite AxF](https://www.xrite.com/axf) measured Material format. The AxF importer, available in [Unity Enterprise for Product Lifecylce](https://unity.com/products/unity-enterprise-product-lifecycle), automatically populates an AxF Material when it imports AxF Assets. For more information, including a full list of Shader properties, see the [AxF Shader documentation](AxF-Shader). ### Decal Shader @@ -216,7 +216,7 @@ om ![](Images/HDRPFeatures-Fog.png) -In HDRP, you set up fog, inside a [Volume](Volumes.md),so you can change fog settings, or even the fog type itself, depending on the position of the Camera in the Scene. You can set the color of the fog yourself or use the color of the sky. HDRP fog affects Materials with both opaque and transparent surfaces. HDRP implements an exponential [fog](Override-Fog.md) with optional volumetric effects. +In HDRP, you set up fog, inside a [Volume](Volumes.md), so you can change fog settings, or even the fog type itself, depending on the position of the Camera in the Scene. You can set the color of the fog yourself or use the color of the sky. HDRP fog affects Materials with both opaque and transparent surfaces. HDRP implements an exponential [fog](Override-Fog.md) with optional volumetric effects. ### Light Layers @@ -250,7 +250,7 @@ HDRP uses ray tracing to replace some of its screen space effects, shadowing tec Real time raytracing effect are currently in Preview and behavior could change in the future. - [Ray-Traced Ambient Occlusion](Ray-Traced-Ambient-Occlusion.md) replaces [screen space ambient occlusion](Override-Ambient-Occlusion.md) with a more accurate, ray-traced, ambient occlusion technique that can use off screen data. -- [Ray-Traced Contact Shadows](Ray-Tracing-Contact-Shadows.md) replaces [contact shadows](Override-Contact-Shadows.md) with a more accurate, ray-traced, contact shadow technique that can use off screen data. +- [Ray-Traced Contact Shadows](Ray-Traced-Contact-Shadows.md) replaces [contact shadows](Override-Contact-Shadows.md) with a more accurate, ray-traced, contact shadow technique that can use off screen data. - [Ray-Traced Global Illumination](Ray-Traced-Global-Illumination.md) is an alternative to Light Probes and lightmaps in HDRP. - [Ray-Traced Reflections](Ray-Traced-Reflections.md) is a replacement for [screen space reflection](Override-Screen-Space-Reflection.md) that uses a ray-traced reflection technique that can use off-screen data. - [Ray-Traced Shadows](Ray-Traced-Shadows.md) replace shadow maps for Directional, Point, and Area [Lights](Light-Component.md). @@ -307,7 +307,7 @@ The Render Pipeline Debugger contains many debugging and visualization tools to ### LookDev ![](Images/HDRPFeatures-LookDev.png) -The LookDev is a viewer that allows you to import and display Assets in a good, consistent lighting environment. Use it to validate outsourced Assets or to showcase your own created Asset with HDRP. For more information on the LookDev, including a description of how to use it, see the [LookDev documentation](LookDev.md). +The LookDev is a viewer that allows you to import and display Assets in a good, consistent lighting environment. Use it to validate outsourced Assets or to showcase your own created Asset with HDRP. For more information on the LookDev, including a description of how to use it, see the [LookDev documentation](Look-Dev.md). ### MatCap mode From 3216fdbc27543d629fed06387167edc6debb2024 Mon Sep 17 00:00:00 2001 From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com> Date: Thu, 7 May 2020 13:20:43 +0200 Subject: [PATCH 48/81] Hdrp/reflection probe scale perf #252 --- .../Editor/HDReflectionSystemTests.cs | 52 ++++++++ .../Editor/HDReflectionSystemTests.cs.meta | 11 ++ .../CHANGELOG.md | 1 + .../Reflection/HDBakedReflectionSystem.cs | 48 ++++---- .../Reflection/HDProbeCullingResults.cs | 5 +- .../Lighting/Reflection/HDProbeSystem.cs | 113 +++++++++--------- 6 files changed, 150 insertions(+), 80 deletions(-) create mode 100644 TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs create mode 100644 TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs.meta diff --git a/TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs b/TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs new file mode 100644 index 00000000000..1e7f0dfcc0c --- /dev/null +++ b/TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs @@ -0,0 +1,52 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor.Rendering; +using UnityEngine.TestTools; +using NUnit.Framework; +using System.Text.RegularExpressions; +using System.Globalization; +using System.Threading; +using Unity.PerformanceTesting; +using UnityEditor.Rendering.HighDefinition; +using UnityEngine.Rendering; +using UnityEngine.Rendering.HighDefinition; +using static PerformanceTestUtils; +using static PerformanceMetricNames; + +public class HDReflectionSystemTests : EditorPerformanceTests +{ + [Version("1"), Test, Performance] + public void HDProbeSystemRegister() + { + using (ListPool.Get(out var probes)) + { + // Create a lot of probe + for (var i = 0; i < 10000; ++i) + { + var gameObject = new GameObject(i.ToString("0000")); + // Deactivate the GameObject to avoid OnEnable calls (which register the probe) + gameObject.SetActive(false); + gameObject.AddComponent(); + var probe = gameObject.AddComponent(); + probe.enabled = false; + probes.Add(probe); + } + + // Measure registration + Measure.Method(() => + { + foreach (var probe in probes) + HDProbeSystem.RegisterProbe(probe); + }).Run(); + + // Unregister + foreach (var probe in probes) + HDProbeSystem.UnregisterProbe(probe); + + // Delete the probes + foreach (var probe in probes) + Object.DestroyImmediate(probe.gameObject); + } + } +} diff --git a/TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs.meta b/TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs.meta new file mode 100644 index 00000000000..bf2dcfddbaa --- /dev/null +++ b/TestProjects/HDRP_PerformanceTests/Assets/PerformanceTests/Editor/HDReflectionSystemTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34a610b21c88b5947a1780a1175ca3e4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 3dbb78f1c6f..39229cc4c7b 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -84,6 +84,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. - Renamed "Environment" to "Reflection Probes" in tile/cluster debug menu. - Debug exposure in debug menu have been replace to debug exposure compensation in EV100 space and is always visible. +- Improved performance of reflection probe management when using a lot of probes. ## [7.3.0] - 2020-03-11 diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs index 071cf80f198..416a320cdbc 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs @@ -131,26 +131,27 @@ IScriptableBakedReflectionSystemStageNotifier handle HashUtilities.AppendHash(ref skySettingsHash, ref allProbeDependencyHash); var bakedProbes = HDProbeSystem.bakedProbes; + var bakedProbeCount = HDProbeSystem.bakedProbeCount; // == 2. == - var states = stackalloc HDProbeBakingState[bakedProbes.Count]; + var states = stackalloc HDProbeBakingState[bakedProbeCount]; ComputeProbeInstanceID(bakedProbes, states); ComputeProbeSettingsHashes(bakedProbes, states); // TODO: Handle bounce dependency here - ComputeProbeBakingHashes(bakedProbes.Count, allProbeDependencyHash, states); + ComputeProbeBakingHashes(bakedProbeCount, allProbeDependencyHash, states); CoreUnsafeUtils.QuickSort( - bakedProbes.Count, states + bakedProbeCount, states ); int operationCount = 0, addCount = 0, remCount = 0; - var maxProbeCount = Mathf.Max(bakedProbes.Count, m_HDProbeBakedStates.Length); + var maxProbeCount = Mathf.Max(bakedProbeCount, m_HDProbeBakedStates.Length); var addIndices = stackalloc int[maxProbeCount]; var remIndices = stackalloc int[maxProbeCount]; if (m_HDProbeBakedStates.Length == 0) { - for (int i = 0; i < bakedProbes.Count; ++i) + for (int i = 0; i < bakedProbeCount; ++i) addIndices[addCount++] = i; operationCount = addCount; } @@ -165,7 +166,7 @@ IScriptableBakedReflectionSystemStageNotifier handle HDProbeBakingState, HDProbeBakingState.ProbeBakingHash > ( m_HDProbeBakedStates.Length, oldBakedStates, // old hashes - bakedProbes.Count, states, // new hashes + bakedProbeCount, states, // new hashes addIndices, remIndices, out addCount, out remCount ); @@ -202,7 +203,7 @@ IScriptableBakedReflectionSystemStageNotifier handle // Get from cache or render the probe if (!File.Exists(cacheFile)) RenderAndWriteToFile(probe, cacheFile, cubeRT, planarRT); - + planarRT.Release(); } cubeRT.Release(); @@ -232,7 +233,7 @@ IScriptableBakedReflectionSystemStageNotifier handle for (int j = 0; j < 2; ++j) { AssetDatabase.StartAssetEditing(); - for (int i = 0; i < bakedProbes.Count; ++i) + for (int i = 0; i < bakedProbeCount; ++i) { var index = addIndices[i]; var instanceId = states[index].instanceID; @@ -312,7 +313,7 @@ IScriptableBakedReflectionSystemStageNotifier handle handle.SetIsDone(true); } - public static bool BakeProbes(IList bakedProbes) + public static bool BakeProbes(IEnumerable bakedProbes) { if (!(RenderPipelineManager.currentPipeline is HDRenderPipeline hdPipeline)) { @@ -326,9 +327,8 @@ public static bool BakeProbes(IList bakedProbes) var cubeRT = HDRenderUtilities.CreateReflectionProbeRenderTarget(cubemapSize); // Render and write the result to disk - for (int i = 0; i < bakedProbes.Count; ++i) + foreach (var probe in bakedProbes) { - var probe = bakedProbes[i]; var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe); var planarRT = HDRenderUtilities.CreatePlanarProbeRenderTarget((int)probe.resolution); RenderAndWriteToFile(probe, bakedTexturePath, cubeRT, planarRT); @@ -342,9 +342,8 @@ public static bool BakeProbes(IList bakedProbes) for (int j = 0; j < 2; ++j) { AssetDatabase.StartAssetEditing(); - for (int i = 0; i < bakedProbes.Count; ++i) + foreach (var probe in bakedProbes) { - var probe = bakedProbes[i]; var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe); AssetDatabase.ImportAsset(bakedTexturePath); ImportAssetAt(probe, bakedTexturePath); @@ -353,9 +352,8 @@ public static bool BakeProbes(IList bakedProbes) } AssetDatabase.StartAssetEditing(); - for (int i = 0; i < bakedProbes.Count; ++i) + foreach (var probe in bakedProbes) { - var probe = bakedProbes[i]; var bakedTexturePath = HDBakingUtilities.GetBakedTextureFilePath(probe); // Get or create the baked texture asset for the probe @@ -379,9 +377,8 @@ public static bool BakeProbes(IList bakedProbes) // updateCount is a transient data, so don't execute this code before the asset reload. { UnityEngine.Random.InitState((int)(1000 * hdPipeline.GetTime())); - for (int i = 0; i < bakedProbes.Count; ++i) + foreach (var probe in bakedProbes) { - var probe = bakedProbes[i]; var c = UnityEngine.Random.Range(2, 10); while (probe.texture.updateCount < c) probe.texture.IncrementUpdateCount(); } @@ -663,23 +660,28 @@ string GetGICacheFileForHDProbe(Hash128 hash) return Path.Combine(hashFolder, string.Format("HDProbe-{0}.exr", hash)); } - static void ComputeProbeInstanceID(IList probes, HDProbeBakingState* states) + static void ComputeProbeInstanceID(IEnumerable probes, HDProbeBakingState* states) { - for (int i = 0; i < probes.Count; ++i) - states[i].instanceID = probes[i].GetInstanceID(); + var i = 0; + foreach (var probe in probes) + { + states[i].instanceID = probe.GetInstanceID(); + ++i; + } } - static void ComputeProbeSettingsHashes(IList probes, HDProbeBakingState* states) + static void ComputeProbeSettingsHashes(IEnumerable probes, HDProbeBakingState* states) { - for (int i = 0; i < probes.Count; ++i) + var i = 0; + foreach (var probe in probes) { - var probe = probes[i]; var positionSettings = ProbeCapturePositionSettings.ComputeFrom(probe, null); var positionSettingsHash = positionSettings.ComputeHash(); // TODO: make ProbeSettings and unmanaged type so its hash can be the hash of its memory var probeSettingsHash = probe.settings.ComputeHash(); HashUtilities.AppendHash(ref positionSettingsHash, ref probeSettingsHash); states[i].probeSettingsHash = probeSettingsHash; + ++i; } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeCullingResults.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeCullingResults.cs index 6ca43e2b60f..4fa75f24e34 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeCullingResults.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeCullingResults.cs @@ -10,7 +10,6 @@ struct HDProbeCullingResults List m_VisibleProbes; public IReadOnlyList visibleProbes => m_VisibleProbes ?? s_EmptyList; - internal List writeableVisibleProbes => m_VisibleProbes; internal void Reset() { @@ -20,11 +19,11 @@ internal void Reset() m_VisibleProbes.Clear(); } - internal void Set(List visibleProbes) + internal void AddProbe(HDProbe visibleProbes) { Assert.IsNotNull(m_VisibleProbes); - m_VisibleProbes.AddRange(visibleProbes); + m_VisibleProbes.Add(visibleProbes); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs index 5a2bcc6dac5..4f17ce5df33 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDProbeSystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Unity.Collections.LowLevel.Unsafe; using UnityEngine.Assertions; @@ -30,9 +31,10 @@ public static ReflectionSystemParameters Parameters set => s_Instance.Parameters = value; } - public static IList realtimeViewDependentProbes => s_Instance.realtimeViewDependentProbes; - public static IList realtimeViewIndependentProbes => s_Instance.realtimeViewIndependentProbes; - public static IList bakedProbes => s_Instance.bakedProbes; + public static IEnumerable realtimeViewDependentProbes => s_Instance.realtimeViewDependentProbes; + public static IEnumerable realtimeViewIndependentProbes => s_Instance.realtimeViewIndependentProbes; + public static IEnumerable bakedProbes => s_Instance.bakedProbes; + public static int bakedProbeCount => s_Instance.bakedProbeCount; public static void RegisterProbe(HDProbe probe) => s_Instance.RegisterProbe(probe); public static void UnregisterProbe(HDProbe probe) => s_Instance.UnregisterProbe(probe); @@ -143,21 +145,25 @@ static Texture CreateAndSetRenderTargetIfRequired(HDProbe probe, ProbeSettings.M class HDProbeSystemInternal : IDisposable { - List m_BakedProbes = new List(); - List m_RealtimeViewDependentProbes = new List(); - List m_RealtimeViewIndependentProbes = new List(); + HashSet m_BakedProbes = new HashSet(); + HashSet m_RealtimeViewDependentProbes = new HashSet(); + HashSet m_RealtimeViewIndependentProbes = new HashSet(); int m_PlanarProbeCount = 0; - PlanarReflectionProbe[] m_PlanarProbes = new PlanarReflectionProbe[32]; + bool m_RebuildPlanarProbeArray; + HashSet m_PlanarProbes = new HashSet(); + PlanarReflectionProbe[] m_PlanarProbesArray = new PlanarReflectionProbe[32]; BoundingSphere[] m_PlanarProbeBounds = new BoundingSphere[32]; CullingGroup m_PlanarProbeCullingGroup = new CullingGroup(); - public IList bakedProbes + public IEnumerable bakedProbes { get { RemoveDestroyedProbes(m_BakedProbes); return m_BakedProbes; } } - public IList realtimeViewDependentProbes + public IEnumerable realtimeViewDependentProbes { get { RemoveDestroyedProbes(m_RealtimeViewDependentProbes); return m_RealtimeViewDependentProbes; } } - public IList realtimeViewIndependentProbes + public IEnumerable realtimeViewIndependentProbes { get { RemoveDestroyedProbes(m_RealtimeViewIndependentProbes); return m_RealtimeViewIndependentProbes; } } + public int bakedProbeCount => m_BakedProbes.Count; + public ReflectionSystemParameters Parameters; public void Dispose() @@ -172,12 +178,7 @@ internal void RegisterProbe(HDProbe probe) switch (settings.mode) { case ProbeSettings.Mode.Baked: - // TODO: Remove the duplicate check - // In theory, register/unregister are called by pair, never twice register in a row - // So there should not any "duplicate" calls. still it happens and we must prevent - // duplicate entries. - if (!m_BakedProbes.Contains(probe)) - m_BakedProbes.Add(probe); + m_BakedProbes.Add(probe); break; case ProbeSettings.Mode.Realtime: switch (settings.type) @@ -198,22 +199,19 @@ internal void RegisterProbe(HDProbe probe) { case ProbeSettings.ProbeType.PlanarProbe: { - // TODO: Remove the duplicate check - // In theory, register/unregister are called by pair, never twice register in a row - // So there should not any "duplicate" calls. still it happens and we must prevent - // duplicate entries. - if (Array.IndexOf(m_PlanarProbes, (PlanarReflectionProbe) probe) != -1) - break; - - // Grow the arrays - if (m_PlanarProbeCount == m_PlanarProbes.Length) + if (m_PlanarProbes.Add((PlanarReflectionProbe)probe)) { - Array.Resize(ref m_PlanarProbes, m_PlanarProbes.Length * 2); - Array.Resize(ref m_PlanarProbeBounds, m_PlanarProbeBounds.Length * 2); + // Insert in the array + // Grow the arrays + if (m_PlanarProbeCount == m_PlanarProbesArray.Length) + { + Array.Resize(ref m_PlanarProbesArray, m_PlanarProbes.Count * 2); + Array.Resize(ref m_PlanarProbeBounds, m_PlanarProbeBounds.Length * 2); + } + m_PlanarProbesArray[m_PlanarProbeCount] = (PlanarReflectionProbe)probe; + m_PlanarProbeBounds[m_PlanarProbeCount] = ((PlanarReflectionProbe)probe).boundingSphere; + ++m_PlanarProbeCount; } - m_PlanarProbes[m_PlanarProbeCount] = (PlanarReflectionProbe)probe; - m_PlanarProbeBounds[m_PlanarProbeCount] = ((PlanarReflectionProbe)probe).boundingSphere; - ++m_PlanarProbeCount; break; } } @@ -226,16 +224,11 @@ internal void UnregisterProbe(HDProbe probe) m_RealtimeViewIndependentProbes.Remove(probe); // Remove swap back - var index = Array.IndexOf(m_PlanarProbes, probe); - if (index != -1) + if (m_PlanarProbes.Remove(probe)) { - if (index < m_PlanarProbeCount) - { - m_PlanarProbes[index] = m_PlanarProbes[m_PlanarProbeCount - 1]; - m_PlanarProbeBounds[index] = m_PlanarProbeBounds[m_PlanarProbeCount - 1]; - m_PlanarProbes[m_PlanarProbeCount - 1] = null; - } - --m_PlanarProbeCount; + // It is best to rebuild the full array when we need it instead of doing it at each unregister. + // So we mark it as dirty. + m_RebuildPlanarProbeArray = true; } } @@ -246,15 +239,34 @@ internal HDProbeCullState PrepareCull(Camera camera) if (m_PlanarProbeCullingGroup == null) return default; - UpdateBoundsAndRemoveDestroyedProbes(m_PlanarProbes, m_PlanarProbeBounds, ref m_PlanarProbeCount); + RebuildPlanarProbeArrayIfRequired(); + + UpdateBoundsAndRemoveDestroyedProbes(m_PlanarProbesArray, m_PlanarProbeBounds, ref m_PlanarProbeCount); m_PlanarProbeCullingGroup.targetCamera = camera; m_PlanarProbeCullingGroup.SetBoundingSpheres(m_PlanarProbeBounds); m_PlanarProbeCullingGroup.SetBoundingSphereCount(m_PlanarProbeCount); - var stateHash = ComputeStateHashDebug(m_PlanarProbeBounds, m_PlanarProbes, m_PlanarProbeCount); + var stateHash = ComputeStateHashDebug(m_PlanarProbeBounds, m_PlanarProbesArray, m_PlanarProbeCount); - return new HDProbeCullState(m_PlanarProbeCullingGroup, m_PlanarProbes, stateHash); + return new HDProbeCullState(m_PlanarProbeCullingGroup, m_PlanarProbesArray, stateHash); + } + + void RebuildPlanarProbeArrayIfRequired() + { + if (m_RebuildPlanarProbeArray) + { + RemoveDestroyedProbes(m_PlanarProbes); + + m_RebuildPlanarProbeArray = false; + var i = 0; + foreach (var probe in m_PlanarProbes) + { + m_PlanarProbesArray[i] = (PlanarReflectionProbe)probe; + ++i; + } + m_PlanarProbeCount = m_PlanarProbes.Count; + } } int[] m_QueryCullResults_Indices; @@ -262,29 +274,22 @@ internal void QueryCullResults(HDProbeCullState state, ref HDProbeCullingResults { Assert.IsNotNull(state.cullingGroup, "Culling was not prepared, please prepare cull before performing it."); Assert.IsNotNull(state.hdProbes, "Culling was not prepared, please prepare cull before performing it."); - var stateHash = ComputeStateHashDebug(m_PlanarProbeBounds, m_PlanarProbes, m_PlanarProbeCount); + var stateHash = ComputeStateHashDebug(m_PlanarProbeBounds, m_PlanarProbesArray, m_PlanarProbeCount); Assert.AreEqual(stateHash, state.stateHash, "HDProbes changes since culling was prepared, this will lead to incorrect results."); results.Reset(); - var probes = results.writeableVisibleProbes; Array.Resize( ref m_QueryCullResults_Indices, Parameters.maxActivePlanarReflectionProbe + Parameters.maxActiveReflectionProbe ); var indexCount = state.cullingGroup.QueryIndices(true, m_QueryCullResults_Indices, 0); - for (int i = 0; i < indexCount; ++i) - probes.Add(state.hdProbes[m_QueryCullResults_Indices[i]]); + for (var i = 0; i < indexCount; ++i) + results.AddProbe(state.hdProbes[m_QueryCullResults_Indices[i]]); } - static void RemoveDestroyedProbes(List probes) - { - for (int i = probes.Count - 1; i >= 0; --i) - { - if (probes[i] == null || probes[i].Equals(null)) - probes.RemoveAt(i); - } - } + static void RemoveDestroyedProbes(HashSet probes) + => probes.RemoveWhere(p => p == null || p.Equals(null)); static void UpdateBoundsAndRemoveDestroyedProbes(PlanarReflectionProbe[] probes, BoundingSphere[] bounds, ref int count) { From 122f94250db17f0579b9f7bf26d821f2da1e9dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aras=20Pranckevi=C4=8Dius?= Date: Mon, 27 Apr 2020 05:33:59 -0700 Subject: [PATCH 49/81] HD: Switch to 1920x1080 default standalone resolution (#279) Well, the default is "fullscreen desktop resolution" anyway, so this does not change anything at default settings. But, if user unchecks the "default native fullscreen", then it was going into 1024x768 on Standalone platform. Which was the most popular resolution back in year 2005. In year 2019, the 1920x1080 is the most popular, so make that the default. See also: https://ono.unity3d.com/unity/unity/pull-request/105219/_/desktop/default-res (moved https://github.cds.internal.unity3d.com/unity/com.unity.template-hd/pull/33 to this new repo) --- com.unity.template-hd/ProjectSettings/ProjectSettings.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.template-hd/ProjectSettings/ProjectSettings.asset b/com.unity.template-hd/ProjectSettings/ProjectSettings.asset index d8f37d14c94..952390690b5 100644 --- a/com.unity.template-hd/ProjectSettings/ProjectSettings.asset +++ b/com.unity.template-hd/ProjectSettings/ProjectSettings.asset @@ -42,8 +42,8 @@ PlayerSettings: m_SplashScreenLogos: [] m_VirtualRealitySplashScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0} - defaultScreenWidth: 1024 - defaultScreenHeight: 768 + defaultScreenWidth: 1920 + defaultScreenHeight: 1080 defaultScreenWidthWeb: 960 defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 From f77e94a39d88d29880b2c51694de76fd58161f11 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Thu, 14 May 2020 15:00:33 +0200 Subject: [PATCH 50/81] =?UTF-8?q?Makes=20sure=20quaternion=20is=20normaliz?= =?UTF-8?q?ed=20and=20valid=20before=20converting=20to=20ma=E2=80=A6=20#33?= =?UTF-8?q?1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 39229cc4c7b..127ed834a7c 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue where asset preview could be rendered white because of static lighting sky. - Fixed an issue where static lighting was not updated when removing the static lighting sky profile. - Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047). +- Fixed an invalid rotation in Planar Reflection Probe editor display, that was causing an error message (case 1182022) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs index cbece4f9ae9..4a37f1c8492 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/PlanarReflectionProbeEditor.cs @@ -273,7 +273,7 @@ static void DrawCapturePositionGizmo(PlanarReflectionProbe probe) var mirrorPositionProxySpace = settings.proxySettings.mirrorPositionProxySpace + Vector3.up * 0.001f; var mirrorPosition = proxyToWorld.MultiplyPoint(mirrorPositionProxySpace); - var mirrorRotation = proxyToWorld.rotation * settings.proxySettings.mirrorRotationProxySpace * Quaternion.Euler(0, 180, 0); + var mirrorRotation = (proxyToWorld.rotation * settings.proxySettings.mirrorRotationProxySpace * Quaternion.Euler(0, 180, 0)).normalized; var renderData = probe.renderData; var gpuProj = GL.GetGPUProjectionMatrix(renderData.projectionMatrix, true); From 2905dd022ab0e549d88bad4d1b5f42fa728f0d32 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Wed, 6 May 2020 12:31:05 +0200 Subject: [PATCH 51/81] Fix cookie srgb #297 --- .../CHANGELOG.md | 1 + .../RenderPipeline/Utility/Texture2DAtlas.cs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 127ed834a7c..9a1f9cb7631 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -75,6 +75,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an issue where static lighting was not updated when removing the static lighting sky profile. - Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047). - Fixed an invalid rotation in Planar Reflection Probe editor display, that was causing an error message (case 1182022) +- Fixed cookie texture not updated when changing an import settings (srgb for example). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/Texture2DAtlas.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/Texture2DAtlas.cs index cca6204af96..32567a11dc3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/Texture2DAtlas.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Utility/Texture2DAtlas.cs @@ -141,6 +141,7 @@ class Texture2DAtlas private AtlasAllocator m_AtlasAllocator = null; private Dictionary m_AllocationCache = new Dictionary(); private Dictionary m_IsGPUTextureUpToDate = new Dictionary(); + private Dictionary m_TextureHashes = new Dictionary(); static readonly Vector4 fullScaleOffset = new Vector4(1, 1, 0, 0); @@ -278,6 +279,7 @@ public virtual bool AllocateTextureWithoutBlit(int instanceId, int width, int he scaleOffset.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height)); m_AllocationCache.Add(instanceId, scaleOffset); MarkGPUTextureInvalid(instanceId); // the texture data haven't been uploaded + m_TextureHashes[instanceId] = -1; return true; } else @@ -289,10 +291,29 @@ public virtual bool AllocateTextureWithoutBlit(int instanceId, int width, int he public bool IsCached(out Vector4 scaleOffset, Texture texture) => m_AllocationCache.TryGetValue(texture.GetInstanceID(), out scaleOffset); + protected int GetTextureHash(Texture texture) + { + int hash = texture.GetHashCode(); + + unchecked + { + hash = hash * 23 + texture.graphicsFormat.GetHashCode(); + hash = hash * 23 + texture.wrapMode.GetHashCode(); + hash = hash * 23 + texture.width.GetHashCode(); + hash = hash * 23 + texture.height.GetHashCode(); + hash = hash * 23 + texture.filterMode.GetHashCode(); + hash = hash * 23 + texture.anisoLevel.GetHashCode(); + hash = hash * 23 + texture.mipmapCount.GetHashCode(); + } + + return hash; + } + public virtual bool NeedsUpdate(Texture texture, bool needMips = false) { RenderTexture rt = texture as RenderTexture; int key = texture.GetInstanceID(); + int textureHash = GetTextureHash(texture); // Update the render texture if needed if (rt != null) @@ -309,6 +330,12 @@ public virtual bool NeedsUpdate(Texture texture, bool needMips = false) m_IsGPUTextureUpToDate[key] = rt.updateCount; } } + // In case the texture settings/import settings have changed, we need to update it + else if (m_TextureHashes.TryGetValue(key, out int hash) && hash != textureHash) + { + m_TextureHashes[key] = textureHash; + return true; + } // For regular textures, values == 0 means that their GPU data needs to be updated (either because // the atlas have been re-layouted or the texture have never been uploaded. We also check if the mips // are valid for the texture if we need them From e0c3e74d5fa93dce95ab020e81724b9ce44c6863 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Mon, 4 May 2020 12:44:34 +0100 Subject: [PATCH 52/81] Updated forward and deferred rendering definitions (#350) * Update Forward-And-Deferred-Rendering.md * Update Forward-And-Deferred-Rendering.md --- .../Documentation~/Forward-And-Deferred-Rendering.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Forward-And-Deferred-Rendering.md b/com.unity.render-pipelines.high-definition/Documentation~/Forward-And-Deferred-Rendering.md index 3ac208d453b..17daafbdd19 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Forward-And-Deferred-Rendering.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Forward-And-Deferred-Rendering.md @@ -15,8 +15,8 @@ You can choose between three rendering modes: | **Lit Shader Mode** | **Description** | | ------------------- | ------------------------------------------------------------ | -| **Forward** | HDRP calculates the lighting in a single pass when rendering each individual Material. | -| **Deferred** | HDRP renders all GameObjects into a GBuffer that stores the Material properties that are visible on the screen. HDRP then processes the lighting for every GameObject in the Scene. | +| **Forward** | HDRP calculates the lighting in a single pass when rendering each individual GameObject. | +| **Deferred** | HDRP renders the Material properties of every GameObject visible on screen into a GBuffer. HDRP then processes the lighting for every pixel in the frame. | | **Both** | Use the [Frame Settings](Frame-Settings.html) to change between **Forward** and **Deferred** rendering mode on a per Camera and Reflection Probe basis at runtime. Selecting this increases Project [build time](#BuildTime). | If you select **Both**, you can set a rendering mode for all Cameras to use by default, and also override this default rendering mode at runtime for a specific Camera. For example, you can use Forward mode for a Planar Reflection Probe and then render your main Camera using Deferred mode. From 3795b346bf682c2d01843b02b4e84a98a15f582b Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 14 May 2020 14:01:26 +0100 Subject: [PATCH 53/81] Update Light-Component.md (#357) --- .../Documentation~/Light-Component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md b/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md index f5029e94aaa..44e162a6e72 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Light-Component.md @@ -55,7 +55,7 @@ To make the Light work with the **Animation window**, when you click on the **Ad | **Property** | **Description** | | --------------- | ------------------------------------------------------------ | | **Type** | Defines the Light’s type. Lights of different Types behave differently, so when you change the **Type**, the properties change in the Inspector. Possible types are:
• Directional
• Point
• Spot
• Area | -| **Mode** | Specify the [Light Mode](https://docs.unity3d.com/Manual/LightModes.html) that HDRP uses to determine how to bake a Light, if at all. Possible modes are:
• [Realtime](https://docs.unity3d.com/Manual/LightMode-Realtime.html)
• [Mixed](https://docs.unity3d.com/Manual/LightMode-Mixed.html)
• [Baked](https://docs.unity3d.com/Manual/LightMode-Baked.html) | +| **Mode** | Specify the [Light Mode](https://docs.unity3d.com/Manual/LightModes.html) that HDRP uses to determine how to bake a Light, if at all. Possible modes are:
• [Realtime](https://docs.unity3d.com/Manual/LightMode-Realtime.html): Unity performs the lighting calculations for Realtime Lights at runtime, once per frame.
• [Mixed](https://docs.unity3d.com/Manual/LightMode-Mixed.html): Mixed Lights combine elements of both realtime and baked lighting.
• [Baked](https://docs.unity3d.com/Manual/LightMode-Baked.html): Unity performs lighting calculations for Baked Lights in the Unity Editor, and saves the results to disk as lighting data. Note that soft falloff/range attenuation is not supported for Baked Area Lights. | | **Light Layer** | A mask that allows you to choose which Light Layers this Light affects. The affected Light only lights up Mesh Renderers with a matching **Rendering Layer Mask**.
This property only appears when you enable [more options](More-Options.html) for this section. | #### Light Types guide From a3dae382469c4a7ffaf213beaefd1bd9fdfde4f9 Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Tue, 12 May 2020 01:33:32 +0200 Subject: [PATCH 54/81] Hd/add layer modification on generated emissive mesh for area light #364 --- .../CHANGELOG.md | 1 + .../Editor/Lighting/HDLightUI.Skin.cs | 2 + .../Editor/Lighting/HDLightUI.cs | 66 ++++++++++--- .../Editor/Lighting/SerializedHDLight.cs | 73 ++++++++++++-- .../Lighting/Light/HDAdditionalLightData.cs | 94 ++++++++++++++++++- 5 files changed, 211 insertions(+), 25 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 9a1f9cb7631..50d05d6d48e 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added Light decomposition lighting debugging modes and support in AOV - Added exposure compensation to Fixed exposure mode - Added an info box to warn about depth test artifacts when rendering object twice in custom passes with MSAA. +- Added Layer parameter on Area Light to modify Layer of generated Emissive Mesh ### Fixed - Fixed an issue where a dynamic sky changing any frame may not update the ambient probe. diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs index 791fbe90800..223aadbfac9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.Skin.cs @@ -80,6 +80,8 @@ sealed class Styles public readonly GUIContent displayAreaLightEmissiveMesh = new GUIContent("Display Emissive Mesh", "Generate an emissive mesh using the size, Color and Intensity of the Area Light."); public readonly GUIContent areaLightEmissiveMeshCastShadow = new GUIContent("Cast Shadows", "Specify wether the generated geometry create shadow or not when a shadow casting Light shines on it"); public readonly GUIContent areaLightEmissiveMeshMotionVector = new GUIContent("Motion Vectors", "Specify wether the generated Mesh renders 'Per Object Motion', 'Camera Motion' or 'No Motion' vectors to the Camera Motion Vector Texture."); + public readonly GUIContent areaLightEmissiveMeshSameLayer = new GUIContent("Same Layer", "If checked, use the same Layer than the Light one."); + public readonly GUIContent areaLightEmissiveMeshCustomLayer = new GUIContent("Custom Layer", "Specify on which layer the generated Mesh live."); public readonly GUIContent lightLayer = new GUIContent("Light Layer", "Specifies the current Light Layers that the Light affects. This Light illuminates corresponding Renderers with the same Light Layer flags."); public readonly GUIContent interactsWithSky = new GUIContent("Affect Physically Based Sky", "Check this option to make the light and the Physically Based sky affect one another."); diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs index ba050f4fb54..9ab5df722ac 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs @@ -104,17 +104,6 @@ static HDLightUI() CED.FoldoutGroup(s_Styles.shapeHeader, Expandable.Shape, k_ExpandedState, DrawShapeContent), CED.Conditional((serialized, owner) => serialized.type == HDLightType.Directional && !serialized.settings.isCompletelyBaked, CED.FoldoutGroup(s_Styles.celestialBodyHeader, Expandable.CelestialBody, k_ExpandedState, DrawCelestialBodyContent)), - //CED.TernaryConditional((serialized, owner) => serialized.type == HDLightType.Directional && !serialized.settings.isCompletelyBaked, - // CED.AdvancedFoldoutGroup(s_Styles.shapeHeader, Expandable.Shape, k_ExpandedState, - // (serialized, owner) => GetAdvanced(AdvancedMode.Shape, serialized, owner), - // (serialized, owner) => SwitchAdvanced(AdvancedMode.Shape, serialized, owner), - // DrawShapeContent, - // DrawShapeAdvancedContent - // ), - // CED.FoldoutGroup(s_Styles.shapeHeader, Expandable.Shape, k_ExpandedState, - // DrawShapeContent - // ) - //), CED.AdvancedFoldoutGroup(s_Styles.emissionHeader, Expandable.Emission, k_ExpandedState, (serialized, owner) => GetAdvanced(AdvancedMode.Emission, serialized, owner), (serialized, owner) => SwitchAdvanced(AdvancedMode.Emission, serialized, owner), @@ -821,6 +810,7 @@ static void DrawEmissionAdvancedContent(SerializedHDLight serialized, Editor own { serialized.UpdateAreaLightEmissiveMeshCastShadow(newCastShadow); } + EditorGUI.showMixedValue = false; lineRect = EditorGUILayout.GetControlRect(); SerializedHDLight.MotionVector newMotionVector; @@ -834,8 +824,62 @@ static void DrawEmissionAdvancedContent(SerializedHDLight serialized, Editor own { serialized.UpdateAreaLightEmissiveMeshMotionVectorGeneration(newMotionVector); } + EditorGUI.showMixedValue = false; + EditorGUI.showMixedValue = serialized.areaLightEmissiveMeshLayer.hasMultipleDifferentValues || serialized.lightLayer.hasMultipleDifferentValues; + EditorGUI.BeginChangeCheck(); + bool toggle; + using (new SerializedHDLight.AreaLightEmissiveMeshDrawScope(lineRect, s_Styles.areaLightEmissiveMeshSameLayer, showSubArea, serialized.areaLightEmissiveMeshLayer, serialized.deportedAreaLightEmissiveMeshLayer)) + { + toggle = EditorGUILayout.Toggle(s_Styles.areaLightEmissiveMeshSameLayer, serialized.areaLightEmissiveMeshLayer.intValue == -1); + } + if (EditorGUI.EndChangeCheck()) + { + serialized.UpdateAreaLightEmissiveMeshLayer(serialized.lightLayer.intValue); + if (toggle) + serialized.areaLightEmissiveMeshLayer.intValue = -1; + } EditorGUI.showMixedValue = false; + + ++EditorGUI.indentLevel; + if (toggle || serialized.areaLightEmissiveMeshLayer.hasMultipleDifferentValues) + { + using (new EditorGUI.DisabledScope(true)) + { + lineRect = EditorGUILayout.GetControlRect(); + EditorGUI.showMixedValue = serialized.areaLightEmissiveMeshLayer.hasMultipleDifferentValues || serialized.lightLayer.hasMultipleDifferentValues; + EditorGUI.LayerField(lineRect, s_Styles.areaLightEmissiveMeshCustomLayer, serialized.lightLayer.intValue); + EditorGUI.showMixedValue = false; + } + } + else + { + EditorGUI.showMixedValue = serialized.areaLightEmissiveMeshLayer.hasMultipleDifferentValues; + lineRect = EditorGUILayout.GetControlRect(); + int layer; + EditorGUI.BeginChangeCheck(); + using (new SerializedHDLight.AreaLightEmissiveMeshDrawScope(lineRect, s_Styles.areaLightEmissiveMeshCustomLayer, showSubArea, serialized.areaLightEmissiveMeshLayer, serialized.deportedAreaLightEmissiveMeshLayer)) + { + layer = EditorGUI.LayerField(lineRect, s_Styles.areaLightEmissiveMeshCustomLayer, serialized.areaLightEmissiveMeshLayer.intValue); + } + if (EditorGUI.EndChangeCheck()) + { + serialized.UpdateAreaLightEmissiveMeshLayer(layer); + } + // or if the value of layer got changed using the layer change including child mechanism (strangely apply even if object not editable), + // discard the change: the child is not saved anyway so the value in HDAdditionalLightData is the only serialized one. + else if (!EditorGUI.showMixedValue + && serialized.deportedAreaLightEmissiveMeshLayer != null + && !serialized.deportedAreaLightEmissiveMeshLayer.Equals(null) + && serialized.areaLightEmissiveMeshLayer.intValue != serialized.deportedAreaLightEmissiveMeshLayer.intValue) + { + GUI.changed = true; //force register change to handle update and apply later + serialized.UpdateAreaLightEmissiveMeshLayer(layer); + } + EditorGUI.showMixedValue = false; + } + --EditorGUI.indentLevel; + --EditorGUI.indentLevel; } diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs index d4c5aef2d36..b9cfcea5681 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/SerializedHDLight.cs @@ -32,6 +32,8 @@ internal class SerializedHDLight public SerializedProperty deportedAreaLightEmissiveMeshCastShadow; public SerializedProperty areaLightEmissiveMeshMotionVector; public SerializedProperty deportedAreaLightEmissiveMeshMotionVector; + public SerializedProperty areaLightEmissiveMeshLayer; + public SerializedProperty deportedAreaLightEmissiveMeshLayer; public SerializedProperty renderingLayerMask; public SerializedProperty shadowNearPlane; public SerializedProperty blockerSampleCount; @@ -97,12 +99,15 @@ internal class SerializedHDLight private SerializedProperty pointLightHDType; private SerializedProperty areaLightShapeProperty; - private IEnumerable emissiveMeshes; + private GameObject[] emissiveMeshes; public bool needUpdateAreaLightEmissiveMeshComponents = false; public SerializedObject serializedObject; + public SerializedProperty lightLayer; + private SerializedObject lightGameObject; + //contain serialized property that are mainly used to draw inspector public LightEditor.Settings settings; @@ -226,25 +231,50 @@ void System.IDisposable.Dispose() } } + struct AreaLightEmissiveMeshObjectEditionScope : System.IDisposable + { + SerializedHDLight m_Serialized; + public AreaLightEmissiveMeshObjectEditionScope(SerializedHDLight serialized) + { + m_Serialized = serialized; + foreach (GameObject emissiveMesh in m_Serialized.emissiveMeshes) + { + emissiveMesh.hideFlags &= ~HideFlags.NotEditable; + } + m_Serialized.areaLightEmissiveMeshLayer.serializedObject.Update(); + } + + void System.IDisposable.Dispose() + { + m_Serialized.areaLightEmissiveMeshLayer.serializedObject.ApplyModifiedProperties(); + foreach (GameObject emissiveMesh in m_Serialized.emissiveMeshes) + { + emissiveMesh.hideFlags |= HideFlags.NotEditable; + } + m_Serialized.areaLightEmissiveMeshLayer.serializedObject.Update(); + } + } + public struct AreaLightEmissiveMeshDrawScope : System.IDisposable { - int propertyCount; - bool oldEnableState; + SerializedProperty[] m_Properties; + bool m_OldEnableState; public AreaLightEmissiveMeshDrawScope(Rect rect, GUIContent label, bool enabler, params SerializedProperty[] properties) { - propertyCount = properties.Count(p => p != null); - foreach (var property in properties) + m_Properties = properties; + foreach (var property in m_Properties) if (property != null) EditorGUI.BeginProperty(rect, label, property); - oldEnableState = GUI.enabled; + m_OldEnableState = GUI.enabled; GUI.enabled = enabler; } void System.IDisposable.Dispose() { - GUI.enabled = oldEnableState; - for (int i = 0; i < propertyCount; ++i) - EditorGUI.EndProperty(); + GUI.enabled = m_OldEnableState; + foreach (var property in m_Properties) + if (property != null) + EditorGUI.EndProperty(); } } @@ -276,6 +306,16 @@ public void UpdateAreaLightEmissiveMeshMotionVectorGeneration(MotionVector motio } } + public void UpdateAreaLightEmissiveMeshLayer(int layer) + { + using (new AreaLightEmissiveMeshObjectEditionScope(this)) + { + areaLightEmissiveMeshLayer.intValue = layer; + if (deportedAreaLightEmissiveMeshLayer != null) //only possible while editing from prefab + deportedAreaLightEmissiveMeshLayer.intValue = layer; + } + } + public SerializedHDLight(HDAdditionalLightData[] lightDatas, LightEditor.Settings settings) { serializedObject = new SerializedObject(lightDatas); @@ -372,9 +412,13 @@ public SerializedHDLight(HDAdditionalLightData[] lightDatas, LightEditor.Setting // emission mesh areaLightEmissiveMeshCastShadow = o.Find("m_AreaLightEmissiveMeshShadowCastingMode"); areaLightEmissiveMeshMotionVector = o.Find("m_AreaLightEmissiveMeshMotionVectorGenerationMode"); + areaLightEmissiveMeshLayer = o.Find("m_AreaLightEmissiveMeshLayer"); } RefreshEmissiveMeshReference(); + + lightGameObject = new SerializedObject(serializedObject.targetObjects.Select(ld => ((HDAdditionalLightData)ld).gameObject).ToArray()); + lightLayer = lightGameObject.FindProperty("m_Layer"); } void RefreshEmissiveMeshReference() @@ -386,9 +430,11 @@ void RefreshEmissiveMeshReference() SerializedObject meshRendererSerializedObject = new SerializedObject(meshRenderers.ToArray()); deportedAreaLightEmissiveMeshCastShadow = meshRendererSerializedObject.FindProperty("m_CastShadows"); deportedAreaLightEmissiveMeshMotionVector = meshRendererSerializedObject.FindProperty("m_MotionVectors"); + SerializedObject gameObjectSerializedObject = new SerializedObject(emissiveMeshes); + deportedAreaLightEmissiveMeshLayer = gameObjectSerializedObject.FindProperty("m_Layer"); } else - deportedAreaLightEmissiveMeshCastShadow = deportedAreaLightEmissiveMeshMotionVector = null; + deportedAreaLightEmissiveMeshCastShadow = deportedAreaLightEmissiveMeshMotionVector = deportedAreaLightEmissiveMeshLayer = null; } public void FetchAreaLightEmissiveMeshComponents() @@ -416,6 +462,10 @@ public void Update() serializedObject.Update(); settings.Update(); + + lightGameObject.Update(); + deportedAreaLightEmissiveMeshMotionVector?.serializedObject.Update(); + deportedAreaLightEmissiveMeshLayer?.serializedObject.Update(); } void ApplyInternal(bool withDeportedEmissiveMeshData) @@ -423,7 +473,10 @@ void ApplyInternal(bool withDeportedEmissiveMeshData) serializedObject.ApplyModifiedProperties(); settings.ApplyModifiedProperties(); if (withDeportedEmissiveMeshData) + { deportedAreaLightEmissiveMeshMotionVector?.serializedObject.ApplyModifiedProperties(); + deportedAreaLightEmissiveMeshLayer?.serializedObject.ApplyModifiedProperties(); + } } public void Apply() => ApplyInternal(withDeportedEmissiveMeshData: true); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs index 83131607463..1daa053dd7f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs @@ -511,7 +511,7 @@ public bool applyRangeAttenuation /// /// If enabled, display an emissive mesh rect synchronized with the intensity and color of the light. /// - internal bool displayAreaLightEmissiveMesh + public bool displayAreaLightEmissiveMesh { get => m_DisplayAreaLightEmissiveMesh; set @@ -1465,9 +1465,53 @@ void CreateChildEmissiveMeshViewerIfNeeded() if (PrefabUtility.IsPartOfPrefabAsset(this)) return; #endif + bool here = m_ChildEmissiveMeshViewer != null && !m_ChildEmissiveMeshViewer.Equals(null); - //if not here, create it - if (m_ChildEmissiveMeshViewer == null || m_ChildEmissiveMeshViewer.Equals(null)) +#if UNITY_EDITOR + //if not parented anymore, destroy it + if (here && m_ChildEmissiveMeshViewer.transform.parent != transform) + { + if (Application.isPlaying) + Destroy(m_ChildEmissiveMeshViewer); + else + DestroyImmediate(m_ChildEmissiveMeshViewer); + m_ChildEmissiveMeshViewer = null; + m_EmissiveMeshFilter = null; + here = false; + } +#endif + + //if not here, try to find it first + if (!here) + { + foreach (Transform child in transform) + { + var test = child.GetComponents(typeof(Component)); + if (child.name == k_EmissiveMeshViewerName + && child.hideFlags == (HideFlags.NotEditable | HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor) + && child.GetComponents(typeof(MeshFilter)).Length == 1 + && child.GetComponents(typeof(MeshRenderer)).Length == 1 + && child.GetComponents(typeof(Component)).Length == 3) // Transform + MeshFilter + MeshRenderer + { + m_ChildEmissiveMeshViewer = child.gameObject; + m_ChildEmissiveMeshViewer.transform.localPosition = Vector3.zero; + m_ChildEmissiveMeshViewer.transform.localRotation = Quaternion.identity; + m_ChildEmissiveMeshViewer.transform.localScale = Vector3.one; + m_ChildEmissiveMeshViewer.layer = areaLightEmissiveMeshLayer == -1 ? gameObject.layer : areaLightEmissiveMeshLayer; + + m_EmissiveMeshFilter = m_ChildEmissiveMeshViewer.GetComponent(); + emissiveMeshRenderer = m_ChildEmissiveMeshViewer.GetComponent(); + emissiveMeshRenderer.shadowCastingMode = m_AreaLightEmissiveMeshShadowCastingMode; + emissiveMeshRenderer.motionVectorGenerationMode = m_AreaLightEmissiveMeshMotionVectorGenerationMode; + + here = true; + break; + } + } + } + + //if still not here, create it + if (!here) { m_ChildEmissiveMeshViewer = new GameObject(k_EmissiveMeshViewerName, typeof(MeshFilter), typeof(MeshRenderer)); m_ChildEmissiveMeshViewer.hideFlags = HideFlags.NotEditable | HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor; @@ -1475,6 +1519,7 @@ void CreateChildEmissiveMeshViewerIfNeeded() m_ChildEmissiveMeshViewer.transform.localPosition = Vector3.zero; m_ChildEmissiveMeshViewer.transform.localRotation = Quaternion.identity; m_ChildEmissiveMeshViewer.transform.localScale = Vector3.one; + m_ChildEmissiveMeshViewer.layer = areaLightEmissiveMeshLayer == -1 ? gameObject.layer : areaLightEmissiveMeshLayer; m_EmissiveMeshFilter = m_ChildEmissiveMeshViewer.GetComponent(); emissiveMeshRenderer = m_ChildEmissiveMeshViewer.GetComponent(); @@ -1498,6 +1543,8 @@ void DestroyChildEmissiveMeshViewer() ShadowCastingMode m_AreaLightEmissiveMeshShadowCastingMode = ShadowCastingMode.Off; [SerializeField] MotionVectorGenerationMode m_AreaLightEmissiveMeshMotionVectorGenerationMode; + [SerializeField] + int m_AreaLightEmissiveMeshLayer = -1; //Special value that means we need to grab the one in the Light for initialization (for migration purpose) /// Change the Shadow Casting Mode of the generated emissive mesh for Area Light public ShadowCastingMode areaLightEmissiveMeshShadowCastingMode @@ -1532,7 +1579,24 @@ public MotionVectorGenerationMode areaLightEmissiveMeshMotionVectorGenerationMod } } } - + + /// Change the Layer of the generated emissive mesh for Area Light + public int areaLightEmissiveMeshLayer + { + get => m_AreaLightEmissiveMeshLayer; + set + { + if (m_AreaLightEmissiveMeshLayer == value) + return; + + m_AreaLightEmissiveMeshLayer = value; + if (emissiveMeshRenderer != null && !emissiveMeshRenderer.Equals(null)) + { + emissiveMeshRenderer.gameObject.layer = m_AreaLightEmissiveMeshLayer; + } + } + } + private void DisableCachedShadowSlot() { if (WillRenderShadowMap() && !ShadowIsUpdatedEveryFrame()) @@ -2087,6 +2151,28 @@ void LateUpdate() return; #endif +#if UNITY_EDITOR + //if not parented anymore, refresh it + if (m_ChildEmissiveMeshViewer != null && !m_ChildEmissiveMeshViewer.Equals(null)) + { + if (m_ChildEmissiveMeshViewer.transform.parent != transform) + { + CreateChildEmissiveMeshViewerIfNeeded(); + UpdateAreaLightEmissiveMesh(); + } + if (m_ChildEmissiveMeshViewer.gameObject.isStatic != gameObject.isStatic) + m_ChildEmissiveMeshViewer.gameObject.isStatic = gameObject.isStatic; + if (GameObjectUtility.GetStaticEditorFlags(m_ChildEmissiveMeshViewer.gameObject) != GameObjectUtility.GetStaticEditorFlags(gameObject)) + GameObjectUtility.SetStaticEditorFlags(m_ChildEmissiveMeshViewer.gameObject, GameObjectUtility.GetStaticEditorFlags(gameObject)); + } +#endif + + //auto change layer on emissive mesh + if (areaLightEmissiveMeshLayer == -1 + && m_ChildEmissiveMeshViewer != null && !m_ChildEmissiveMeshViewer.Equals(null) + && m_ChildEmissiveMeshViewer.gameObject.layer != gameObject.layer) + m_ChildEmissiveMeshViewer.gameObject.layer = gameObject.layer; + // Delayed cleanup when removing emissive mesh from timeline if (needRefreshEmissiveMeshesFromTimeLineUpdate) { From 139c8c07bccdb3341eba7d3e8b099a4ca8069da5 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 14 May 2020 14:01:44 +0100 Subject: [PATCH 55/81] Update Look-Dev-Environment-Library.md (#365) --- .../Documentation~/Look-Dev-Environment-Library.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md b/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md index 0bc2862a183..c1be65fb941 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md @@ -47,6 +47,7 @@ To add, remove, or duplicate environments, use the toolbar at the bottom of the ## Importing an HDRI Texture -To import an HDRI Texture into the Unity Editor, load an **.hdr** or **.exr** file into your Unity Project like you would any other image. In the Texture Importer Inspector window, set **Texture Type** to **Default**, set **Texture Shape** to **Cube**, and set **Convolution Type** to **Specular (Glossy Reflection)**. +To import an HDRI Texture into the Unity Editor, load an **.hdr** or **.exr** file into your Unity Project like you would any other image. In the Texture Importer Inspector window, set **Texture Type** to **Default**, set **Texture Shape** to **Cube**, and set **Convolution Type** to **None**. + +When you want to test an HDRI Texture Asset or a skybox cube map Material, drag and drop it into the Look Dev view. -When you want to test an HDRI Texture Asset or a skybox cube map Material, drag and drop it into the Look Dev view. \ No newline at end of file From 5fefa89bbc1c28be84ac198f7557959371945aa9 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Mon, 11 May 2020 11:35:01 +0100 Subject: [PATCH 56/81] Update Volumetric-Lighting.md (#402) Fixes https://fogbugz.unity3d.com/f/cases/1238592 --- .../Documentation~/Volumetric-Lighting.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md b/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md index 50c128176e8..bdf941ed394 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md @@ -1,6 +1,6 @@ # Volumetric Lighting -The High Definition Render Pipeline (HDRP) includes a volumetric lighting system that renders Volumetric Fog. HDRP also implements a unified lighting system, which means that all Scene components (such as Lights, as well as opaque and transparent GameObjects) interact with the fog in order to make it volumetric. +The High Definition Render Pipeline (HDRP) includes a volumetric lighting system that renders Volumetric Fog. HDRP also implements a unified lighting system, which means that all Scene components (such as [Lights](Light-Component.md), as well as opaque and transparent GameObjects) interact with the fog to make it volumetric. ## Enabling Volumetric Lighting @@ -12,3 +12,6 @@ To toggle and customize Volumetric Lighting in an [HDRP Asset](HDRP-Asset.html): 3. In the **Default Frame Settings** section, under the **Lighting** subsection, make sure you enable **Fog** and **Volumetric** if they are not already. ![](Images/VolumetricLighting2.png) 4. If you want to enable reprojection support, check **Reprojection**. This option improves the lighting quality in the Scene by taking previous frames into account when calculating the lighting for the current frame. Currently, this option is not compatible with dynamic lights, so you may encounter ghosting artifacts behind moving Lights. Additionally, using high values for **Global Anisotropy** in the [Fog](Override-Fog.html) Volume override may cause flickering Shadows. + +## Notes +Volumetric fog does not work for Cameras that use oblique projection matrices. If you want a Camera to render volumetric fog, do not assign an off-axis projection to it. \ No newline at end of file From e0ec69e56912e0610b15b69b696c5096fba1600e Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Tue, 12 May 2020 17:51:25 +0200 Subject: [PATCH 57/81] Hd/fix nullref while removing decal component #416 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/Material/Decal/DecalProjectorEditor.cs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 50d05d6d48e..7c6818736f4 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed issue with reflection probes in realtime time mode with OnEnable baking having wrong lighting with sky set to dynamic (case 1238047). - Fixed an invalid rotation in Planar Reflection Probe editor display, that was causing an error message (case 1182022) - Fixed cookie texture not updated when changing an import settings (srgb for example). +- Fix error when removing DecalProjector from component contextual menu (case 1243960) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs index ab124573fa3..aa2ce0acb8a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Decal/DecalProjectorEditor.cs @@ -125,9 +125,10 @@ private void OnEnable() private void OnDisable() { - foreach (var decalProjector in targets) + foreach (DecalProjector decalProjector in targets) { - (decalProjector as DecalProjector).OnMaterialChange -= UpdateMaterialEditor; + if (decalProjector != null) + decalProjector.OnMaterialChange -= UpdateMaterialEditor; } s_Owner = null; } From 2cb76f98c3ad204f0a0895916639bd63fd3cddff Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Tue, 12 May 2020 18:23:10 +0200 Subject: [PATCH 58/81] Fix issue with Uber Post process shader when alpha is enabled #422 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/PostProcessing/Shaders/UberPost.compute | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 7c6818736f4..f6d2fce9911 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed an invalid rotation in Planar Reflection Probe editor display, that was causing an error message (case 1182022) - Fixed cookie texture not updated when changing an import settings (srgb for example). - Fix error when removing DecalProjector from component contextual menu (case 1243960) +- Fixed issue with post process when running in RGBA16 and an object with additive blending is in the scene. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute index aabda26bc6b..d5e8be447e5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/UberPost.compute @@ -231,7 +231,8 @@ void MAIN(uint3 dispatchThreadId : SV_DispatchThreadID) // Alpha mask #ifdef ENABLE_ALPHA // Post processing is not applied on pixels with zero alpha - color.xyz = lerp(inputColor.xyz, color.xyz, inputColor.a); + // Saturate is necessary to avoid issues when additive blending pushes the alpha over 1. + color.xyz = lerp(inputColor.xyz, color.xyz, saturate(inputColor.a)); #endif // Done From e457ebac4648b14eb8ed0b8014c3a7c51a3f1c59 Mon Sep 17 00:00:00 2001 From: skhiat <55133890+skhiat@users.noreply.github.com> Date: Wed, 13 May 2020 09:17:51 +0200 Subject: [PATCH 59/81] Fix the bug (#430) --- .../Runtime/Material/Decal/DecalSystem.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs index ceeed37afbd..903fda5eb61 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Decal/DecalSystem.cs @@ -783,7 +783,14 @@ public int DrawOrder { get { - return this.m_Material.GetInt("_DrawOrder"); + if (m_IsHDRenderPipelineDecal) + { + return this.m_Material.GetInt("_DrawOrder"); + } + else + { + return 0; + } } } From 4a5c68b4fed82f55b1e643289709f610bf4d664b Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Thu, 14 May 2020 15:07:01 +0200 Subject: [PATCH 60/81] Fix issue causing not all baked reflection probes to be deleted #441 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/Lighting/Reflection/HDBakedReflectionSystem.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index f6d2fce9911..db0c5a98a30 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -79,6 +79,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed cookie texture not updated when changing an import settings (srgb for example). - Fix error when removing DecalProjector from component contextual menu (case 1243960) - Fixed issue with post process when running in RGBA16 and an object with additive blending is in the scene. +- Fixed issue that caused not all baked reflection to be deleted upon clicking "Clear Baked Data" in the lighting menu (case 1136080) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs index 416a320cdbc..a72d37ea47e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDBakedReflectionSystem.cs @@ -471,8 +471,13 @@ void DeleteCubemapAssets(bool deleteUnusedOnly) // Or we delete all assets || !deleteUnusedOnly) { + // If the buffer is full we empty it and then push again the element we were trying to + // push but failed. if (!buffer.TryPush(files[fileI])) + { DeleteAllAssetsIn(ref buffer); + buffer.TryPush(files[fileI]); + } } } } @@ -489,6 +494,9 @@ static void DeleteAllAssetsIn(ref CoreUnsafeUtils.FixedBufferStringQueue queue) while (queue.TryPop(out string path)) AssetDatabase.DeleteAsset(path); AssetDatabase.StopAssetEditing(); + + // Clear the queue so that can be filled again. + queue.Clear(); } internal static void Checkout(string targetFile) From 9f59d1df16d56dbde48953d6461a2f29878533ba Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 14 May 2020 15:00:59 +0100 Subject: [PATCH 61/81] Updated Decal Projector doc (#477) Updated Limitations section and added a disclaimer about decal shader stripping. --- .../Documentation~/Decal-Projector.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md b/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md index 371832bad66..37ad65a2972 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md @@ -42,6 +42,7 @@ Using the Inspector allows you to change all of the Decal Projector properties, | **Fade Factor** | Allows you to manually fade the decal in and out. A value of 0 makes the decal fully transparent, and a value of 1 makes the decal as opaque as defined by the **Material**. The **Material** manages the maximum opacity of the decal using **Global Opacity** and an opacity map. | | **Affects Transparent** | Enable the checkbox to allow HDRP to draw the projector’s decal on top of transparent surfaces. HDRP packs all Textures from decals with **Affects Transparency** enabled into an atlas, which can affect memory and performance. You can edit the dimensions of this atlas in the **Decals** section of your Unity Project’s [HDRP Asset](HDRP-Asset.html#Decals). | -## Know limitation +## Limitations -- Decal texture tiling is ignored when projected on transparent surface +- If you project a decal onto a transparent surface, HDRP ignores the decal's Texture tiling. +- In **Project Settings > Graphics**, if **Instancing Variants** is set to **Strip All**, Unity strips the Decal Shader this component references when you build your Project. This happens even if you include the Shader in the **Always Included Shaders** list. If Unity strips the Shader during the build process, the decal does not appear in your built Application. From 51a5ed34b524a7779686e28247d364d5749e5f1d Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Thu, 14 May 2020 15:09:17 +0100 Subject: [PATCH 62/81] Look Dev docs refactor 2 #484 --- .../Documentation~/Images/LookDev1.png | 0 .../Documentation~/Images/LookDev2.png | 0 .../Documentation~/Images/LookDev3.png | 0 .../Documentation~/Images/LookDev4.png | 0 .../Documentation~/Images/LookDev5.png | 0 .../Documentation~/Images/LookDev6.png | 0 .../Documentation~/Images/LookDev7.png | 0 .../Documentation~/Images/LookDev8.png | 0 .../Documentation~/Images/LookDev9.png | 0 .../Images/LookDevEnvironmentLibrary1.png | 0 .../Images/LookDevEnvironmentLibrary2.png | 0 .../Images/LookDevEnvironmentLibrary3.png | 0 .../Images/LookDevEnvironmentLibrary4.png | 0 .../Images/LookDevEnvironmentLibrary5.png | 0 .../Look-Dev-Environment-Library.md | 3 +- .../Documentation~/Look-Dev.md | 142 ++++++++++++++++++ .../Documentation~/TableOfContents.md | 4 +- .../Documentation~/Look-Dev.md | 142 +----------------- .../Documentation~/TableOfContents.md | 4 +- 19 files changed, 150 insertions(+), 145 deletions(-) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev1.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev2.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev3.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev4.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev5.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev6.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev7.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev8.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDev9.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDevEnvironmentLibrary1.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDevEnvironmentLibrary2.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDevEnvironmentLibrary3.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDevEnvironmentLibrary4.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Images/LookDevEnvironmentLibrary5.png (100%) rename {com.unity.render-pipelines.high-definition => com.unity.render-pipelines.core}/Documentation~/Look-Dev-Environment-Library.md (98%) create mode 100644 com.unity.render-pipelines.core/Documentation~/Look-Dev.md diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev1.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev1.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev1.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev1.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev2.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev2.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev2.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev2.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev3.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev3.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev3.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev3.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev4.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev4.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev4.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev4.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev5.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev5.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev5.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev5.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev6.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev6.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev6.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev6.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev7.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev7.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev7.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev7.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev8.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev8.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev8.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev8.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev9.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDev9.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDev9.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDev9.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary1.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary1.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary1.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary1.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary2.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary2.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary2.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary2.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary3.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary3.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary3.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary3.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary4.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary4.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary4.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary4.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary5.png b/com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary5.png similarity index 100% rename from com.unity.render-pipelines.high-definition/Documentation~/Images/LookDevEnvironmentLibrary5.png rename to com.unity.render-pipelines.core/Documentation~/Images/LookDevEnvironmentLibrary5.png diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md b/com.unity.render-pipelines.core/Documentation~/Look-Dev-Environment-Library.md similarity index 98% rename from com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md rename to com.unity.render-pipelines.core/Documentation~/Look-Dev-Environment-Library.md index c1be65fb941..cfaa0c1da1a 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev-Environment-Library.md +++ b/com.unity.render-pipelines.core/Documentation~/Look-Dev-Environment-Library.md @@ -49,5 +49,4 @@ To add, remove, or duplicate environments, use the toolbar at the bottom of the To import an HDRI Texture into the Unity Editor, load an **.hdr** or **.exr** file into your Unity Project like you would any other image. In the Texture Importer Inspector window, set **Texture Type** to **Default**, set **Texture Shape** to **Cube**, and set **Convolution Type** to **None**. -When you want to test an HDRI Texture Asset or a skybox cube map Material, drag and drop it into the Look Dev view. - +When you want to test an HDRI Texture Asset or a skybox cube map Material, drag and drop it into the Look Dev view. \ No newline at end of file diff --git a/com.unity.render-pipelines.core/Documentation~/Look-Dev.md b/com.unity.render-pipelines.core/Documentation~/Look-Dev.md new file mode 100644 index 00000000000..2797d2b7a5c --- /dev/null +++ b/com.unity.render-pipelines.core/Documentation~/Look-Dev.md @@ -0,0 +1,142 @@ +# Look Dev + +Look Dev is an image-based lighting tool that contains a viewer for you to check and compare Assets to ensure they work well in various lighting conditions. Look Dev uses the Scriptable Render Pipeline, so it can display the Asset in the same way as it looks in your Scene. You can load Assets into Look Dev either as Prefabs or from the Hierarchy window. + +Look Dev is only available in Edit mode. The Look Dev window closes when you enter Play mode. + +### Asset validation + +Asset validation confirms whether Assets are authored correctly and behave as expected in different lighting environments. + +You must use an HDRI (high dynamic range image) to validate your Assets in Look Dev. An HDRI contains real-world lighting with incredibly high detail. As such, it offers perfect lighting that is difficult to create by hand. By using such an accurate lighting environment to test an Asset, you can determine whether the Asset itself or your Project's lighting is reducing the visual quality of your Scene. + +You can load two different Assets into Look Dev at the same time and compare them in two viewports. For example, an Art Director can check that a new Asset matches the art direction guidelines of a reference Asset. + +## Using Look Dev + +To open Look Dev in the Unity Editor, select **Window > Render Pipeline > Look Dev**. The first time you use Look Dev, you must either create a new [Environment Library](Look-Dev-Environment-Library.html) or load one. For information on how to create an Environment Library, see the [Environment Library documentation](Look-Dev-Environment-Library.html). + +### Viewports + +By default, there is only one viewport in Look Dev, but you can choose from a selection of split-screen views (see the [Multi-view section](#MultiView)). + +### Controls + +Navigation with the Look Dev Camera works in a similar way to the [Scene view Camera](https://docs.unity3d.com/Manual/SceneViewNavigation.html): + +- **Rotate around pivot:** Left click and drag (this is similar to the Scene view except that you need to press the Alt key for the Scene view Camera). +- **Pan camera:** Middle click and drag. +- **Zoom:** Alt + right click and drag. +- **Forward/backward:** Mouse wheel. +- **First Person mode:** Right click + W, A,S, and D. + +### Loading Assets into Look Dev + +Look Dev lets you view: + +**Prefabs** - To load a Prefab into Look Dev, drag it from the Project window into the Look Dev viewport. + +**GameObjects** - To load a copy of a Hierarchy GameObject, drag the GameObject from the Hierarchy into the Look Dev viewport. + + + +## Viewport modes + +Use the toolbar in the top-left of the window to change which viewing mode Look Dev uses. + +### Single viewport + +![](Images/LookDev1.png) + +By default, Look Dev displays a single viewport which contains the Prefab or GameObject you are working with. If you are in another viewing mode, you can click either the number **1** or number **2** button to go back to single view. Each button corresponds to a viewport in Look Dev. Select button **1** to use viewport 1, and button 2 to use viewport **2**. + + + +### Multi-viewport + +![](Images/LookDev2.png) + +Use multiple viewports to compare different environments and settings for the same Asset. You can arrange viewports: + +- Vertically side-by-side. Use this mode to compare two different lighting conditions on the same Asset to check that the Asset behaves correctly. +- Horizontally side-by-side. Use this mode to compare two different lighting conditions for horizontal objects, like an environment Asset, to check that the Asset behaves correctly. +- Split-screen. Use this mode investigate texture problems using a debug Shader mode (for example, use one screen to view Normal or Albedo shading, and the other for environment-lit mode). +- Side-by-side and split-screen: Use this mode to compare two different versions of the same Asset using the same lighting conditions to see which changes improve the Asset’s quality. + +All three of these modes are useful to compare two different versions of the same Asset using the same lighting conditions to see which changes improve the Asset’s quality. + +To load a different Prefab or Hierarchy GameObject into each split-screen view, drag and drop the Asset into the viewport that you want to view it in. + +When using multiple viewports, it only makes sense to compare different Prefabs or GameObjects when you want to look at two versions of the same Asset. Comparing completely different Assets doesn’t give you a good idea of the difference in lighting or visual effect. + +##### Vertical or horizontal side-by-side + +Vertical and horizontal side-by-side viewports show an identical view of your Asset. + +![](Images/LookDev3.png) + +##### Split-screen + +In a split-screen view, there is a red/blue manipulation Gizmo that separates the two viewports. For information on how to use this Gizmo, see [Using the manipulation Gizmo](#ManipulationGizmo). + +![](Images/LookDev4.png) + +#### Multi-viewport Camera + +By default, Look Dev synchronizes the camera movement for both views. To decouple the Cameras from one another, and manipulate them independently, click the **Synchronized Cameras** button in-between the two numbered Camera buttons. + +![](Images/LookDev5.png) + +To align the cameras with each other, or reset them, click on the drop-down arrow next to the viewport **2** icon: + +![](Images/LookDev6.png) + + + +### Using the manipulation Gizmo + +The manipulation Gizmo represents the separation plane between the two viewports. It has different behavior in split-screen mode, but you use it in the same way for both side-by-side or split-screen modes. + +#### Moving the separator + +To move the separator, click and drag the straight line of the Gizmo to the location you want. + +![](Images/LookDev7.png) + +#### Changing the orientation and length + +To change the orientation and length of the manipulator Gizmo, click and drag the circle at either end of the manipulator. Changing the length of the Gizmo lets you set the orientation and [blending](#Blending) values more precisely. + +![](Images/LookDev8.png)) + +#### Changing the split in increments + +To change the split in increments, click and hold the circle on the end of the manipulation Gizmo, then hold Shift as you move the mouse. This snaps the manipulation Gizmo to set angles in increments of 22.5°, which is useful for a perfectly horizontal, vertical or diagonal angle. + + + +#### Blending + +The central white circle on the separator allows you to blend between the two views. Left click on it and drag along the red line to blend the left-hand view with the right-hand view. Drag along the blue line to blend the right-hand view with the left-hand view (as shown in the image below). + +The white circle automatically snaps back into the center when you drag it back. This helps you get back to the default blending value quickly. + +![](Images/LookDev9.png) + +### HDRI environments in Look Dev + +Lighting in Look Dev uses an HDRI. The Look Dev view allows you to manipulate and easily switch between HDRIs to simulate different environments for the Asset you are working on. + +Look Dev uses the [Environment Library](Look-Dev-Environment-Library.html) Asset to store a list of environments, which are HDRIs with extra properties that you can use to further refine the environment. For information on how to create, edit, and assign Environment Libraries, see the [Environment Library documentation](Look-Dev-Environment-Library.html#Creation). + +## Implementing Look Dev for your custom Scriptable Render Pipeline + +In order to use Look Dev in your custom Scriptable Render Pipeline, you must implement the **UnityEngine.Rendering.LookDev.IDataProvider** interface. + +| **Function** | **Description** | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| **void FirstInitScene(StageRuntimeInterface stage)** | Look Dev calls this function after it initializes the Scene with a Light and Camera. It uses this function to add and configure extra components according to the needs of your Scriptable Render Pipeline. | +| **void UpdateSky(Camera camera, Sky sky, StageRuntimeInterface stage)** | Look Dev uses this function to update the environment when you change something in Look Dev. You can handle the sky in various ways, so add code that corresponds to your Scriptable Render Pipeline. | +| **IEnumerable****** **supportedDebugModes { get; }** | Use this function to specify the list of supported debug modes. You do not need to add **None** because Look Dev handles that automatically. | +| **void UpdateDebugMode(int debugIndex)** | Use this function to update the debug mode based on what the user selects. The **debugIndex** matches the list in **supportedDebugModes**. If the user selects **None**, then the **debugIndex** is **-1**; | +| **void GetShadowMask(ref RenderTexture output, StageRuntimeInterface stage)** | This function computes a shadow map. The given **StageRuntimeInterface** contains access to the Camera and a Light simulating the sun. | \ No newline at end of file diff --git a/com.unity.render-pipelines.core/Documentation~/TableOfContents.md b/com.unity.render-pipelines.core/Documentation~/TableOfContents.md index 43587d6cc61..3896f5b625e 100644 --- a/com.unity.render-pipelines.core/Documentation~/TableOfContents.md +++ b/com.unity.render-pipelines.core/Documentation~/TableOfContents.md @@ -1,4 +1,6 @@ * [SRP Core](index) * Camera components * [Free Camera](Free-Camera) - * [Camera Switcher](Camera-Switcher) \ No newline at end of file + * [Camera Switcher](Camera-Switcher) +* [Look Dev](Look-Dev) + * [Environment Library](Look-Dev-Environment-Library) \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev.md b/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev.md index 2797d2b7a5c..db12c7feac2 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Look-Dev.md @@ -1,142 +1,6 @@ # Look Dev +Look Dev is an image-based lighting tool that you can use to test how your Assets look in various lighting conditions. -Look Dev is an image-based lighting tool that contains a viewer for you to check and compare Assets to ensure they work well in various lighting conditions. Look Dev uses the Scriptable Render Pipeline, so it can display the Asset in the same way as it looks in your Scene. You can load Assets into Look Dev either as Prefabs or from the Hierarchy window. +For more information, see [the SRP Core documentation.](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest/index.html?subfolder=/manual/Look-Dev.html) -Look Dev is only available in Edit mode. The Look Dev window closes when you enter Play mode. - -### Asset validation - -Asset validation confirms whether Assets are authored correctly and behave as expected in different lighting environments. - -You must use an HDRI (high dynamic range image) to validate your Assets in Look Dev. An HDRI contains real-world lighting with incredibly high detail. As such, it offers perfect lighting that is difficult to create by hand. By using such an accurate lighting environment to test an Asset, you can determine whether the Asset itself or your Project's lighting is reducing the visual quality of your Scene. - -You can load two different Assets into Look Dev at the same time and compare them in two viewports. For example, an Art Director can check that a new Asset matches the art direction guidelines of a reference Asset. - -## Using Look Dev - -To open Look Dev in the Unity Editor, select **Window > Render Pipeline > Look Dev**. The first time you use Look Dev, you must either create a new [Environment Library](Look-Dev-Environment-Library.html) or load one. For information on how to create an Environment Library, see the [Environment Library documentation](Look-Dev-Environment-Library.html). - -### Viewports - -By default, there is only one viewport in Look Dev, but you can choose from a selection of split-screen views (see the [Multi-view section](#MultiView)). - -### Controls - -Navigation with the Look Dev Camera works in a similar way to the [Scene view Camera](https://docs.unity3d.com/Manual/SceneViewNavigation.html): - -- **Rotate around pivot:** Left click and drag (this is similar to the Scene view except that you need to press the Alt key for the Scene view Camera). -- **Pan camera:** Middle click and drag. -- **Zoom:** Alt + right click and drag. -- **Forward/backward:** Mouse wheel. -- **First Person mode:** Right click + W, A,S, and D. - -### Loading Assets into Look Dev - -Look Dev lets you view: - -**Prefabs** - To load a Prefab into Look Dev, drag it from the Project window into the Look Dev viewport. - -**GameObjects** - To load a copy of a Hierarchy GameObject, drag the GameObject from the Hierarchy into the Look Dev viewport. - - - -## Viewport modes - -Use the toolbar in the top-left of the window to change which viewing mode Look Dev uses. - -### Single viewport - -![](Images/LookDev1.png) - -By default, Look Dev displays a single viewport which contains the Prefab or GameObject you are working with. If you are in another viewing mode, you can click either the number **1** or number **2** button to go back to single view. Each button corresponds to a viewport in Look Dev. Select button **1** to use viewport 1, and button 2 to use viewport **2**. - - - -### Multi-viewport - -![](Images/LookDev2.png) - -Use multiple viewports to compare different environments and settings for the same Asset. You can arrange viewports: - -- Vertically side-by-side. Use this mode to compare two different lighting conditions on the same Asset to check that the Asset behaves correctly. -- Horizontally side-by-side. Use this mode to compare two different lighting conditions for horizontal objects, like an environment Asset, to check that the Asset behaves correctly. -- Split-screen. Use this mode investigate texture problems using a debug Shader mode (for example, use one screen to view Normal or Albedo shading, and the other for environment-lit mode). -- Side-by-side and split-screen: Use this mode to compare two different versions of the same Asset using the same lighting conditions to see which changes improve the Asset’s quality. - -All three of these modes are useful to compare two different versions of the same Asset using the same lighting conditions to see which changes improve the Asset’s quality. - -To load a different Prefab or Hierarchy GameObject into each split-screen view, drag and drop the Asset into the viewport that you want to view it in. - -When using multiple viewports, it only makes sense to compare different Prefabs or GameObjects when you want to look at two versions of the same Asset. Comparing completely different Assets doesn’t give you a good idea of the difference in lighting or visual effect. - -##### Vertical or horizontal side-by-side - -Vertical and horizontal side-by-side viewports show an identical view of your Asset. - -![](Images/LookDev3.png) - -##### Split-screen - -In a split-screen view, there is a red/blue manipulation Gizmo that separates the two viewports. For information on how to use this Gizmo, see [Using the manipulation Gizmo](#ManipulationGizmo). - -![](Images/LookDev4.png) - -#### Multi-viewport Camera - -By default, Look Dev synchronizes the camera movement for both views. To decouple the Cameras from one another, and manipulate them independently, click the **Synchronized Cameras** button in-between the two numbered Camera buttons. - -![](Images/LookDev5.png) - -To align the cameras with each other, or reset them, click on the drop-down arrow next to the viewport **2** icon: - -![](Images/LookDev6.png) - - - -### Using the manipulation Gizmo - -The manipulation Gizmo represents the separation plane between the two viewports. It has different behavior in split-screen mode, but you use it in the same way for both side-by-side or split-screen modes. - -#### Moving the separator - -To move the separator, click and drag the straight line of the Gizmo to the location you want. - -![](Images/LookDev7.png) - -#### Changing the orientation and length - -To change the orientation and length of the manipulator Gizmo, click and drag the circle at either end of the manipulator. Changing the length of the Gizmo lets you set the orientation and [blending](#Blending) values more precisely. - -![](Images/LookDev8.png)) - -#### Changing the split in increments - -To change the split in increments, click and hold the circle on the end of the manipulation Gizmo, then hold Shift as you move the mouse. This snaps the manipulation Gizmo to set angles in increments of 22.5°, which is useful for a perfectly horizontal, vertical or diagonal angle. - - - -#### Blending - -The central white circle on the separator allows you to blend between the two views. Left click on it and drag along the red line to blend the left-hand view with the right-hand view. Drag along the blue line to blend the right-hand view with the left-hand view (as shown in the image below). - -The white circle automatically snaps back into the center when you drag it back. This helps you get back to the default blending value quickly. - -![](Images/LookDev9.png) - -### HDRI environments in Look Dev - -Lighting in Look Dev uses an HDRI. The Look Dev view allows you to manipulate and easily switch between HDRIs to simulate different environments for the Asset you are working on. - -Look Dev uses the [Environment Library](Look-Dev-Environment-Library.html) Asset to store a list of environments, which are HDRIs with extra properties that you can use to further refine the environment. For information on how to create, edit, and assign Environment Libraries, see the [Environment Library documentation](Look-Dev-Environment-Library.html#Creation). - -## Implementing Look Dev for your custom Scriptable Render Pipeline - -In order to use Look Dev in your custom Scriptable Render Pipeline, you must implement the **UnityEngine.Rendering.LookDev.IDataProvider** interface. - -| **Function** | **Description** | -| ------------------------------------------------------------ | ------------------------------------------------------------ | -| **void FirstInitScene(StageRuntimeInterface stage)** | Look Dev calls this function after it initializes the Scene with a Light and Camera. It uses this function to add and configure extra components according to the needs of your Scriptable Render Pipeline. | -| **void UpdateSky(Camera camera, Sky sky, StageRuntimeInterface stage)** | Look Dev uses this function to update the environment when you change something in Look Dev. You can handle the sky in various ways, so add code that corresponds to your Scriptable Render Pipeline. | -| **IEnumerable****** **supportedDebugModes { get; }** | Use this function to specify the list of supported debug modes. You do not need to add **None** because Look Dev handles that automatically. | -| **void UpdateDebugMode(int debugIndex)** | Use this function to update the debug mode based on what the user selects. The **debugIndex** matches the list in **supportedDebugModes**. If the user selects **None**, then the **debugIndex** is **-1**; | -| **void GetShadowMask(ref RenderTexture output, StageRuntimeInterface stage)** | This function computes a shadow map. The given **StageRuntimeInterface** contains access to the Camera and a Light simulating the sun. | \ No newline at end of file +![](Images/HDRPFeatures-LookDev.png) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md index ef71b2f9e67..967712e4a3b 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md @@ -139,9 +139,7 @@ * Components * [Decal Projector](Decal-Projector) * Tools - * Look Dev - * [Look Dev Window](Look-Dev) - * [Environment Library](Look-Dev-Environment-Library) + * [Look Dev](Look-Dev) * Debugging * [MatCap](MatCap) * [Render Pipeline Debug Window](Render-Pipeline-Debug-Window) From 6529107fec9c1143f9430739e67335af4c5248ed Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Fri, 15 May 2020 01:27:33 +0200 Subject: [PATCH 63/81] [7.x.x Backport] Fix issue with corrupted values with Layer Lit when using multiply mode for vertex color (#425) * Saturate vertex color to avoid negative values. * changelog Co-authored-by: sebastienlagarde --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Material/LayeredLit/LayeredLitData.hlsl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index db0c5a98a30..73c6018a694 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -80,6 +80,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix error when removing DecalProjector from component contextual menu (case 1243960) - Fixed issue with post process when running in RGBA16 and an object with additive blending is in the scene. - Fixed issue that caused not all baked reflection to be deleted upon clicking "Clear Baked Data" in the lighting menu (case 1136080) +- Fix issue with corrupted values with Layer Lit when using multiply mode for vertex color ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl index ab216729cbc..821ee5814e8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl @@ -494,7 +494,7 @@ float4 GetBlendMask(LayerTexCoord layerTexCoord, float4 vertexColor, bool useLod // It also means that when using wind, users can't use vertex color to modulate the effect of influence from the main layer. float4 maskVertexColor = vertexColor; #if defined(_LAYER_MASK_VERTEX_COLOR_MUL) - blendMasks *= maskVertexColor; + blendMasks *= saturate(maskVertexColor); #elif defined(_LAYER_MASK_VERTEX_COLOR_ADD) blendMasks = saturate(blendMasks + maskVertexColor * 2.0 - 1.0); #endif From e69b21e61d919ac132363387b04a93b4a3daea2b Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Wed, 6 May 2020 20:27:48 +0200 Subject: [PATCH 64/81] Fix Motion Vectors written by transparent when rendering with MSAA #315 --- .../CHANGELOG.md | 1 + .../Runtime/Material/SharedRTManager.cs | 17 +++ .../Runtime/RenderPipeline/HDProfileId.cs | 1 + .../HDRenderPipeline.RenderGraph.cs | 47 ++++++ .../RenderPipeline/HDRenderPipeline.cs | 8 + .../RenderPass/MSAA/MotionVecResolve.shader | 143 ++++++++++++++++++ .../MSAA/MotionVecResolve.shader.meta | 10 ++ .../RenderPipeline/RenderPipelineResources.cs | 2 + 8 files changed, 229 insertions(+) create mode 100644 com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader create mode 100644 com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader.meta diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index db0c5a98a30..a2e9646742a 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -80,6 +80,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix error when removing DecalProjector from component contextual menu (case 1243960) - Fixed issue with post process when running in RGBA16 and an object with additive blending is in the scene. - Fixed issue that caused not all baked reflection to be deleted upon clicking "Clear Baked Data" in the lighting menu (case 1136080) +- Fixed transparent motion vectors not working when in MSAA. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs index 4c261ced47d..643a69138e3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs @@ -29,6 +29,7 @@ class SharedRTManager // MSAA resolve materials Material m_DepthResolveMaterial = null; Material m_ColorResolveMaterial = null; + Material m_MotionVectorResolve = null; // Flags that defines if we are using a local texture or external bool m_ReuseGBufferMemory = false; @@ -94,6 +95,7 @@ public void InitSharedBuffers(GBufferManager gbufferManager, RenderPipelineSetti // Create the required resolve materials m_DepthResolveMaterial = CoreUtils.CreateEngineMaterial(resources.shaders.depthValuesPS); m_ColorResolveMaterial = CoreUtils.CreateEngineMaterial(resources.shaders.colorResolvePS); + m_MotionVectorResolve = CoreUtils.CreateEngineMaterial(resources.shaders.resolveMotionVecPS); CoreUtils.SetKeyword(m_DepthResolveMaterial, "_HAS_MOTION_VECTORS", m_MotionVectorsSupport); } @@ -310,6 +312,7 @@ public void Cleanup() // Do not forget to release the materials CoreUtils.Destroy(m_DepthResolveMaterial); CoreUtils.Destroy(m_ColorResolveMaterial); + CoreUtils.Destroy(m_MotionVectorResolve); } } @@ -372,6 +375,20 @@ public void ResolveSharedRT(CommandBuffer cmd, HDCamera hdCamera) } } } + + public void ResolveMotionVectorTexture(CommandBuffer cmd, HDCamera hdCamera) + { + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA) && m_MotionVectorsSupport) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ResolveMSAAMotionVector))) + { + CoreUtils.SetRenderTarget(cmd, m_MotionVectorsRT, m_CameraDepthStencilBuffer); + Shader.SetGlobalTexture(HDShaderIDs._MotionVectorTextureMS, m_MotionVectorsMSAART); + cmd.DrawProcedural(Matrix4x4.identity, m_MotionVectorResolve, SampleCountToPassIndex(m_MSAASamples), MeshTopology.Triangles, 3, 1); + } + } + } + public void ResolveMSAAColor(CommandBuffer cmd, HDCamera hdCamera, RTHandle msaaTarget, RTHandle simpleTarget) { if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs index 815883bdd96..79edfc490e8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDProfileId.cs @@ -75,6 +75,7 @@ internal enum HDProfileId RenderWireFrame, PushToColorPicker, ResolveMSAAColor, + ResolveMSAAMotionVector, ResolveMSAADepth, ConvolveReflectionProbe, ConvolvePlanarReflectionProbe, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 9c3d7f4a003..acdb967d89a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -137,6 +137,11 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.motionVectorsBuffer, currentColorPyramid, prepassOutput.depthPyramidTexture, shadowResult, cullingResults); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) + { + prepassOutput.motionVectorsBuffer = ResolveMotionVector(m_RenderGraph, hdCamera, prepassOutput.motionVectorsBuffer); + } + // TODO RENDERGRAPH : Move this to the end after we do move semantic and graph pruning to avoid doing the rest of the frame for nothing // Transparent objects may write to the depth and motion vectors buffers. aovRequest.PushCameraTexture(m_RenderGraph, AOVBuffers.DepthStencil, hdCamera, prepassOutput.resolvedDepthBuffer, aovBuffers); @@ -988,6 +993,48 @@ RenderGraphMutableResource ResolveMSAAColor(RenderGraph renderGraph, HDCamera hd } } + class ResolveMotionVectorData + { + public TextureHandle input; + public TextureHandle output; + public Material resolveMaterial; + public int passIndex; + } + + TextureHandle ResolveMotionVector(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle input) + { + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)) + { + using (var builder = renderGraph.AddRenderPass("ResolveMotionVector", out var passData)) + { + var outputDesc = renderGraph.GetTextureDesc(input); + outputDesc.enableMSAA = false; + outputDesc.enableRandomWrite = true; + outputDesc.bindTextureMS = false; + outputDesc.name = string.Format("{0}Resolved", outputDesc.name); + + passData.input = builder.ReadTexture(input); + passData.output = builder.UseColorBuffer(renderGraph.CreateTexture(outputDesc), 0); + passData.resolveMaterial = m_MotionVectorResolve; + passData.passIndex = SampleCountToPassIndex(m_MSAASamples); + + builder.SetRenderFunc( + (ResolveColorData data, RenderGraphContext context) => + { + var res = context.resources; + var mpb = context.renderGraphPool.GetTempMaterialPropertyBlock(); + mpb.SetTexture(HDShaderIDs._MotionVectorTextureMS, res.GetTexture(data.input)); + context.cmd.DrawProcedural(Matrix4x4.identity, data.resolveMaterial, data.passIndex, MeshTopology.Triangles, 3, 1, mpb); + }); + + return passData.output; + } + } + else + { + return input; + } + } #if UNITY_EDITOR class RenderGizmosPassData { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 370a5ba6377..936d18646ea 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -312,6 +312,7 @@ internal bool showCascade // MSAA resolve materials Material m_ColorResolveMaterial = null; + Material m_MotionVectorResolve = null; // Flag that defines if ray tracing is supported by the current asset and platform bool m_RayTracingSupported = false; @@ -501,6 +502,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset, HDRenderPipelineAsset defau InitializePrepass(m_Asset); m_ColorResolveMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.shaders.colorResolvePS); + m_MotionVectorResolve = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.shaders.resolveMotionVecPS); } #if UNITY_EDITOR @@ -915,6 +917,7 @@ protected override void Dispose(bool disposing) m_RenderGraph.UnRegisterDebug(); CleanupPrepass(); CoreUtils.Destroy(m_ColorResolveMaterial); + CoreUtils.Destroy(m_MotionVectorResolve); #if UNITY_EDITOR @@ -2361,6 +2364,11 @@ void Callback(CommandBuffer c, HDCamera cam) // Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects. RenderForwardTransparent(cullingResults, hdCamera, false, renderContext, cmd); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) + { + m_SharedRTManager.ResolveMotionVectorTexture(cmd, hdCamera); + } + // We push the motion vector debug texture here as transparent object can overwrite the motion vector texture content. if(m_Asset.currentPlatformRenderPipelineSettings.supportMotionVectors) PushFullScreenDebugTexture(hdCamera, cmd, m_SharedRTManager.GetMotionVectorsBuffer(), FullScreenDebugMode.MotionVectors); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader new file mode 100644 index 00000000000..09246ce23c3 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader @@ -0,0 +1,143 @@ +Shader "Hidden/HDRP/MotionVecResolve" +{ + HLSLINCLUDE + #pragma target 4.5 + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch + + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" + // #pragma enable_d3d11_debug_symbols + + // Target multisampling textures + TEXTURE2D_X_MSAA(float2, _MotionVectorTextureMS); + + struct Attributes + { + uint vertexID : SV_VertexID; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings + { + float4 positionCS : SV_POSITION; + float2 texcoord : TEXCOORD0; + UNITY_VERTEX_OUTPUT_STEREO + }; + + struct FragOut + { + float2 motionVectors : SV_Target0; + }; + + Varyings Vert(Attributes input) + { + Varyings output; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); + output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID) * _ScreenSize.xy; + return output; + } + + FragOut Frag1X(Varyings input) + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + FragOut fragO; + int2 pixelCoords = int2(input.texcoord); + fragO.motionVectors = LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, 0); + return fragO; + } + + FragOut Frag2X(Varyings input) + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + FragOut fragO; + int2 pixelCoords = int2(input.texcoord); + float2 outMotionVec = 0; + for(int sampleIdx = 0; sampleIdx < 2; ++sampleIdx) + { + outMotionVec += LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, sampleIdx); + } + fragO.motionVectors = outMotionVec * 0.5f; + return fragO; + } + + FragOut Frag4X(Varyings input) + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + FragOut fragO; + int2 pixelCoords = int2(input.texcoord); + float2 outMotionVec = 0; + for(int sampleIdx = 0; sampleIdx < 4; ++sampleIdx) + { + outMotionVec += LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, sampleIdx); + } + fragO.motionVectors = outMotionVec * 0.25f; + + return fragO; + } + + FragOut Frag8X(Varyings input) + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + FragOut fragO; + int2 pixelCoords = int2(input.texcoord); + float2 outMotionVec = 0; + for(int sampleIdx = 0; sampleIdx < 8; ++sampleIdx) + { + outMotionVec += LOAD_TEXTURE2D_X_MSAA(_MotionVectorTextureMS, pixelCoords, sampleIdx); + } + fragO.motionVectors = outMotionVec * 0.125f; + return fragO; + } + ENDHLSL + SubShader + { + Tags{ "RenderPipeline" = "HDRenderPipeline" } + + // 0: MSAA 1x + Pass + { + ZWrite On ZTest Always Blend Off Cull Off + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag1X + ENDHLSL + } + + // 1: MSAA 2x + Pass + { + ZWrite On ZTest Always Blend Off Cull Off + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag2X + ENDHLSL + } + + // 2: MSAA 4X + Pass + { + ZWrite On ZTest Always Blend Off Cull Off + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag4X + ENDHLSL + } + + // 3: MSAA 8X + Pass + { + ZWrite On ZTest Always Blend Off Cull Off + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag8X + ENDHLSL + } + } + Fallback Off +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader.meta b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader.meta new file mode 100644 index 00000000000..b65eb06c832 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ea18ca9826385e943979c46cf98968cc +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs index dabf9748eb1..c94f35b4772 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs @@ -188,6 +188,8 @@ public sealed class ShaderResources public Shader depthValuesPS; [Reload("Runtime/RenderPipeline/RenderPass/MSAA/ColorResolve.shader")] public Shader colorResolvePS; + [Reload("Runtime/RenderPipeline/RenderPass/MSAA/MotionVecResolve.shader")] + public Shader resolveMotionVecPS; // Post-processing [Reload("Runtime/PostProcessing/Shaders/AlphaCopy.compute")] From 6abeb5c34deb8c74993e33c3477e5d0e0e1cbf12 Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Wed, 13 May 2020 15:00:04 +0200 Subject: [PATCH 65/81] Fix issue with the resolve of motion vectors (#421) --- .../Runtime/Material/SharedRTManager.cs | 2 +- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs index 643a69138e3..32b3011883a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SharedRTManager.cs @@ -382,7 +382,7 @@ public void ResolveMotionVectorTexture(CommandBuffer cmd, HDCamera hdCamera) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.ResolveMSAAMotionVector))) { - CoreUtils.SetRenderTarget(cmd, m_MotionVectorsRT, m_CameraDepthStencilBuffer); + CoreUtils.SetRenderTarget(cmd, m_MotionVectorsRT); Shader.SetGlobalTexture(HDShaderIDs._MotionVectorTextureMS, m_MotionVectorsMSAART); cmd.DrawProcedural(Matrix4x4.identity, m_MotionVectorResolve, SampleCountToPassIndex(m_MSAASamples), MeshTopology.Triangles, 3, 1); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 936d18646ea..5022dffbf6a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2367,6 +2367,7 @@ void Callback(CommandBuffer c, HDCamera cam) if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) { m_SharedRTManager.ResolveMotionVectorTexture(cmd, hdCamera); + cmd.SetGlobalTexture(HDShaderIDs._CameraMotionVectorsTexture, m_SharedRTManager.GetMotionVectorsBuffer()); } // We push the motion vector debug texture here as transparent object can overwrite the motion vector texture content. From 54e5fcea72ada6f7e9e915a05684e3c02f46f7a7 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Tue, 12 May 2020 18:16:59 +0200 Subject: [PATCH 66/81] fix issue with ShowPrePassAndPostPass --- .../Editor/Material/Eye/ShaderGraph/EyeGUI.cs | 3 +-- .../Editor/Material/Fabric/ShaderGraph/FabricGUI.cs | 3 +-- .../Editor/Material/Hair/ShaderGraph/HairGUI.cs | 3 +-- .../Editor/Material/Lit/ShaderGraph/HDLitGUI.cs | 4 +--- .../Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs | 3 +-- .../Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs | 3 +-- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs index d3070c798a7..083a42d386d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Eye/ShaderGraph/EyeGUI.cs @@ -14,8 +14,7 @@ class EyeGUI : HDShaderGUI // For surface option shader graph we only want all unlit features but alpha clip, back then front rendering and SSR const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass - ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs index f94a62156f2..adf7cf976e7 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Fabric/ShaderGraph/FabricGUI.cs @@ -15,8 +15,7 @@ class FabricGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass - ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs index e354ec5f0c0..fefeb3f5b21 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Hair/ShaderGraph/HairGUI.cs @@ -15,8 +15,7 @@ class HairGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass - ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs index e41bc36ed26..affca5d0f81 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitGUI.cs @@ -14,9 +14,7 @@ class HDLitGUI : HDShaderGUI // For surface option shader graph we only want all unlit features but alpha clip and back then front rendering const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass - ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; + ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs index aec2a60c1b8..dba83b9b46a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/StackLit/ShaderGraph/StackLitGUI.cs @@ -15,8 +15,7 @@ class StackLitGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass - ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; + ^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs index 9d91aadf2a9..a3f577a6075 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitGUI.cs @@ -16,8 +16,7 @@ class HDUnlitGUI : HDShaderGUI const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit ^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold ^ SurfaceOptionUIBlock.Features.DoubleSidedNormalMode - ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering - ^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass; + ^ SurfaceOptionUIBlock.Features.BackThenFrontRendering; MaterialUIBlockList uiBlocks = new MaterialUIBlockList { From a5b8bacf94b395bed23b9dc9741b3581e81eae30 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Fri, 15 May 2020 03:16:51 +0200 Subject: [PATCH 67/81] fix compilation issue in rendergraph --- .../HDRenderPipeline.RenderGraph.cs | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index acdb967d89a..b984820df5e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -137,10 +137,6 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, colorBuffer, prepassOutput.depthBuffer, prepassOutput.motionVectorsBuffer, currentColorPyramid, prepassOutput.depthPyramidTexture, shadowResult, cullingResults); - if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentsWriteMotionVector)) - { - prepassOutput.motionVectorsBuffer = ResolveMotionVector(m_RenderGraph, hdCamera, prepassOutput.motionVectorsBuffer); - } // TODO RENDERGRAPH : Move this to the end after we do move semantic and graph pruning to avoid doing the rest of the frame for nothing // Transparent objects may write to the depth and motion vectors buffers. @@ -993,48 +989,6 @@ RenderGraphMutableResource ResolveMSAAColor(RenderGraph renderGraph, HDCamera hd } } - class ResolveMotionVectorData - { - public TextureHandle input; - public TextureHandle output; - public Material resolveMaterial; - public int passIndex; - } - - TextureHandle ResolveMotionVector(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle input) - { - if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA)) - { - using (var builder = renderGraph.AddRenderPass("ResolveMotionVector", out var passData)) - { - var outputDesc = renderGraph.GetTextureDesc(input); - outputDesc.enableMSAA = false; - outputDesc.enableRandomWrite = true; - outputDesc.bindTextureMS = false; - outputDesc.name = string.Format("{0}Resolved", outputDesc.name); - - passData.input = builder.ReadTexture(input); - passData.output = builder.UseColorBuffer(renderGraph.CreateTexture(outputDesc), 0); - passData.resolveMaterial = m_MotionVectorResolve; - passData.passIndex = SampleCountToPassIndex(m_MSAASamples); - - builder.SetRenderFunc( - (ResolveColorData data, RenderGraphContext context) => - { - var res = context.resources; - var mpb = context.renderGraphPool.GetTempMaterialPropertyBlock(); - mpb.SetTexture(HDShaderIDs._MotionVectorTextureMS, res.GetTexture(data.input)); - context.cmd.DrawProcedural(Matrix4x4.identity, data.resolveMaterial, data.passIndex, MeshTopology.Triangles, 3, 1, mpb); - }); - - return passData.output; - } - } - else - { - return input; - } - } #if UNITY_EDITOR class RenderGizmosPassData { From 7b84523e7da08b2453c15d70ce14de579b846552 Mon Sep 17 00:00:00 2001 From: Pavlos Mavridis Date: Fri, 15 May 2020 02:57:29 +0200 Subject: [PATCH 68/81] Fixed null reference exception in LookDev when setting the SRP to None #447 --- com.unity.render-pipelines.core/CHANGELOG.md | 1 + .../Editor/LookDev/DisplayWindow.cs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 4627f7cd093..ed10b9f3540 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed copy/pasting of Volume Components when loading a new scene - Fix LookDev's camera button layout. - Fix LookDev's layout vanishing on domain reload. +- Fixed null reference exception in LookDev when setting the SRP to one not implementing LookDev (case 1245086) ## [7.3.0] - 2020-03-11 diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs index a616701a681..cbdcc972640 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs @@ -3,6 +3,8 @@ using UnityEngine; using UnityEngine.UIElements; +using RenderPipelineManager = UnityEngine.Rendering.RenderPipelineManager; + namespace UnityEditor.Rendering.LookDev { /// Interface that must implement the viewer to communicate with the compositor and data management @@ -680,6 +682,17 @@ void OnGUI() rootVisualElement.styleSheets.Add(styleSheetLight); } + // [case 1245086] Guard in case the SRP asset is set to null (or to a not supported SRP) when the lookdev window is already open + // Note: After an editor reload, we might get a null OnUpdateRequestedInternal and null SRP for a couple of frames, hence the check. + if (!LookDev.supported && OnUpdateRequestedInternal !=null) + { + // Print an error and close the Lookdev window (to avoid spamming the console) + Debug.LogError($"LookDev is not supported by this Scriptable Render Pipeline: " + + (RenderPipelineManager.currentPipeline == null ? "No SRP in use" : RenderPipelineManager.currentPipeline.ToString())); + LookDev.Close(); + return; + } + OnUpdateRequestedInternal?.Invoke(); } } From fe2ad48c1217519672e94421a17432862157fe61 Mon Sep 17 00:00:00 2001 From: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com> Date: Fri, 15 May 2020 12:20:35 +0200 Subject: [PATCH 69/81] Check reflection probe null pointer before use. (case 1244047) #456 --- .../CHANGELOG.md | 1 + .../Reflection/HDAdditionalReflectionData.Legacy.cs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index c7edf082425..82bd3d44da9 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -85,6 +85,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed transparent motion vectors not working when in MSAA. - VFX: Removed irrelevant queues in render queue selection from HDRP outputs - VFX: Motion Vector are correctly renderered with MSAA [Case 1240754](https://issuetracker.unity3d.com/product/unity/issues/guid/1240754/) +- Fixed error when undo a Reflection Probe removal in a prefab instance. (case 1244047) ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDAdditionalReflectionData.Legacy.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDAdditionalReflectionData.Legacy.cs index 1b979ba2b23..1f446401766 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDAdditionalReflectionData.Legacy.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Reflection/HDAdditionalReflectionData.Legacy.cs @@ -30,6 +30,16 @@ public override void PrepareCulling() var tr = transform; var position = tr.position; var cubeProbe = reflectionProbe; + + if (cubeProbe == null || cubeProbe.Equals(null)) + { + // case 1244047 + // This can happen when removing the component from the editor and then undo the remove. + // The order of call maybe incorrect and the code flows here before the reflection probe + // is restored. + return; + } + switch (influence.shape) { case InfluenceShape.Box: From acf8f95b2fdd9147f36c1910e7730cb5e2144ab1 Mon Sep 17 00:00:00 2001 From: Antoine Lelievre Date: Fri, 15 May 2020 13:30:07 +0200 Subject: [PATCH 70/81] Remove max atlas probe alloc size in HDRP asset (#458) * Fixed max alloc planar size not taking in account the max cache size * Removed the max cache clamp on texture atlases --- .../RenderPipeline/HDRenderPipelineUI.cs | 26 +++---------------- .../Runtime/Lighting/LightCookieManager.cs | 3 --- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index bd41dd2e4e1..8ecc4016043 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -221,17 +221,8 @@ static void Drawer_SectionCookies(SerializedHDRenderPipelineAsset serialized, Ed { GraphicsFormat cookieFormat = (GraphicsFormat)serialized.renderPipelineSettings.lightLoopSettings.cookieFormat.intValue; long currentCache = PowerOfTwoTextureAtlas.GetApproxCacheSizeInByte(1, serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasSize.intValue, true, cookieFormat); - if (currentCache > HDRenderPipeline.k_MaxCacheSize) - { - int reserved = PowerOfTwoTextureAtlas.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, true, cookieFormat); - string message = string.Format(Styles.cacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved); - EditorGUILayout.HelpBox(message, MessageType.Error); - } - else - { - string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); - EditorGUILayout.HelpBox(message, MessageType.Info); - } + string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); + EditorGUILayout.HelpBox(message, MessageType.Info); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.cookieAtlasLastValidMip, Styles.cookieAtlasLastValidMipContent); @@ -301,17 +292,8 @@ static void Drawer_SectionReflection(SerializedHDRenderPipelineAsset serialized, else { long currentCache = PlanarReflectionProbeCache.GetApproxCacheSizeInByte(1, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.intValue, GraphicsFormat.R16G16B16A16_UNorm); - if (currentCache > HDRenderPipeline.k_MaxCacheSize) - { - int reserved = PlanarReflectionProbeCache.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, GraphicsFormat.R16G16B16A16_UNorm); - string message = string.Format(Styles.cacheErrorFormat, HDEditorUtils.HumanizeWeight(currentCache), reserved); - EditorGUILayout.HelpBox(message, MessageType.Error); - } - else - { - string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); - EditorGUILayout.HelpBox(message, MessageType.Info); - } + string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache)); + EditorGUILayout.HelpBox(message, MessageType.Info); } EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.maxPlanarReflectionOnScreen, Styles.maxPlanarReflectionOnScreen); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs index 8de7e0f0406..d551020e17c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightCookieManager.cs @@ -63,9 +63,6 @@ public LightCookieManager(HDRenderPipelineAsset hdAsset, int maxCacheSize) cookieFormat = (GraphicsFormat)gLightLoopSettings.cookieFormat; cookieAtlasLastValidMip = gLightLoopSettings.cookieAtlasLastValidMip; - if (PowerOfTwoTextureAtlas.GetApproxCacheSizeInByte(1, cookieAtlasSize, true, cookieFormat) > HDRenderPipeline.k_MaxCacheSize) - cookieAtlasSize = PowerOfTwoTextureAtlas.GetMaxCacheSizeForWeightInByte(HDRenderPipeline.k_MaxCacheSize, true, cookieFormat); - m_CookieAtlas = new PowerOfTwoTextureAtlas(cookieAtlasSize, gLightLoopSettings.cookieAtlasLastValidMip, cookieFormat, name: "Cookie Atlas (Punctual Lights)", useMipMap: true); m_CubeToPanoMaterial = CoreUtils.CreateEngineMaterial(hdResources.shaders.cubeToPanoPS); From 69b807c891a6bc2c2acd6680cf970d095d2d7c2b Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Fri, 15 May 2020 10:38:21 +0200 Subject: [PATCH 71/81] Fix few multi-editing issues with Emission UI #473 --- .../CHANGELOG.md | 1 + .../Material/UIBlocks/EmissionUIBlock.cs | 95 +++++++++++++++++-- 2 files changed, 86 insertions(+), 10 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 82bd3d44da9..11c444f1617 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -86,6 +86,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - VFX: Removed irrelevant queues in render queue selection from HDRP outputs - VFX: Motion Vector are correctly renderered with MSAA [Case 1240754](https://issuetracker.unity3d.com/product/unity/issues/guid/1240754/) - Fixed error when undo a Reflection Probe removal in a prefab instance. (case 1244047) +- Fixed various multi-editing issues when changing Emission parameters. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs index 292ac8ea228..9630d51ad25 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/EmissionUIBlock.cs @@ -89,6 +89,31 @@ public override void OnGUI() } } + void UpdateEmissiveColorAndIntensity() + { + materialEditor.serializedObject.ApplyModifiedProperties(); + foreach (Material target in materials) + { + if (target.HasProperty(kEmissiveColorLDR) && target.HasProperty(kEmissiveIntensity) && target.HasProperty(kEmissiveColor)) + { + target.SetColor(kEmissiveColor, target.GetColor(kEmissiveColorLDR) * target.GetFloat(kEmissiveIntensity)); + } + } + materialEditor.serializedObject.Update(); + } + + void UpdateEmissionUnit(float newUnitFloat) + { + foreach (Material target in materials) + { + if (target.HasProperty(kEmissiveIntensityUnit) && target.HasProperty(kEmissiveIntensity)) + { + target.SetFloat(kEmissiveIntensityUnit, newUnitFloat); + } + } + materialEditor.serializedObject.Update(); + } + void DrawEmissionGUI() { EditorGUI.BeginChangeCheck(); @@ -106,35 +131,85 @@ void DrawEmissionGUI() else { EditorGUI.BeginChangeCheck(); + DoEmissiveTextureProperty(emissiveColorLDR); + // Normalize all emissive colors for each target separately + foreach (Material material in materials) { - DoEmissiveTextureProperty(emissiveColorLDR); - emissiveColorLDR.colorValue = NormalizeEmissionColor(ref updateEmissiveColor, emissiveColorLDR.colorValue); + if (material.HasProperty(kEmissiveColorLDR)) + material.SetColor(kEmissiveColorLDR, NormalizeEmissionColor(ref updateEmissiveColor, material.GetColor(kEmissiveColorLDR))); + } + if (EditorGUI.EndChangeCheck() || updateEmissiveColor) + UpdateEmissiveColorAndIntensity(); + float newUnitFloat; + float newIntensity = emissiveIntensity.floatValue; + bool unitIsMixed = emissiveIntensityUnit.hasMixedValue; + bool intensityIsMixed = unitIsMixed || emissiveIntensity.hasMixedValue; + bool intensityChanged = false; + bool unitChanged = false; + EditorGUI.BeginChangeCheck(); + { using (new EditorGUILayout.HorizontalScope()) { EmissiveIntensityUnit unit = (EmissiveIntensityUnit)emissiveIntensityUnit.floatValue; + EditorGUI.showMixedValue = intensityIsMixed; if (unit == EmissiveIntensityUnit.Nits) { using (var change = new EditorGUI.ChangeCheckScope()) { materialEditor.ShaderProperty(emissiveIntensity, Styles.emissiveIntensityText); - if (change.changed) - emissiveIntensity.floatValue = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); + intensityChanged = change.changed; + if (intensityChanged) + newIntensity = Mathf.Clamp(emissiveIntensity.floatValue, 0, float.MaxValue); } } else { - float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); - evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue); - evValue = Mathf.Clamp(evValue, 0, float.MaxValue); - emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); + float value = emissiveIntensity.floatValue; + if (!intensityIsMixed) + { + float evValue = LightUtils.ConvertLuminanceToEv(emissiveIntensity.floatValue); + evValue = EditorGUILayout.FloatField(Styles.emissiveIntensityText, evValue); + newIntensity = Mathf.Clamp(evValue, 0, float.MaxValue); + emissiveIntensity.floatValue = LightUtils.ConvertEvToLuminance(evValue); + } + else + { + using (var change = new EditorGUI.ChangeCheckScope()) + { + newIntensity = EditorGUILayout.FloatField(Styles.emissiveIntensityText, value); + intensityChanged = change.changed; + } + } + } + EditorGUI.showMixedValue = false; + + EditorGUI.showMixedValue = emissiveIntensityUnit.hasMixedValue; + using (var change = new EditorGUI.ChangeCheckScope()) + { + newUnitFloat = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit); + unitChanged = change.changed; } - emissiveIntensityUnit.floatValue = (float)(EmissiveIntensityUnit)EditorGUILayout.EnumPopup(unit); + EditorGUI.showMixedValue = false; } } if (EditorGUI.EndChangeCheck() || updateEmissiveColor) - emissiveColor.colorValue = emissiveColorLDR.colorValue * emissiveIntensity.floatValue; + { + if(unitChanged) + { + if (unitIsMixed) + UpdateEmissionUnit(newUnitFloat); + else + emissiveIntensityUnit.floatValue = newUnitFloat; + } + + // We don't allow changes on intensity if units are mixed + if (intensityChanged && !unitIsMixed) + emissiveIntensity.floatValue = newIntensity; + + UpdateEmissiveColorAndIntensity(); + } } materialEditor.ShaderProperty(emissiveExposureWeight, Styles.emissiveExposureWeightText); From ffb242527365c91c1f04dcfd3ff9f7b5db5482cb Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Fri, 15 May 2020 11:59:27 +0200 Subject: [PATCH 72/81] Re-enable cubemap thumbnail gen only for d3d11 #487 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Editor/Lighting/Reflection/HDCubemapInspector.cs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 11c444f1617..d3d9852ec66 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -87,6 +87,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - VFX: Motion Vector are correctly renderered with MSAA [Case 1240754](https://issuetracker.unity3d.com/product/unity/issues/guid/1240754/) - Fixed error when undo a Reflection Probe removal in a prefab instance. (case 1244047) - Fixed various multi-editing issues when changing Emission parameters. +- Fixed issue that prevented cubemap thumbnails from rendering (only on D3D11 and Metal). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDCubemapInspector.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDCubemapInspector.cs index edb610fd6e2..48008d8f558 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDCubemapInspector.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDCubemapInspector.cs @@ -233,7 +233,12 @@ public override Texture2D RenderStaticPreview(string assetPath, Object[] subAsse m_PreviewUtility.ambientColor = Color.black; m_PreviewUtility.BeginStaticPreview(new Rect(0, 0, width, height)); m_PreviewUtility.DrawMesh(sphereMesh, Matrix4x4.identity, previewMaterial, 0); - m_PreviewUtility.camera.Render(); + // TODO: For now the following line is D3D11 + Metal only as it cause out of memory on both DX12 and Vulkan API. + // We will need to invest time to understand what is happening + // For now priority is to enable Yamato platform automation + // This mean that cubemap icon will render incorrectly on anything but D3D11 + if(SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal) + m_PreviewUtility.camera.Render(); var outTexture = m_PreviewUtility.EndStaticPreview(); From daa66ead0cd27c08aff48770b48bb1f75a38538b Mon Sep 17 00:00:00 2001 From: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Date: Fri, 15 May 2020 14:24:56 +0200 Subject: [PATCH 73/81] Hd/fix undo environmentlibrary lookdev #490 --- com.unity.render-pipelines.core/CHANGELOG.md | 1 + .../Editor/LookDev/Context.cs | 12 ++++++++++++ .../DisplayWindow.EnvironmentLibrarySidePanel.cs | 8 ++++++++ .../Editor/LookDev/DisplayWindow.cs | 8 +++++++- .../Editor/LookDev/EnvironmentLibrary.cs | 11 +++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index ed10b9f3540..4bb7f49531b 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fix LookDev's camera button layout. - Fix LookDev's layout vanishing on domain reload. - Fixed null reference exception in LookDev when setting the SRP to one not implementing LookDev (case 1245086) +- Fix LookDev's undo/redo on EnvironmentLibrary (case 1234725) ## [7.3.0] - 2020-03-11 diff --git a/com.unity.render-pipelines.core/Editor/LookDev/Context.cs b/com.unity.render-pipelines.core/Editor/LookDev/Context.cs index 04f0300517e..7db4c4e799f 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/Context.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/Context.cs @@ -264,6 +264,18 @@ internal bool HasLibraryAssetChanged(EnvironmentLibrary environmentLibrary) return m_EnvironmentLibraryGUID != AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(environmentLibrary)); } + + internal void FullReimportEnvironmentLibrary() + { + if (environmentLibrary == null) + return; + + // refresh AssetDatabase in case of undo/redo creating/destructing environment subasset + string libraryPath = AssetDatabase.GetAssetPath(environmentLibrary); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(environmentLibrary), ImportAssetOptions.DontDownloadFromCacheServer | ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate | ImportAssetOptions.ImportRecursive); + UpdateEnvironmentLibrary(AssetDatabase.LoadAssetAtPath(libraryPath)); + EditorUtility.SetDirty(environmentLibrary); + } } /// diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs index 30d1e966387..5db3aba5723 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs @@ -463,5 +463,13 @@ void OnFocus() ((IEnvironmentDisplayer)this).Repaint(); } } + + void FullRefreshEnvironmentList() + { + if (LookDev.currentContext.environmentLibrary != null) + LookDev.currentContext.FullReimportEnvironmentLibrary(); + + ((IEnvironmentDisplayer)this).Repaint(); + } } } diff --git a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs index cbdcc972640..12b7368fccc 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs @@ -259,9 +259,15 @@ void OnEnable() ApplyLayout(viewLayout); ApplySidePanelChange(layout.showedSidePanel); + + Undo.undoRedoPerformed += FullRefreshEnvironmentList; } - void OnDisable() => OnClosedInternal?.Invoke(); + void OnDisable() + { + Undo.undoRedoPerformed -= FullRefreshEnvironmentList; + OnClosedInternal?.Invoke(); + } void CreateToolbar() { diff --git a/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs b/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs index 5540c59322a..c9e7e82e823 100644 --- a/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs +++ b/com.unity.render-pipelines.core/Editor/LookDev/EnvironmentLibrary.cs @@ -32,15 +32,21 @@ public class EnvironmentLibrary : ScriptableObject /// The created Environment public Environment Add() { + Undo.SetCurrentGroupName("Add Environment"); + int group = Undo.GetCurrentGroup(); + Environment environment = ScriptableObject.CreateInstance(); environment.name = "New Environment"; Undo.RegisterCreatedObjectUndo(environment, "Add Environment"); + Undo.RecordObject(this, "Add Environment"); environments.Add(environment); // Store this new environment as a subasset so we can reference it safely afterwards. AssetDatabase.AddObjectToAsset(environment, this); + Undo.CollapseUndoOperations(group); + // Force save / refresh. Important to do this last because SaveAssets can cause effect to become null! EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); @@ -54,11 +60,16 @@ public Environment Add() /// Index where to remove Environment public void Remove(int index) { + Undo.SetCurrentGroupName("Remove Environment"); + int group = Undo.GetCurrentGroup(); + Environment environment = environments[index]; Undo.RecordObject(this, "Remove Environment"); environments.RemoveAt(index); Undo.DestroyObjectImmediate(environment); + Undo.CollapseUndoOperations(group); + // Force save / refresh EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); From d31417ecf5132d24d25a3396df8db221803e8b4d Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Fri, 15 May 2020 15:16:55 +0100 Subject: [PATCH 74/81] Added system requirements and frame settings api docs (#510) * Added system requirements and frame settings api doc * Update System-Requirements.md Co-authored-by: sebastienlagarde --- .../Documentation~/Frame-Settings-API.md | 112 ++++++++++++++++++ .../Images/FrameSettingsAPI-watch.png | 3 + .../Documentation~/System-Requirements.md | 37 ++++++ .../Documentation~/TableOfContents.md | 2 + .../Documentation~/index.md | 11 +- 5 files changed, 155 insertions(+), 10 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings-API.md create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Images/FrameSettingsAPI-watch.png create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings-API.md b/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings-API.md new file mode 100644 index 00000000000..6a95b715d56 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Frame-Settings-API.md @@ -0,0 +1,112 @@ +# Frame Settings Scripting API + +In the High Definition Render Pipelines (HDRP), [Frame Settings](Frame-Settings.md) control how a rendering component, such as a [Camera](HDRP-Camera.md), [Reflection Probe](Reflection-Probe.md), or [Planar Reflection Probe](Planar-Reflection-Probe.md), renders a Scene. You can specify default Frame Settings for your entire Project and then override them for a particular rendering component. This means that each Frame Setting has a default value, set in the [HDRP Asset](HDRP-Asset.md), then each individual rendering component in your Scene can have an override for it. This is useful if you have lower priority rendering components that do not need to use certain effects. To specify which default Frame Settings a rendering component overrides, each rendering component contains an [override mask](../api/UnityEngine.Rendering.HighDefinition.FrameSettingsOverrideMask.html). A mask is an array of bits, where each bit represents one of two states (0 for disabled and 1 for enabled). Each bit in the override mask represents the override state of a particular Frame Setting. + +To get the final value of a Frame Setting for a particular rendering component, HDRP performs the following steps: + +1. Checks the Project-wide default value for the Frame Setting. In this step, HDRP checks the current value stored for the Frame Setting in the HDRP Asset. +2. Checks the rendering component's override mask to see if the bit that corresponds to the Frame Setting is set. The state of the Frame Setting's bit in the override mask corresponds to the state of the override checkbox to the left of the Frame Setting in the rendering component's Inspector. +3. Gets the Frame Setting's override value from the rendering component's custom Frame Settings. +4. Sanitizes the result. To lighten your Project, you can specify which features to use in the HDRP Asset. If the Frame Setting you try to modify affects an unavailable feature, Unity discards it in this final sanitization pass. To make sure it is not possible for HDRP to process features that are not available, you cannot access the sanitization process via scripting API. + +## Modifying default Frame Settings + +The Default Frame Settings are in the HDRP Asset, so it is not good practice to modify them at runtime. Instead, you can modify them in Edit mode in [Default Settings tab](Default-Settings-Window.md). + +Note that you can set individual default Frame Settings for three types of rendering component: + +- Cameras +- Realtime Reflection Probes and Realtime Planar Reflection Probes +- Baked/custom Reflection Probes and Baked/custom Planar Reflection Probe + +There is currently no scripting API to modify default Frame Settings. + +## Modifying Frame Settings for a particular rendering component + +HDRP stores the Frame Settings for rendering components in additional data components attached to the rendering component. The additional data components are: + +| **Rendering component** | **Additional data component** | +| ----------------------- | ----------------------------- | +| **Camera** | HDAdditionalCameraData | +| **Reflection Probe** | HDAdditionalReflectionData | + +To modify the value of a Frame Setting, the first step is to get a reference to the additional data component. To do this, either create a public variable and assign it in the Inspector, or use [GetComponent()](https://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html) where T is the additional data component type. + +Next, access the Frame Settings override mask. This controls which Frame Settings to use overridden values for and is of type `FrameSettingsOverrideMask`. Accessing the Frame Settings override mask is different depending on whether you want to modify the Frame Settings of a Camera or a Reflection Probe: + +- **Camera**: `HDAdditionalCameraData.renderingPathCustomFrameSettingsOverrideMask` +- **Reflection Probe**: `HDAdditionalReflectionData.frameSettingsOverrideMask` + +For information on the API available for `FrameSettingsOverrideMask`, including how to set/unset a bit in the mask, see [FrameSettingsOverrideMask Scripting API](#framesettingsoverridemask-scripting-api). + +Finally, access the Frame Settings structure itself. This controls the actual value for each Frame Setting and is of type `FrameSettings`. Accessing the Frame Settings is also different depending on whether you want to modify the Frame Settings of a Camera or a Reflection Probe: + +- **Camera**: `HDAdditionalCameraData.renderingPathCustomFrameSettings` +- **Reflection Probe**: `HDAdditionalReflectionData.frameSettings` + +For information on the API available for `FrameSettings`, including how to edit the value of a Frame Setting, see [FrameSettings Scripting API](framesettings-scripting-api). + +## Frame Setting enumerations + +To make it easier to set the value of some Frame Settings, HDRP provides the following enum types. + +### LitShaderMode + +An enum which helps to switch a rendering component between deferred and forward rendering. + +For information on what each enum value does, see [LitShaderMode](../api/UnityEngine.Rendering.HighDefinition.LitShaderMode.html). + +### LODBiasMode + +An enum which defines how HDRP calculates a LOD bias. + +For information on what each enum value does, see [LODBiasMode](../api/UnityEngine.Rendering.HighDefinition.LODBiasMode.html). + +### MaximumLODLevelMode + +An enum which defines how HDRP calculates the maximum LOD level. + +For information on what each enum value does, see [MaximumLODLevelMode](../api/UnityEngine.Rendering.HighDefinition.MaximumLODLevelMode.html). + +### FrameSettingsField + +An enum where each entry represents a particular Frame Setting. For a list of entries in this enum, see [FrameSettingsField](../api/UnityEngine.Rendering.HighDefinition.FrameSettingsField.html). + +As well as an entry for each Frame Settings, this enum also includes the value `FrameSettingsField.None` that is set to **-1** for convenience and internal usage. + +## FrameSettingsOverrideMask Scripting API + +This is a structure that has a single field which stores the override mask. For more information about this structure and the API it contains, see [FrameSettingsOverrideMask](../api/UnityEngine.Rendering.HighDefinition.FrameSettingsOverrideMask.html). + +In the override mask, to allow you to easily access the bit for a given Frame Setting, HDRP provides the [FrameSettingsField](#framesettingsfield) enum. You can use this, for example, to find the bit responsible for overriding the **Opaque Objects** Frame Setting. To do this, you would do `this[(int)FrameSettingsField.OpaqueObjects]`. + +The following example shows how to compare the `humanizedData` from a rendering component's override mask with the rendering component's custom Frame Settings. There are some custom Frame Settings set, but the mask is all zeros which means that this rendering component uses the default Frame Settings. + +![](Images/FrameSettingsAPI-watch.png) + +## FrameSettings Scripting API + +This is a structure that contains information on how a rendering component should render the Scene. For more information about this structure and the API it contains, see [FrameSettings](../api/UnityEngine.Rendering.HighDefinition.FrameSettings.html). + +### Example + +The following example demonstrates a component that changes a Camera's Frame Settings so the Camera does not render opaque GameObjects. It has the public field `cameraToChange`, which represents the Camera to change the Frame Settings for, and the public function `RemoveOpaqueObjectsFromRendering`, which contains the logic to change the Camera's Frame Settings. + +``` +using UnityEngine; +using UnityEngine.Rendering.HighDefinition; + +public class ChangeFrameSettings : MonoBehaviour +{ + public Camera cameraToChange; + + public void RemoveOpaqueObjectsFromRendering() + { + HDAdditionalCameraData hdCameraData = cameraToChange.GetComponent(); + + hdCameraData.renderingPathCustomFrameSettingsOverrideMask.mask[(int)FrameSettingsField.OpaqueObjects] = true; + + hdCameraData.renderingPathCustomFrameSettings.SetEnabled(FrameSettingsField.OpaqueObjects, false); + } +} +``` \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/FrameSettingsAPI-watch.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/FrameSettingsAPI-watch.png new file mode 100644 index 00000000000..7b6000f35dd --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/FrameSettingsAPI-watch.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e025291d565a2ce695ac45c8dc00c59c74ba0750da440e86245d4878c9b40a8b +size 9502 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md b/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md new file mode 100644 index 00000000000..d8f06030ca6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/System-Requirements.md @@ -0,0 +1,37 @@ +# Requirements and compatibility + +This page contains information on system requirements and compatibility of the High Definition Render Pipeline (HDRP) package. + +## Unity Editor compatibility + +The following table shows the compatibility of the High Definition Render Pipeline (HDRP) versions with different Unity Editor versions. + +| **Package version** | **Minimum Unity version** | **Maximum Unity version** | +| ------------------- | ------------------------- | ------------------------- | +| 10.x | 2020.2 | 2020.2 | +| 8.x / 9.x-preview | 2020.1 | 2020.1 | +| 7.x | 2019.3 | 2019.4 | +| 6.x | 2019.2 | 2019.2 | + +## Render pipeline compatibility + +Projects made using HDRP are not compatible with the Universal Render Pipeline (URP) or the Built-in Render Pipeline. Before you start development, you must decide which render pipeline to use in your Project. For information on choosing a render pipeline, see the [Render Pipelines](https://docs.unity3d.com/2019.3/Documentation/Manual/render-pipelines.html) section of the Unity Manual. + +## Unity Player system requirements + +This section describes the HDRP package’s target platform requirements. For platforms or use cases not covered in this section, general system requirements for the Unity Player apply. + +For more information, see [System requirements for Unity](https://docs.unity3d.com/Manual/system-requirements.html). + +HRDP is only compatible with the following platforms: + +- Windows and Windows Store, with DirectX 11 or DirectX 12 and Shader Model 5.0 +- Modern consoles (Sony PS4 and Microsoft Xbox One) +- MacOS (minimum version 10.13) using Metal graphics +- Linux and Windows platforms with Vulkan + +**Note: HDRP only works on these platforms if the device used supports Compute Shaders. HDRP does not support OpenGL or OpenGL ES devices.** + +### Ray tracing + +To use ray tracing in HDRP, there are hardware requirements you must meet. For information on these requirements, see [Getting started with ray tracing](Ray-Tracing-Getting-Started.md#HardwareRequirements). diff --git a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md index 967712e4a3b..35655a3321b 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md @@ -3,6 +3,7 @@ * [Features List](HDRP-Features) * [Comparison with the Built-in Render Pipeline](Feature-Comparison) * Getting started + * [System Requirements](System-Requirements.md) * [Getting Started with HDRP](Getting-started-with-HDRP) * [Upgrading to HDRP](Upgrading-To-HDRP) * [Render Pipeline Wizard](Render-Pipeline-Wizard) @@ -152,5 +153,6 @@ * [Creating a Custom Sky](Creating-a-Custom-Sky) * [Creating a Custom Post-Process Effect](Custom-Post-Process) * [Creating a Custom Render Pass](Custom-Pass) + * [Editing Frame Settings at Runtime](Frame-Settings-API.md) * [HDRP Glossary](Glossary) * [Known Issues and How To Fix Them](Known-Issues) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/index.md b/com.unity.render-pipelines.high-definition/Documentation~/index.md index b041030e01d..b066920f5ad 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/index.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/index.md @@ -10,13 +10,4 @@ NOTE: Projects that you make with HDRP are not compatible with the Universal Ren This documentation contains the information you need to create applications using HDRP; including information on Lighting, Materials and Shaders, Cameras, and debugging. -HRDP is only supported on the following platforms: - -* Windows and Windows Store, with DirectX 11 or DirectX 12 and Shader Model 5.0 -* Modern consoles (Sony PS4 and Microsoft Xbox One) -* MacOS using Metal graphics -* Linux and Windows platforms with Vulkan - -**HDRP does not support OpenGL or OpenGL ES devices.** - -**Note: HDRP only works on these platforms if the device used supports Compute Shaders.** \ No newline at end of file +For information on platform support and system requirements, see [System Requirements](System-Requirements.md). From b5c6f7f983b43eae85fab432a2dc6037ce2a3978 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 18 May 2020 17:09:45 +0200 Subject: [PATCH 75/81] hide exposure compensation for fixed exposure (#535) * hide exposure compensation for fixed exposure * Update PostProcessSystem.cs --- .../Editor/PostProcessing/ExposureEditor.cs | 1 - .../Runtime/PostProcessing/PostProcessSystem.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs index 783223d4d49..9e6ba5a09fe 100644 --- a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs @@ -51,7 +51,6 @@ public override void OnInspectorGUI() else if (mode == (int)ExposureMode.Fixed) { PropertyField(m_FixedExposure); - PropertyField(m_Compensation); } else { diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index 4f5aeca5a90..fd8ec95a9e6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -809,7 +809,8 @@ void DoFixedExposure(CommandBuffer cmd, HDCamera camera) if (m_Exposure.mode.value == ExposureMode.Fixed) { kernel = cs.FindKernel("KFixedExposure"); - cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams, new Vector4(m_Exposure.compensation.value + m_DebugExposureCompensation, m_Exposure.fixedExposure.value, 0f, 0f)); + // Don't apply exposure compensation on fixed exposure in 7.4.0 to not break existing users project + cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams, new Vector4(0f /* m_Exposure.compensation.value + m_DebugExposureCompensation */, m_Exposure.fixedExposure.value, 0f, 0f)); } else if (m_Exposure.mode == ExposureMode.UsePhysicalCamera) { From 60ff03d20bd28f266083a444456dbb40ed25d28e Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 18 May 2020 17:08:42 +0200 Subject: [PATCH 76/81] [9.x.x] Fix Microshadow not working properly with LightLayers enabled in deferred #522 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/Material/Lit/Lit.hlsl | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 0c577390afb..628b98729a9 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -88,6 +88,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed error when undo a Reflection Probe removal in a prefab instance. (case 1244047) - Fixed various multi-editing issues when changing Emission parameters. - Fixed issue that prevented cubemap thumbnails from rendering (only on D3D11 and Metal). +- Fixed Microshadow not working correctly in deferred with LightLayers ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index 64ad119c8fd..e92762b9224 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -195,11 +195,8 @@ float GetAmbientOcclusionForMicroShadowing(BSDFData bsdfData) { float sourceAO; #if (SHADERPASS == SHADERPASS_DEFERRED_LIGHTING) - // Note: In deferred pass we don't have space in GBuffer to store ambientOcclusion unless LIGHT_LAYERS is enabled - // so we use specularOcclusion instead - // The define LIGHT_LAYERS only exist for the GBuffer and the Forward pass. To avoid to add another - // variant to deferred.compute, we use dynamic branching instead with _EnableLightLayers. - sourceAO = _EnableLightLayers ? bsdfData.ambientOcclusion : bsdfData.specularOcclusion; + // Note: In deferred pass we don't have space in GBuffer to store ambientOcclusion so we use specularOcclusion instead + sourceAO = bsdfData.specularOcclusion; #else sourceAO = bsdfData.ambientOcclusion; #endif From 8d58f81aa086af0ceac26b1bdca8aa274040f96f Mon Sep 17 00:00:00 2001 From: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Date: Mon, 18 May 2020 09:46:37 +0200 Subject: [PATCH 77/81] Use path relative to package for depth of field #523 --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + .../Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute | 2 +- .../Runtime/PostProcessing/Shaders/DepthOfFieldTileMax.compute | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 628b98729a9..ceb143fa6f1 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -89,6 +89,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed various multi-editing issues when changing Emission parameters. - Fixed issue that prevented cubemap thumbnails from rendering (only on D3D11 and Metal). - Fixed Microshadow not working correctly in deferred with LightLayers +- Tentative fix for missing include in depth of field shaders. ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute index 6ddc24e0c0d..732ee482b01 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldGather.compute @@ -1,6 +1,6 @@ #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" -#include "DepthOfFieldCommon.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldCommon.hlsl" #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldTileMax.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldTileMax.compute index 9174ec0f47c..8d8d36e9c3a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldTileMax.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldTileMax.compute @@ -1,6 +1,6 @@ #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" -#include "DepthOfFieldCommon.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/DepthOfFieldCommon.hlsl" #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch From 402a718604f0137543c186830be93272246ecfac Mon Sep 17 00:00:00 2001 From: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com> Date: Mon, 18 May 2020 11:11:24 -0400 Subject: [PATCH 78/81] Fix taaFrameIndex and restore TAA tests for XR #534 --- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 10 ++++++---- .../TestRunner/HDRP_GraphicTestRunner.cs | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 799fb4659b9..bbe8a97a2ea 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -472,6 +472,10 @@ internal void Update(FrameSettings currentFrameSettings, HDRenderPipeline hdrp, screenSize = new Vector4(screenWidth, screenHeight, 1.0f / screenWidth, 1.0f / screenHeight); screenParams = new Vector4(screenSize.x, screenSize.y, 1 + screenSize.z, 1 + screenSize.w); + const int kMaxSampleCount = 8; + if (++taaFrameIndex >= kMaxSampleCount) + taaFrameIndex = 0; + UpdateAllViewConstants(); isFirstFrame = false; cameraFrameCount++; @@ -889,6 +893,8 @@ void UpdateAllViewConstants() if (m_XRViewConstants == null || m_XRViewConstants.Length != viewCount) { m_XRViewConstants = new ViewConstants[viewCount]; + resetPostProcessingHistory = true; + isFirstFrame = true; } UpdateAllViewConstants(IsTAAEnabled(), true); @@ -1138,10 +1144,6 @@ Matrix4x4 GetJitteredProjectionMatrix(Matrix4x4 origProj) float jitterY = HaltonSequence.Get((taaFrameIndex & 1023) + 1, 3) - 0.5f; taaJitter = new Vector4(jitterX, jitterY, jitterX / actualWidth, jitterY / actualHeight); - const int kMaxSampleCount = 8; - if (++taaFrameIndex >= kMaxSampleCount) - taaFrameIndex = 0; - Matrix4x4 proj; if (camera.orthographic) diff --git a/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs b/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs index 0b0113342ac..e6e73a3fe40 100644 --- a/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs +++ b/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs @@ -58,6 +58,9 @@ public IEnumerator Run(GraphicsTestCase testCase) yield return null; } + // Reset temporal effects on hdCamera + HDCamera.GetOrCreate(camera).Reset(); + for (int i=0 ; i Date: Mon, 18 May 2020 20:13:32 +0200 Subject: [PATCH 79/81] Fix an issue in reading the gbuffer for ray traced subsurface scattering (#538) --- .../CHANGELOG.md | 1 + .../SubsurfaceScatteringManager.cs | 4 ---- .../Raytracing/Shaders/RayTracingSubSurface.raytrace | 12 ++++-------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index ceb143fa6f1..295be2e6fcd 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -90,6 +90,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed issue that prevented cubemap thumbnails from rendering (only on D3D11 and Metal). - Fixed Microshadow not working correctly in deferred with LightLayers - Tentative fix for missing include in depth of field shaders. +- Fix an issue in reading the gbuffer for ray traced subsurface scattering (case 1248358). ### Changed - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs index 08419191dcb..114ccae3f06 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs @@ -350,10 +350,6 @@ void RenderSubsurfaceScattering(HDCamera hdCamera, CommandBuffer cmd, RTHandle c // Bind the textures for ray generation cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._DepthTexture, sharedRTManager.GetDepthStencilBuffer()); cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._NormalBufferTexture, sharedRTManager.GetNormalBuffer()); - cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[0], m_GbufferManager.GetBuffer(0)); - cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[1], m_GbufferManager.GetBuffer(1)); - cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[2], m_GbufferManager.GetBuffer(2)); - cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._GBufferTexture[3], m_GbufferManager.GetBuffer(3)); cmd.SetRayTracingTextureParam(subSurfaceShader, HDShaderIDs._SSSBufferTexture, m_SSSColor); cmd.SetGlobalTexture(HDShaderIDs._StencilTexture, sharedRTManager.GetDepthStencilBuffer(), RenderTextureSubElement.Stencil); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace index faffd8f5997..85762c9926e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingSubSurface.raytrace @@ -66,13 +66,9 @@ void RayGenSubSurface() PositionInputs posInput = GetPositionInput(currentPixelCoord, 1.0/LaunchDim.xy, depthValue, UNITY_MATRIX_I_VP, GetWorldToViewMatrix(), 0); posInput.positionWS = GetAbsolutePositionWS(posInput.positionWS); - // Read the bsdf data and builtin data from the gbuffer - BSDFData bsdfData; - ZERO_INITIALIZE(BSDFData, bsdfData); - BuiltinData builtinData; - ZERO_INITIALIZE(BuiltinData, builtinData); - uint featureFlags = MATERIALFEATUREFLAGS_LIT_SUBSURFACE_SCATTERING; - DecodeFromGBuffer(currentPixelCoord, featureFlags, bsdfData, builtinData); + // Read the normal data + NormalData normalData; + DecodeFromNormalBuffer(currentPixelCoord, normalData); // Read the SSS Data SSSData sssData; @@ -88,7 +84,7 @@ void RayGenSubSurface() // Do our walk ScatteringResult scatteringResult; - ScatteringWalk(bsdfData.normalWS, bsdfData.diffuseColor, scatteringDistance, currentPixelCoord, globalSampleIndex, posInput.positionWS, scatteringResult); + ScatteringWalk(normalData.normalWS, sssData.diffuseColor, scatteringDistance, currentPixelCoord, globalSampleIndex, posInput.positionWS, scatteringResult); // Normalize the throughput scatteringResult.outputThroughput /= (float)_RaytracingNumSamples; From 6102466e38f6a751bd35fff1b2ad8aec160fceb2 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Mon, 18 May 2020 21:53:01 +0200 Subject: [PATCH 80/81] fix DXR manifest --- TestProjects/HDRP_DXR_Tests/Packages/manifest.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TestProjects/HDRP_DXR_Tests/Packages/manifest.json b/TestProjects/HDRP_DXR_Tests/Packages/manifest.json index 8439c77f45a..88bef3f617a 100644 --- a/TestProjects/HDRP_DXR_Tests/Packages/manifest.json +++ b/TestProjects/HDRP_DXR_Tests/Packages/manifest.json @@ -2,25 +2,25 @@ "dependencies": { "com.unity.2d.sprite": "1.0.0", "com.unity.2d.tilemap": "1.0.0", - "com.unity.ads": "3.3.1", + "com.unity.ads": "3.4.4", "com.unity.analytics": "3.3.5", - "com.unity.collab-proxy": "1.3.5", "com.unity.ide.rider": "1.2.1", "com.unity.ide.visualstudio": "2.0.0", "com.unity.ide.vscode": "1.1.4", + "com.unity.multiplayer-hlapi": "1.0.4", "com.unity.purchasing": "2.0.6", "com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", "com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition", "com.unity.render-pipelines.high-definition-config": "file:../LocalPackages/com.unity.render-pipelines.high-definition-config", "com.unity.shadergraph": "file:../../../com.unity.shadergraph", - "com.unity.test-framework": "1.1.9", + "com.unity.test-framework": "1.1.13", "com.unity.testframework.graphics": "7.2.1-preview", "com.unity.testing.hdrp": "file:../../../com.unity.testing.hdrp", "com.unity.textmeshpro": "3.0.0-preview.1", "com.unity.timeline": "1.2.6", "com.unity.ugui": "1.0.0", "com.unity.visualeffectgraph": "file:../../../com.unity.visualeffectgraph", - "com.unity.xr.legacyinputhelpers": "1.3.7", + "com.unity.xr.legacyinputhelpers": "1.3.11", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", From 917431459806676a39a834f0e8d77bb1dd7f390d Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Tue, 19 May 2020 00:15:42 +0200 Subject: [PATCH 81/81] update reference screenshots --- .../Direct3D11/None/1710_Decals_Normal_Patch.png | 4 ++-- .../Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png | 4 ++-- .../WindowsEditor/Direct3D11/None/2601_SSAO_HalfRes.png | 4 ++-- .../WindowsEditor/Direct3D11/None/2602_SSAO_FullRes.png | 4 ++-- .../Linear/WindowsEditor/Direct3D11/None/4052_TAA.png | 4 ++-- .../WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1710_Decals_Normal_Patch.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1710_Decals_Normal_Patch.png index 3160433f359..4fb0aaa0453 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1710_Decals_Normal_Patch.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/1710_Decals_Normal_Patch.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c70bf0b1d29454fd2ae35267909ea4aea9aed834361bf6e22b333743b49c88ce -size 64825 +oid sha256:6ffc533da9518f67d6bd96507273b32ce2ecfda4ae7395ebbb61be259d0fe1d6 +size 63642 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png index 719eab3a10a..13666faf757 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2316_ShadowTint.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:556bc8905ef1f0f78382707adf52761e3d0a2a1b4e04185f255fdb8e7c72a7b4 -size 132133 +oid sha256:3a6cc6c9e5ceeb4eab1a884369ec892e1461a420f5f8b927539445b1d7df6526 +size 132020 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2601_SSAO_HalfRes.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2601_SSAO_HalfRes.png index 8c455613a93..696532baa26 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2601_SSAO_HalfRes.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2601_SSAO_HalfRes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7b18128f7c2f299245d29b1b281df8cf638a1140c81301041a267892de271be3 -size 133832 +oid sha256:f50c0856d3250f8cef177c562bf45278e8138336f623f1ba1e3638d8b90f2d97 +size 138385 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2602_SSAO_FullRes.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2602_SSAO_FullRes.png index ba2e24790f9..4d1d4d33411 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2602_SSAO_FullRes.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/2602_SSAO_FullRes.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2bd1a14cd17243c2da3e2021eaabba11792e40afe1f7fdaa7009e302e64c3686 -size 154493 +oid sha256:201a9d7e8c98df01d55770a3e4e2ba3b697770923841da173a206677ca52d059 +size 161780 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png index 29015fff8e2..50255388db6 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e293a01b72ac593c538be1e0d6db9fcf095f9447c297a1123d27373e3d57445d -size 183316 +oid sha256:407996856886cd24a508b6d9577aeb9b2e6af9cec8564778702b32c3cf6e3812 +size 184101 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png index c26c649282f..74478ca59e7 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4053_TAA-FP16Alpha.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:35bfaabe20c17251cff955c89334d02eeca38087670aa474b40536d1ff1dfd3c -size 191253 +oid sha256:b1317b044ef80780ceeadde45548f4f266c403f0f2e6477454bf28933f1c7e22 +size 192501