Skip to content

Commit a03e874

Browse files
Antoine LelievreJulienIgnace-Unity
andauthored
Fix diffusion profile dependency (#2327)
* Fixed a nullref when a diffusion profile was created * Updated changelog * Trying to fix diffusion profile asset dependency * Fixed export as package * Updated changelog Co-authored-by: JulienIgnace-Unity <[email protected]>
1 parent 60cb43c commit a03e874

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
Version Updated
1010
The version number for this package has increased due to a version update of a related graphics package.
1111

12+
### Fixed
13+
- Fixed a null reference exception when creating a diffusion profile asset.
14+
- Fixed the diffusion profile not being registered as a dependency of the ShaderGraph.
15+
1216
### Changed
1317
- Improved the punctual light shadow rescale algorithm.
1418

com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Nodes/DiffusionProfileNode.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace UnityEditor.Rendering.HighDefinition
1515
[Title("Input", "High Definition Render Pipeline", "Diffusion Profile")]
1616
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.DiffusionProfileNode")]
1717
[FormerName("UnityEditor.ShaderGraph.DiffusionProfileNode")]
18-
class DiffusionProfileNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode
18+
[HasDependencies(typeof(DiffusionProfileNode))]
19+
class DiffusionProfileNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode, IHasDependencies
1920
{
2021
public DiffusionProfileNode()
2122
{
@@ -121,5 +122,14 @@ public AbstractShaderProperty AsShaderProperty()
121122
}
122123

123124
public int outputSlotId => kOutputSlotId;
125+
126+
public void GetSourceAssetDependencies(AssetCollection assetCollection)
127+
{
128+
if ((diffusionProfile != null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(diffusionProfile, out string guid, out long localId))
129+
{
130+
// diffusion profile is a ScriptableObject, so this is an artifact dependency
131+
assetCollection.AddAssetDependency(new GUID(guid), AssetCollection.Flags.ArtifactDependency | AssetCollection.Flags.IncludeInExportPackage);
132+
}
133+
}
124134
}
125135
}

com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Slots/DiffusionProfileInputMaterialSlot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void GetSourceAssetDependencies(AssetCollection assetCollection)
162162
if ((diffusionProfile != null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(diffusionProfile, out string guid, out long localId))
163163
{
164164
// diffusion profile is a ScriptableObject, so this is an artifact dependency
165-
assetCollection.AddAssetDependency(new GUID(guid), AssetCollection.Flags.ArtifactDependency);
165+
assetCollection.AddAssetDependency(new GUID(guid), AssetCollection.Flags.ArtifactDependency | AssetCollection.Flags.IncludeInExportPackage);
166166
}
167167
}
168168
}

com.unity.render-pipelines.high-definition/Runtime/Material/DiffusionProfile/DiffusionProfileSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void OnEnable()
232232
#if UNITY_EDITOR
233233
internal void Reset()
234234
{
235-
if (profile.hash == 0)
235+
if (profile != null && profile.hash == 0)
236236
{
237237
profile.ResetToDefault();
238238
profile.hash = DiffusionProfileHashTable.GenerateUniqueHash(this);

0 commit comments

Comments
 (0)