Skip to content

Commit b37b4f3

Browse files
Fix for cross-pipeline work (#1851)
* making sure unknown node types are always disallowed by targets * cleaning up target node filtering * adding meta * Update CHANGELOG.md
1 parent d9e686d commit b37b4f3

File tree

9 files changed

+34
-7
lines changed

9 files changed

+34
-7
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ sealed class HDTarget : Target, IHasMetadata, ILegacyTarget
6363
public override bool IsNodeAllowedByTarget(Type nodeType)
6464
{
6565
SRPFilterAttribute srpFilter = NodeClassCache.GetAttributeOnNodeType<SRPFilterAttribute>(nodeType);
66-
return srpFilter == null || srpFilter.srpTypes.Contains(typeof(HDRenderPipeline));
66+
bool worksWithThisSrp = srpFilter == null || srpFilter.srpTypes.Contains(typeof(HDRenderPipeline));
67+
return worksWithThisSrp && base.IsNodeAllowedByTarget(nodeType);
6768
}
6869

6970
public HDTarget()

com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ public override bool IsActive()
153153
public override bool IsNodeAllowedByTarget(Type nodeType)
154154
{
155155
SRPFilterAttribute srpFilter = NodeClassCache.GetAttributeOnNodeType<SRPFilterAttribute>(nodeType);
156-
return srpFilter == null || srpFilter.srpTypes.Contains(typeof(UniversalRenderPipeline));
156+
bool worksWithThisSrp = srpFilter == null || srpFilter.srpTypes.Contains(typeof(UniversalRenderPipeline));
157+
return worksWithThisSrp && base.IsNodeAllowedByTarget(nodeType);
157158
}
158159
public override void Setup(ref TargetSetupContext context)
159160
{

com.unity.shadergraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2929
- Fixed an issue in ShaderGraph with integer-mode Vector1 properties throwing errors when the value is changed [1264930]
3030
- Fixed a bug where ShaderGraph would not load graphs using Procedural VT nodes when the nodes were the project had them disabled [1271598]
3131
- Fixed an issue where the ProceduralVT node was not updating any connected SampleVT nodes when the number of layers was changed [1274288]
32+
- Fixed an issue with how unknown nodes were treated during validation
3233
- Fixed an issue where ShaderGraph shaders did not reimport automatically when some of the included files changed [1269634]
3334
- 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
3435
- Fixed an issue where ShaderGraph was logging error when edited in play mode [1274148].
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace UnityEditor.ShaderGraph
4+
{
5+
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
6+
internal class NeverAllowedByTargetAttribute : ContextFilterableAttribute
7+
{
8+
}
9+
}

com.unity.shadergraph/Editor/Data/Attributes/NeverAllowedByTargetAttribute.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.shadergraph/Editor/Data/Nodes/LegacyUnknownTypeNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace UnityEditor.ShaderGraph
1414
{
1515
[Serializable]
16+
[NeverAllowedByTarget]
1617
class LegacyUnknownTypeNode : AbstractMaterialNode
1718
{
1819
public string serializedType;
@@ -42,7 +43,6 @@ public override void OnAfterDeserialize(string json)
4243
public override void ValidateNode()
4344
{
4445
base.ValidateNode();
45-
4646
owner.AddValidationError(objectId, "This node type could not be found. No function will be generated in the shader.", ShaderCompilerMessageSeverity.Warning);
4747
}
4848
}

com.unity.shadergraph/Editor/Generation/Target.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ internal abstract class Target : JsonObject
2121
public virtual void CollectShaderProperties(PropertyCollector collector, GenerationMode generationMode) { }
2222
public virtual void ProcessPreviewMaterial(Material material) { }
2323
public virtual object saveContext => null;
24-
public virtual bool IsNodeAllowedByTarget(Type nodeType) => true;
24+
public virtual bool IsNodeAllowedByTarget(Type nodeType)
25+
{
26+
NeverAllowedByTargetAttribute never = NodeClassCache.GetAttributeOnNodeType<NeverAllowedByTargetAttribute>(nodeType);
27+
return never == null;
28+
}
2529

2630
public abstract bool WorksWithSRP(RenderPipelineAsset scriptableRenderPipeline);
2731

com.unity.shadergraph/Editor/Generation/Targets/VFXTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override void GetFields(ref TargetFieldContext context)
5151

5252
public override bool IsNodeAllowedByTarget(Type nodeType)
5353
{
54-
return true;
54+
return base.IsNodeAllowedByTarget(nodeType);
5555
}
5656

5757
public override void GetActiveBlocks(ref TargetActiveBlockContext context)

com.unity.shadergraph/Editor/Serialization/MultiJsonInternal.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ public override void Setup(ref TargetSetupContext context)
212212
}
213213
}
214214

215+
[NeverAllowedByTarget]
215216
class UnknownNodeType : AbstractMaterialNode
216217
{
217218
public string jsonData;
@@ -245,8 +246,7 @@ public override string Serialize()
245246

246247
public override void ValidateNode()
247248
{
248-
isValid = false;
249-
SetOverrideActiveState(ActiveState.ExplicitInactive, false);
249+
base.ValidateNode();
250250
owner.AddValidationError(objectId, "This node type could not be found. No function will be generated in the shader.", ShaderCompilerMessageSeverity.Warning);
251251
}
252252
}

0 commit comments

Comments
 (0)