Skip to content

Commit

Permalink
Fix for cross-pipeline work (#1851)
Browse files Browse the repository at this point in the history
* making sure unknown node types are always disallowed by targets

* cleaning up target node filtering

* adding meta

* Update CHANGELOG.md
  • Loading branch information
elizabeth-legros authored Oct 7, 2020
1 parent d9e686d commit b37b4f3
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ sealed class HDTarget : Target, IHasMetadata, ILegacyTarget
public override bool IsNodeAllowedByTarget(Type nodeType)
{
SRPFilterAttribute srpFilter = NodeClassCache.GetAttributeOnNodeType<SRPFilterAttribute>(nodeType);
return srpFilter == null || srpFilter.srpTypes.Contains(typeof(HDRenderPipeline));
bool worksWithThisSrp = srpFilter == null || srpFilter.srpTypes.Contains(typeof(HDRenderPipeline));
return worksWithThisSrp && base.IsNodeAllowedByTarget(nodeType);
}

public HDTarget()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public override bool IsActive()
public override bool IsNodeAllowedByTarget(Type nodeType)
{
SRPFilterAttribute srpFilter = NodeClassCache.GetAttributeOnNodeType<SRPFilterAttribute>(nodeType);
return srpFilter == null || srpFilter.srpTypes.Contains(typeof(UniversalRenderPipeline));
bool worksWithThisSrp = srpFilter == null || srpFilter.srpTypes.Contains(typeof(UniversalRenderPipeline));
return worksWithThisSrp && base.IsNodeAllowedByTarget(nodeType);
}
public override void Setup(ref TargetSetupContext context)
{
Expand Down
1 change: 1 addition & 0 deletions com.unity.shadergraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed an issue in ShaderGraph with integer-mode Vector1 properties throwing errors when the value is changed [1264930]
- Fixed a bug where ShaderGraph would not load graphs using Procedural VT nodes when the nodes were the project had them disabled [1271598]
- Fixed an issue where the ProceduralVT node was not updating any connected SampleVT nodes when the number of layers was changed [1274288]
- Fixed an issue with how unknown nodes were treated during validation
- Fixed an issue where ShaderGraph shaders did not reimport automatically when some of the included files changed [1269634]
- Fixed an issue where building a context menu on a dragging block node would leave it floating and undo/redo would result in a soft-lock
- Fixed an issue where ShaderGraph was logging error when edited in play mode [1274148].
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace UnityEditor.ShaderGraph
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
internal class NeverAllowedByTargetAttribute : ContextFilterableAttribute
{
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace UnityEditor.ShaderGraph
{
[Serializable]
[NeverAllowedByTarget]
class LegacyUnknownTypeNode : AbstractMaterialNode
{
public string serializedType;
Expand Down Expand Up @@ -42,7 +43,6 @@ public override void OnAfterDeserialize(string json)
public override void ValidateNode()
{
base.ValidateNode();

owner.AddValidationError(objectId, "This node type could not be found. No function will be generated in the shader.", ShaderCompilerMessageSeverity.Warning);
}
}
Expand Down
6 changes: 5 additions & 1 deletion com.unity.shadergraph/Editor/Generation/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ internal abstract class Target : JsonObject
public virtual void CollectShaderProperties(PropertyCollector collector, GenerationMode generationMode) { }
public virtual void ProcessPreviewMaterial(Material material) { }
public virtual object saveContext => null;
public virtual bool IsNodeAllowedByTarget(Type nodeType) => true;
public virtual bool IsNodeAllowedByTarget(Type nodeType)
{
NeverAllowedByTargetAttribute never = NodeClassCache.GetAttributeOnNodeType<NeverAllowedByTargetAttribute>(nodeType);
return never == null;
}

public abstract bool WorksWithSRP(RenderPipelineAsset scriptableRenderPipeline);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void GetFields(ref TargetFieldContext context)

public override bool IsNodeAllowedByTarget(Type nodeType)
{
return true;
return base.IsNodeAllowedByTarget(nodeType);
}

public override void GetActiveBlocks(ref TargetActiveBlockContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public override void Setup(ref TargetSetupContext context)
}
}

[NeverAllowedByTarget]
class UnknownNodeType : AbstractMaterialNode
{
public string jsonData;
Expand Down Expand Up @@ -245,8 +246,7 @@ public override string Serialize()

public override void ValidateNode()
{
isValid = false;
SetOverrideActiveState(ActiveState.ExplicitInactive, false);
base.ValidateNode();
owner.AddValidationError(objectId, "This node type could not be found. No function will be generated in the shader.", ShaderCompilerMessageSeverity.Warning);
}
}
Expand Down

0 comments on commit b37b4f3

Please sign in to comment.