浏览代码

Merge pull request #150 from Unity-Technologies/compare-and-branch

Comparison, Branch and Boolean
/main
GitHub 7 年前
当前提交
b72d0466
共有 41 个文件被更改,包括 945 次插入3 次删除
  1. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs
  2. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/PreviewProperty.cs
  3. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Implementation/NodeUtils.cs
  4. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs
  5. 13
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs
  6. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyType.cs
  7. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs
  8. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
  9. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs
  10. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
  11. 9
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
  12. 91
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanMaterialSlot.cs
  13. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanMaterialSlot.cs.meta
  14. 58
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanShaderProperty.cs
  15. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanShaderProperty.cs.meta
  16. 84
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/BooleanNode.cs
  17. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/BooleanNode.cs.meta
  18. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic.meta
  19. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs
  20. 3
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs.meta
  21. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs.meta
  22. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/BranchNode.cs.meta
  23. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AllNode.cs
  24. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AllNode.cs.meta
  25. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AnyNode.cs
  26. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AnyNode.cs.meta
  27. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsInfiniteNode.cs
  28. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsInfiniteNode.cs.meta
  29. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsNanNode.cs
  30. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsNanNode.cs.meta
  31. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AndNode.cs
  32. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AndNode.cs.meta
  33. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/BranchNode.cs
  34. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NandNode.cs
  35. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NandNode.cs.meta
  36. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/OrNode.cs
  37. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/OrNode.cs.meta
  38. 38
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NotNode.cs
  39. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NotNode.cs.meta
  40. 145
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs


return "(3)";
case ConcreteSlotValueType.Vector4:
return "(4)";
case ConcreteSlotValueType.Boolean:
return "(B)";
case ConcreteSlotValueType.Matrix2:
return "(2x2)";
case ConcreteSlotValueType.Matrix3:

return new Vector2MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue, shaderStage, hidden);
case SlotValueType.Vector1:
return new Vector1MaterialSlot(slotId, displayName, shaderOutputName, slotType, defaultValue.x, shaderStage, hidden);
case SlotValueType.Boolean:
return new BooleanMaterialSlot(slotId, displayName, shaderOutputName, slotType, false, shaderStage, hidden);
}
throw new ArgumentOutOfRangeException("type", type, null);

|| inputType == SlotValueType.Vector2
|| inputType == SlotValueType.Vector1
|| inputType == SlotValueType.Dynamic;
case SlotValueType.Boolean:
return inputType == SlotValueType.Boolean;
}
return false;
}

return PropertyType.Texture;
case ConcreteSlotValueType.Cubemap:
return PropertyType.Cubemap;
case ConcreteSlotValueType.Boolean:
return PropertyType.Boolean;
case ConcreteSlotValueType.Vector1:
return PropertyType.Float;
case ConcreteSlotValueType.Vector2:

20
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/PreviewProperty.cs


public Vector4 vector4Value;
[FieldOffset(0)]
public float floatValue;
[FieldOffset(0)]
public bool booleanValue;
}
Data m_Data;

}
}
public bool booleanValue
{
get
{
if (propType != PropertyType.Boolean)
throw new ArgumentException(string.Format(k_GetErrorMessage, PropertyType.Boolean, propType));
return m_Data.booleanValue;
}
set
{
if (propType != PropertyType.Boolean)
throw new ArgumentException(string.Format(k_SetErrorMessage, PropertyType.Boolean, propType));
m_Data.booleanValue = value;
}
}
const string k_SetErrorMessage = "Cannot set a {0} property on a PreviewProperty with type {1}.";
const string k_GetErrorMessage = "Cannot get a {0} property on a PreviewProperty with type {1}.";

block.SetVector(name, m_Data.vector4Value);
else if (propType == PropertyType.Float)
block.SetFloat(name, m_Data.floatValue);
else if (propType == PropertyType.Boolean)
block.SetFloat(name, m_Data.booleanValue ? 1 : 0);
}
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Implementation/NodeUtils.cs


