diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 147e010df59..0453efa69d3 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -109,6 +109,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed error when changing planar probe resolution. - Fixed the dependecy of FrameSettings (MSAA, ClearGBuffer, DepthPrepassWithDeferred) (case 1277620). - Fixed the usage of GUIEnable for volume components (case 1280018). +- Fixed the diffusion profile becoming invalid when hitting the reset (case 1269462). ### Changed - Preparation pass for RTSSShadows to be supported by render graph. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs index 3ec6613de7e..3b60ac18899 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs @@ -1,4 +1,5 @@ using System; +using UnityEditor.Rendering.HighDefinition; namespace UnityEngine.Rendering.HighDefinition { @@ -52,14 +53,19 @@ public enum TransmissionMode : uint // Here we need to have one parameter in the diffusion profile parameter because the deserialization call the default constructor public DiffusionProfile(bool dontUseDefaultConstructor) + { + ResetToDefault(); + } + + public void ResetToDefault() { scatteringDistance = Color.grey; - transmissionTint = Color.white; - texturingMode = TexturingMode.PreAndPostScatter; - transmissionMode = TransmissionMode.ThinObject; - thicknessRemap = new Vector2(0f, 5f); - worldScale = 1f; - ior = 1.4f; // Typical value for skin specular reflectance + transmissionTint = Color.white; + texturingMode = TexturingMode.PreAndPostScatter; + transmissionMode = TransmissionMode.ThinObject; + thicknessRemap = new Vector2(0f, 5f); + worldScale = 1f; + ior = 1.4f; // Typical value for skin specular reflectance } internal void Validate() @@ -223,6 +229,15 @@ void OnEnable() #endif } + internal void Reset() + { + if (profile.hash == 0) + { + profile.ResetToDefault(); + profile.hash = DiffusionProfileHashTable.GenerateUniqueHash(this); + } + } + internal void UpdateCache() { worldScaleAndFilterRadiusAndThicknessRemap = new Vector4(profile.worldScale, diff --git a/com.unity.render-pipelines.high-definition/Runtime/Utilities/DiffusionProfileHashTable.cs b/com.unity.render-pipelines.high-definition/Runtime/Utilities/DiffusionProfileHashTable.cs index bb0fe224938..644b4252363 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Utilities/DiffusionProfileHashTable.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Utilities/DiffusionProfileHashTable.cs @@ -32,7 +32,7 @@ static uint GetDiffusionProfileHash(DiffusionProfileSettings asset) return (exponent << 23) | mantissa; } - static uint GenerateUniqueHash(DiffusionProfileSettings asset) + static internal uint GenerateUniqueHash(DiffusionProfileSettings asset) { uint hash = GetDiffusionProfileHash(asset);