Skip to content

Commit

Permalink
Fix diffusion profile dependency (#2327)
Browse files Browse the repository at this point in the history
* 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 <julien@unity3d.com>
  • Loading branch information
alelievr and JulienIgnace-Unity committed Oct 23, 2020
1 parent 60cb43c commit a03e874
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Version Updated
The version number for this package has increased due to a version update of a related graphics package.

### Fixed
- Fixed a null reference exception when creating a diffusion profile asset.
- Fixed the diffusion profile not being registered as a dependency of the ShaderGraph.

### Changed
- Improved the punctual light shadow rescale algorithm.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace UnityEditor.Rendering.HighDefinition
[Title("Input", "High Definition Render Pipeline", "Diffusion Profile")]
[FormerName("UnityEditor.Experimental.Rendering.HDPipeline.DiffusionProfileNode")]
[FormerName("UnityEditor.ShaderGraph.DiffusionProfileNode")]
class DiffusionProfileNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode
[HasDependencies(typeof(DiffusionProfileNode))]
class DiffusionProfileNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode, IHasDependencies
{
public DiffusionProfileNode()
{
Expand Down Expand Up @@ -121,5 +122,14 @@ public AbstractShaderProperty AsShaderProperty()
}

public int outputSlotId => kOutputSlotId;

public void GetSourceAssetDependencies(AssetCollection assetCollection)
{
if ((diffusionProfile != null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(diffusionProfile, out string guid, out long localId))
{
// diffusion profile is a ScriptableObject, so this is an artifact dependency
assetCollection.AddAssetDependency(new GUID(guid), AssetCollection.Flags.ArtifactDependency | AssetCollection.Flags.IncludeInExportPackage);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void GetSourceAssetDependencies(AssetCollection assetCollection)
if ((diffusionProfile != null) && AssetDatabase.TryGetGUIDAndLocalFileIdentifier(diffusionProfile, out string guid, out long localId))
{
// diffusion profile is a ScriptableObject, so this is an artifact dependency
assetCollection.AddAssetDependency(new GUID(guid), AssetCollection.Flags.ArtifactDependency);
assetCollection.AddAssetDependency(new GUID(guid), AssetCollection.Flags.ArtifactDependency | AssetCollection.Flags.IncludeInExportPackage);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void OnEnable()
#if UNITY_EDITOR
internal void Reset()
{
if (profile.hash == 0)
if (profile != null && profile.hash == 0)
{
profile.ResetToDefault();
profile.hash = DiffusionProfileHashTable.GenerateUniqueHash(this);
Expand Down

0 comments on commit a03e874

Please sign in to comment.