Skip to content

Fix for cross-pipeline work #1851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -26,6 +26,7 @@ The version number for this package has increased due to a version update of a r
- 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 @@ -210,6 +210,7 @@ public override void Setup(ref TargetSetupContext context)
}
}

[NeverAllowedByTarget]
class UnknownNodeType : AbstractMaterialNode
{
public string jsonData;
Expand Down Expand Up @@ -243,8 +244,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