{
switch (slotValue)
{
case ConcreteSlotValueType.Boolean:
return p.ToString();
case ConcreteSlotValueType.Vector1:
return p.ToString();
case ConcreteSlotValueType.Vector2:

7
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs


UpdateNodeAfterDeserialization();
}
protected struct Boolean
{}
protected struct Vector1
{}

if (p.ParameterType.IsByRef)
t = p.ParameterType.GetElementType();
if (t == typeof(Boolean))
{
return SlotValueType.Boolean;
}
if (t == typeof(Vector1))
{
return SlotValueType.Vector1;

13
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs


AddSlot(new CubemapMaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
else if (property is BooleanShaderProperty)
{
AddSlot(new BooleanMaterialSlot(OutputSlotId, "Out", "Out", SlotType.Output, false));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)

else if (property is ColorShaderProperty)
{
var result = string.Format("{0}4 {1} = {2};"
, precision
, GetVariableNameForSlot(OutputSlotId)
, property.referenceName);
visitor.AddShaderChunk(result, true);
}
else if (property is BooleanShaderProperty)
{
var result = string.Format("{0} {1} = {2};"
, precision
, GetVariableNameForSlot(OutputSlotId)
, property.referenceName);

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyType.cs


Color,
Texture,
Cubemap,
Boolean,
Float,
Vector2,
Vector3,

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs


Vector4,
Vector3,
Vector2,
Vector1
Vector1,
Boolean
}
public enum ConcreteSlotValueType

Vector4,
Vector3,
Vector2,
Vector1
Vector1,
Boolean
}
public static class SlotValueHelper

"typeFloat4",
"typeFloat3",
"typeFloat2",
"typeFloat1"
"typeFloat1",
"typeBoolean"
};
public static string ToClassName(this ConcreteSlotValueType type)

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs


gm.AddItem(new GUIContent("Vector3"), false, () => AddProperty(new Vector3ShaderProperty()));
gm.AddItem(new GUIContent("Vector4"), false, () => AddProperty(new Vector4ShaderProperty()));
gm.AddItem(new GUIContent("Color"), false, () => AddProperty(new ColorShaderProperty()));
gm.AddItem(new GUIContent("Boolean"), false, () => AddProperty(new BooleanShaderProperty()));
gm.AddItem(new GUIContent("Texture"), false, () => AddProperty(new TextureShaderProperty()));
gm.AddItem(new GUIContent("Cubemap"), false, () => AddProperty(new CubemapShaderProperty()));
gm.ShowAsContext();

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs


m_ValueAction = Vector3Field;
else if (property is Vector4ShaderProperty)
m_ValueAction = Vector4Field;
else if (property is BooleanShaderProperty)
m_ValueAction = BooleanField;
if (m_ValueAction != null)
{

{
var fProp = (Vector4ShaderProperty)property;
fProp.value = EditorGUILayout.Vector4Field("", fProp.value);
}
void BooleanField()
{
var fProp = (BooleanShaderProperty)property;
fProp.value = EditorGUILayout.Toggle(fProp.value);
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs


case ConcreteSlotValueType.Vector1:
prop = new FloatShaderProperty();
break;
case ConcreteSlotValueType.Boolean:
prop = new BooleanShaderProperty();
break;
default:
throw new ArgumentOutOfRangeException();
}

9
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss


margin-right: 0;
}
BooleanSlotControlView {
flex-direction: row;
align-items: center;
}
BooleanSlotControlView > Toggle {
width: 20;
}
.edge.fromMatrix4, .edge.fromMatrix3, .edge.fromMatrix2 {
edge-output-color: #8FC1DF;
}

91
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanMaterialSlot.cs


using System;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph
{
[Serializable]
public class BooleanMaterialSlot : MaterialSlot, IMaterialSlotHasValue<bool>
{
[SerializeField]
private bool m_Value;
[SerializeField]
private bool m_DefaultValue;
public BooleanMaterialSlot()
{}
public BooleanMaterialSlot(
int slotId,
string displayName,
string shaderOutputName,
SlotType slotType,
bool value,
ShaderStage shaderStage = ShaderStage.Dynamic,
bool hidden = false)
: base(slotId, displayName, shaderOutputName, slotType, shaderStage, hidden)
{
m_DefaultValue = value;
m_Value = value;
}
public override VisualElement InstantiateControl()
{
return new BooleanSlotControlView(this);
}
public bool defaultValue { get { return m_DefaultValue; } }
public bool value
{
get { return m_Value; }
set { m_Value = value; }
}
protected override string ConcreteSlotValueAsVariable(AbstractMaterialNode.OutputPrecision precision)
{
return (value ? 1 : 0).ToString();
}
public override void AddDefaultProperty(PropertyCollector properties, GenerationMode generationMode)
{
if (!generationMode.IsPreview())
return;
var matOwner = owner as AbstractMaterialNode;
if (matOwner == null)
throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode)));
var property = new BooleanShaderProperty()
{
overrideReferenceName = matOwner.GetVariableNameForSlot(id),
generatePropertyBlock = false,
value = value
};
properties.AddShaderProperty(property);
}
public override SlotValueType valueType { get { return SlotValueType.Boolean; } }
public override ConcreteSlotValueType concreteValueType { get { return ConcreteSlotValueType.Boolean; } }
public override PreviewProperty GetPreviewProperty(string name)
{
var pp = new PreviewProperty(PropertyType.Boolean)
{
name = name,
booleanValue = value
};
return pp;
}
public override void CopyValuesFrom(MaterialSlot foundSlot)
{
var slot = foundSlot as BooleanMaterialSlot;
if (slot != null)
value = slot.value;
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanMaterialSlot.cs.meta


fileFormatVersion: 2
guid: efad93f5b8245a54fb4fee128fc0f3f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

58
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanShaderProperty.cs


using System;
using System.Text;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
namespace UnityEditor.ShaderGraph
{
[Serializable]
public class BooleanShaderProperty : AbstractShaderProperty<bool>
{
public BooleanShaderProperty()
{
displayName = "Boolean";
}
public override PropertyType propertyType
{
get { return PropertyType.Boolean; }
}
public override Vector4 defaultValue
{
get { return new Vector4(); }
}
public override string GetPropertyBlockString()
{
var result = new StringBuilder();
result.Append("[Toggle] ");
result.Append(referenceName);
result.Append("(\"");
result.Append(displayName);
result.Append("\", Float) = ");
result.Append(value == true ? 1 : 0);
return result.ToString();
}
public override string GetPropertyDeclarationString(string delimiter = ";")
{
return string.Format("float {0}{1}", referenceName, delimiter);
}
public override PreviewProperty GetPreviewMaterialProperty()
{
return new PreviewProperty(PropertyType.Boolean)
{
name = referenceName,
booleanValue = value
};
}
public override INode ToConcreteNode()
{
return new BooleanNode { value = new Toggle(value) };
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanShaderProperty.cs.meta


fileFormatVersion: 2
guid: 8891f9466e6b01c498c3f4b2c6abc0eb
timeCreated: 1505346922

84
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/BooleanNode.cs


using System.Collections.Generic;
using UnityEditor.ShaderGraph.Drawing.Controls;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("Input", "Basic", "Boolean")]
public class BooleanNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode
{
[SerializeField]
private bool m_Value;
public const int OutputSlotId = 0;
private const string kOutputSlotName = "Out";
public BooleanNode()
{
name = "Boolean";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new BooleanMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, false));
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
}
[ToggleControl("")]
public Toggle value
{
get { return new Toggle(m_Value); }
set
{
if (m_Value == value.isOn)
return;
m_Value = value.isOn;
Dirty(ModificationScope.Node);
}
}
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
{
if (!generationMode.IsPreview())
return;
properties.AddShaderProperty(new BooleanShaderProperty()
{
overrideReferenceName = GetVariableNameForNode(),
generatePropertyBlock = false,
value = m_Value
});
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
if (generationMode.IsPreview())
return;
visitor.AddShaderChunk(precision + " " + GetVariableNameForNode() + " = " + (m_Value ? 1 : 0) + ";", true);
}
public override string GetVariableNameForSlot(int slotId)
{
return GetVariableNameForNode();
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(new PreviewProperty(PropertyType.Boolean)
{
name = GetVariableNameForNode(),
booleanValue = m_Value
});
}
public IShaderProperty AsShaderProperty()
{
return new BooleanShaderProperty { value = m_Value };
}
public int outputSlotId { get { return OutputSlotId; } }
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/BooleanNode.cs.meta


fileFormatVersion: 2
guid: a6bd4d4655c0b9046a14e6ab0caebdc3
timeCreated: 1445864587
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic.meta


fileFormatVersion: 2
guid: 1c5103f75b5ec7445bb4c7b5a36f6aec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

30
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs


using System;
using UnityEditor.Experimental.UIElements;
using UnityEditor.Graphing;
using UnityEngine;
using UnityEngine.Experimental.UIElements;
namespace UnityEditor.ShaderGraph.Drawing.Slots
{
public class BooleanSlotControlView : VisualElement
{
BooleanMaterialSlot m_Slot;
public BooleanSlotControlView(BooleanMaterialSlot slot)
{
m_Slot = slot;
Action changedToggle = () => { OnChangeToggle(); };
var toggleField = new UnityEngine.Experimental.UIElements.Toggle(changedToggle);
Add(toggleField);
}
void OnChangeToggle()
{
m_Slot.owner.owner.owner.RegisterCompleteObjectUndo("Toggle Change");
var value = m_Slot.value;
value = !value;
m_Slot.value = value;
m_Slot.owner.Dirty(ModificationScope.Node);
}
}
}

3
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs.meta


fileFormatVersion: 2
guid: 7fc29d436587748dcaaefd8669c3d946
timeCreated: 1510659384

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs.meta


fileFormatVersion: 2
guid: c66cc68d0d0862b4c8ddfc00093d0ae0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/BranchNode.cs.meta


fileFormatVersion: 2
guid: 15ad3dc0ff22d7748af5e82ef5503d32
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AllNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "All")]
public class AllNode : CodeFunctionNode
{
public AllNode()
{
name = "All";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_All", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_All(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out Boolean Out)
{
return
@"
{
Out = all(In);
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AllNode.cs.meta


fileFormatVersion: 2
guid: aa03a542537ab4fb4a01a004efa97f58
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AnyNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Any")]
public class AnyNode : CodeFunctionNode
{
public AnyNode()
{
name = "Any";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Any", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Any(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out Boolean Out)
{
return
@"
{
Out = any(In);
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AnyNode.cs.meta


fileFormatVersion: 2
guid: f3d072ddeeee848848f2e59dbb5cf1d9
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsInfiniteNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Is Infinite")]
public class IsInfiniteNode : CodeFunctionNode
{
public IsInfiniteNode()
{
name = "Is Infinite";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_IsInfinite", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_IsInfinite(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out Boolean Out)
{
return
@"
{
Out = isinf(In);
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsInfiniteNode.cs.meta


fileFormatVersion: 2
guid: 6eaf1bad910084b85ac9ead4319c7820
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsNanNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Is NaN")]
public class IsNanNode : CodeFunctionNode
{
public IsNanNode()
{
name = "Is NaN";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_IsNaN", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_IsNaN(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.None)] out Boolean Out)
{
return
@"
{
Out = isnan(In);
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsNanNode.cs.meta


fileFormatVersion: 2
guid: 0e15b8359c9db4d0ea27f4deab94137e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AndNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "And")]
public class AndNode : CodeFunctionNode
{
public AndNode()
{
name = "And";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_And", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_And(
[Slot(0, Binding.None)] Boolean A,
[Slot(1, Binding.None)] Boolean B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A && B;
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AndNode.cs.meta


fileFormatVersion: 2
guid: 34929a6d0bb40407fb00206ab0a10fa1
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

35
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/BranchNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Branch")]
public class BranchNode : CodeFunctionNode
{
public BranchNode()
{
name = "Branch";
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Branch", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Branch(
[Slot(0, Binding.None)] Boolean Predicate,
[Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector True,
[Slot(2, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector False,
[Slot(3, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
Out = (Predicate * True) + abs((Predicate - 1) * False);
}
";
}
}
}

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NandNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Nand")]
public class NandNode : CodeFunctionNode
{
public NandNode()
{
name = "Nand";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Nand", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Nand(
[Slot(0, Binding.None)] Boolean A,
[Slot(1, Binding.None)] Boolean B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = !A && !B;
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NandNode.cs.meta


fileFormatVersion: 2
guid: 4defde87a9d5e44d8b8900d3f8ef6440
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/OrNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Or")]
public class OrNode : CodeFunctionNode
{
public OrNode()
{
name = "Or";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Or", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Or(
[Slot(0, Binding.None)] Boolean A,
[Slot(1, Binding.None)] Boolean B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A || B;
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/OrNode.cs.meta


fileFormatVersion: 2
guid: 0f6f860c0f1e24214b5d2974cc624227
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

38
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NotNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
[Title("Utility", "Logic", "Not")]
public class NotNode : CodeFunctionNode
{
public NotNode()
{
name = "Not";
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Not", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Not(
[Slot(0, Binding.None)] Boolean In,
[Slot(1, Binding.None)] out Boolean Out)
{
return
@"
{
Out = !In;
}
";
}
}
}

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NotNode.cs.meta


fileFormatVersion: 2
guid: acb4138f9cef644dfa59102e871d1820
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

145
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;
namespace UnityEditor.ShaderGraph
{
public enum ComparisonType
{
Equal,
NotEqual,
Less,
LessOrEqual,
Greater,
GreaterOrEqual
};
[Title("Utility", "Logic", "Comparison")]
public class ComparisonNode : CodeFunctionNode
{
public ComparisonNode()
{
name = "Comparison";
}
[SerializeField]
private ComparisonType m_ComparisonType = ComparisonType.Equal;
[EnumControl("")]
public ComparisonType comparisonType
{
get { return m_ComparisonType; }
set
{
if (m_ComparisonType == value)
return;
m_ComparisonType = value;
Dirty(ModificationScope.Graph);
}
}
public override bool hasPreview
{
get { return false; }
}
protected override MethodInfo GetFunctionToConvert()
{
switch(comparisonType)
{
case ComparisonType.NotEqual:
return GetType().GetMethod("Unity_Comparison_NotEqual", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonType.Less:
return GetType().GetMethod("Unity_Comparison_Less", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonType.LessOrEqual:
return GetType().GetMethod("Unity_Comparison_LessOrEqual", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonType.Greater:
return GetType().GetMethod("Unity_Comparison_Greater", BindingFlags.Static | BindingFlags.NonPublic);
case ComparisonType.GreaterOrEqual:
return GetType().GetMethod("Unity_Comparison_GreaterOrEqual", BindingFlags.Static | BindingFlags.NonPublic);
default:
return GetType().GetMethod("Unity_Comparison_Equal", BindingFlags.Static | BindingFlags.NonPublic);
}
}
static string Unity_Comparison_Equal(
[Slot(0, Binding.None)] Vector1 A,
[Slot(1, Binding.None)] Vector1 B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A == B ? 1 : 0;
}
";
}
static string Unity_Comparison_NotEqual(
[Slot(0, Binding.None)] Vector1 A,
[Slot(1, Binding.None)] Vector1 B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A != B ? 1 : 0;
}
";
}
static string Unity_Comparison_Less(
[Slot(0, Binding.None)] Vector1 A,
[Slot(1, Binding.None)] Vector1 B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A < B ? 1 : 0;
}
";
}
static string Unity_Comparison_LessOrEqual(
[Slot(0, Binding.None)] Vector1 A,
[Slot(1, Binding.None)] Vector1 B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A <= B ? 1 : 0;
}
";
}
static string Unity_Comparison_Greater(
[Slot(0, Binding.None)] Vector1 A,
[Slot(1, Binding.None)] Vector1 B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A > B ? 1 : 0;
}
";
}
static string Unity_Comparison_GreaterOrEqual(
[Slot(0, Binding.None)] Vector1 A,
[Slot(1, Binding.None)] Vector1 B,
[Slot(2, Binding.None)] out Boolean Out)
{
return
@"
{
Out = A >= B ? 1 : 0;
}
";
}
}
}
正在加载...
取消
保存