当前提交
8984577a
共有 99 个文件被更改,包括 2795 次插入 和 433 次删除
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/ColorShaderProperty.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MaterialSlot.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/PreviewProperty.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableCubemap.cs
-
35MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SerializableTexture.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector1MaterialSlot.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector2MaterialSlot.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector3MaterialSlot.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Vector4MaterialSlot.cs
-
22MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Implementation/NodeUtils.cs
-
68MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightPBRSubShader.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/LightweightPipeline/LightWeightUnlitSubShader.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/MasterNodes/PBRMasterNode.cs
-
24MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/MasterNodes/UnlitMasterNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/AbstractMaterialNode.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/CodeFunctionNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/Vector1Node.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/Vector2Node.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/Vector3Node.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/Vector4Node.cs
-
39MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/PropertyNode.cs
-
36MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/MasterNode.cs
-
1MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/PropertyType.cs
-
9MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/SlotValue.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/GraphUtil.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Util/ShaderGenerator.cs
-
26MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ColorControl.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/DefaultControl.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/EdgeConnectorListener.cs
-
67MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/GraphInspectorView.cs
-
45MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/ShaderPropertyView.cs
-
99MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeSideHandle.cs
-
29MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/MaterialGraphEditWindow.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/PreviewManager.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/SearchWindowProvider.cs
-
99MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/GraphEditorView.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialGraphView.cs
-
101MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/MaterialNodeView.cs
-
46MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/PreviewSceneResources.cs
-
34MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/ShaderPort.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Editor/Importers/ShaderGraphImporter.cs
-
222MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Styles/MaterialGraph.uss
-
10MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightPBRForwardPass.template
-
26MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightUnlitPass.template
-
2MaterialGraphProject/Assets/UnityShaderEditor/package.json
-
2MaterialGraphProject/ProjectSettings/ProjectVersion.txt
-
91MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanMaterialSlot.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanMaterialSlot.cs.meta
-
58MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/BooleanShaderProperty.cs.meta
-
56MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IntegerShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/IntegerShaderProperty.cs.meta
-
61MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SliderShaderProperty.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/SliderShaderProperty.cs.meta
-
84MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/BooleanNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/BooleanNode.cs.meta
-
94MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/HDRColorNode.cs.meta
-
86MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/IntegerNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/IntegerNode.cs.meta
-
86MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/SliderNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Basic/SliderNode.cs.meta
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic.meta
-
53MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/IntegerControl.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/IntegerControl.cs.meta
-
170MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/SliderControl.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/SliderControl.cs.meta
-
99MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/MasterPreviewView.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Inspector/MasterPreviewView.cs.meta
-
54MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeBorderFrame.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/ResizeBorderFrame.cs.meta
-
179MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Manipulators/WindowDraggable.cs.meta
-
30MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Views/Slots/BooleanSlotControlView.cs.meta
-
51MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/BlitNoAlpha.shader
-
11MaterialGraphProject/Assets/UnityShaderEditor/Editor/Resources/Shaders/BlitNoAlpha.shader.meta
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs.meta
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/BranchNode.cs.meta
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AllNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AllNode.cs.meta
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AnyNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AnyNode.cs.meta
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsInfiniteNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsInfiniteNode.cs.meta
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsNanNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/IsNanNode.cs.meta
-
39MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AndNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/AndNode.cs.meta
-
35MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/BranchNode.cs
-
39MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NandNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NandNode.cs.meta
-
39MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/OrNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/OrNode.cs.meta
-
38MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NotNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/NotNode.cs.meta
-
145MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Utility/Logic/ComparisonNode.cs
|
|||
{ |
|||
"name": "com.unity.shadergraph", |
|||
"description": "Shader Graph", |
|||
"version": "0.1.13", |
|||
"version": "0.1.14", |
|||
"unity": "2018.1", |
|||
"dependencies": { |
|||
} |
|
|||
m_EditorVersion: 2018.1.0b1 |
|||
m_EditorVersion: 2018.1.0b4 |
|
|||
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; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: efad93f5b8245a54fb4fee128fc0f3f6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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) }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8891f9466e6b01c498c3f4b2c6abc0eb |
|||
timeCreated: 1505346922 |
|
|||
using System; |
|||
using System.Text; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Serializable] |
|||
public class IntegerShaderProperty : AbstractShaderProperty<int> |
|||
{ |
|||
public IntegerShaderProperty() |
|||
{ |
|||
displayName = "Integer"; |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Float; } |
|||
} |
|||
|
|||
public override Vector4 defaultValue |
|||
{ |
|||
get { return new Vector4(value, value, value, value); } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
result.Append(referenceName); |
|||
result.Append("(\""); |
|||
result.Append(displayName); |
|||
result.Append("\", Int) = "); |
|||
result.Append(value); |
|||
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.Float) |
|||
{ |
|||
name = referenceName, |
|||
floatValue = value |
|||
}; |
|||
} |
|||
|
|||
public override INode ToConcreteNode() |
|||
{ |
|||
return new IntegerNode { value = value }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5980fe29fe1b01c4fa3fb434dd9eb9e2 |
|||
timeCreated: 1505346922 |
|
|||
using System; |
|||
using System.Text; |
|||
using UnityEditor.Graphing; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Serializable] |
|||
public class SliderShaderProperty : AbstractShaderProperty<Vector3> |
|||
{ |
|||
public SliderShaderProperty() |
|||
{ |
|||
displayName = "Slider"; |
|||
value = new Vector3(0, 0, 1); |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Float; } |
|||
} |
|||
|
|||
public override Vector4 defaultValue |
|||
{ |
|||
get { return new Vector4(value.x, value.y, value.z, value.x); } |
|||
} |
|||
|
|||
public override string GetPropertyBlockString() |
|||
{ |
|||
var result = new StringBuilder(); |
|||
result.Append(referenceName); |
|||
result.Append("(\""); |
|||
result.Append(displayName); |
|||
result.Append("\", Range("); |
|||
result.Append(value.y); |
|||
result.Append(", "); |
|||
result.Append(value.z); |
|||
result.Append(")) = "); |
|||
result.Append(value.x); |
|||
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.Float) |
|||
{ |
|||
name = referenceName, |
|||
floatValue = value.x |
|||
}; |
|||
} |
|||
|
|||
public override INode ToConcreteNode() |
|||
{ |
|||
return new SliderNode { value = value }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 116edc957722a90438d51cf6610694d3 |
|||
timeCreated: 1505346922 |
|
|||
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; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a6bd4d4655c0b9046a14e6ab0caebdc3 |
|||
timeCreated: 1445864587 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input", "Basic", "HDR Color")] |
|||
public class HDRColorNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode |
|||
{ |
|||
[SerializeField] |
|||
private Color m_Color; |
|||
|
|||
public const int OutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public HDRColorNode() |
|||
{ |
|||
name = "HDR Color"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new ColorRGBAMaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
|
|||
[ColorControl("", ColorMode.HDR)] |
|||
public Color color |
|||
{ |
|||
get { return m_Color; } |
|||
set |
|||
{ |
|||
if (m_Color == value) |
|||
return; |
|||
|
|||
m_Color = value; |
|||
Dirty(ModificationScope.Node); |
|||
} |
|||
} |
|||
|
|||
|
|||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode) |
|||
{ |
|||
if (!generationMode.IsPreview()) |
|||
return; |
|||
|
|||
properties.AddShaderProperty(new ColorShaderProperty() |
|||
{ |
|||
overrideReferenceName = GetVariableNameForNode(), |
|||
generatePropertyBlock = false, |
|||
value = color, |
|||
HDR = true |
|||
}); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk(string.Format( |
|||
@"{0}4 {1} = IsGammaSpace() ? {0}4({2}, {3}, {4}, {5}) : {0}4(SRGBToLinear({0}3({2}, {3}, {4})), {5});" |
|||
, precision |
|||
, GetVariableNameForNode() |
|||
, color.r |
|||
, color.g |
|||
, color.b |
|||
, color.a), true); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(new PreviewProperty(PropertyType.Color) |
|||
{ |
|||
name = GetVariableNameForNode(), |
|||
colorValue = color |
|||
}); |
|||
} |
|||
|
|||
public IShaderProperty AsShaderProperty() |
|||
{ |
|||
return new ColorShaderProperty { value = color, HDR = true }; |
|||
} |
|||
|
|||
public int outputSlotId { get { return OutputSlotId; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 948ed387e8c19c14c82965be937d7284 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
using System.Collections.Generic; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input", "Basic", "Integer")] |
|||
public class IntegerNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode |
|||
{ |
|||
[SerializeField] |
|||
private int m_Value; |
|||
|
|||
public const int OutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public IntegerNode() |
|||
{ |
|||
name = "Integer"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
|
|||
[IntegerControl("")] |
|||
public int value |
|||
{ |
|||
get { return m_Value; } |
|||
set |
|||
{ |
|||
if (m_Value == value) |
|||
return; |
|||
|
|||
m_Value = value; |
|||
|
|||
Dirty(ModificationScope.Node); |
|||
} |
|||
} |
|||
|
|||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode) |
|||
{ |
|||
if (!generationMode.IsPreview()) |
|||
return; |
|||
|
|||
properties.AddShaderProperty(new IntegerShaderProperty() |
|||
{ |
|||
overrideReferenceName = GetVariableNameForNode(), |
|||
generatePropertyBlock = false, |
|||
value = value |
|||
}); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk(precision + " " + GetVariableNameForNode() + " = " + m_Value + ";", true); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(new PreviewProperty(PropertyType.Float) |
|||
{ |
|||
name = GetVariableNameForNode(), |
|||
floatValue = m_Value |
|||
}); |
|||
} |
|||
|
|||
public IShaderProperty AsShaderProperty() |
|||
{ |
|||
return new IntegerShaderProperty { value = value }; |
|||
} |
|||
|
|||
public int outputSlotId { get { return OutputSlotId; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e449bdf3b245898489ebab4f709ded62 |
|||
timeCreated: 1445864587 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEditor.ShaderGraph.Drawing.Controls; |
|||
using UnityEngine; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph |
|||
{ |
|||
[Title("Input", "Basic", "Slider")] |
|||
public class SliderNode : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode |
|||
{ |
|||
[SerializeField] |
|||
private Vector3 m_Value = new Vector3(0f, 0f, 1f); |
|||
|
|||
public const int OutputSlotId = 0; |
|||
private const string kOutputSlotName = "Out"; |
|||
|
|||
public SliderNode() |
|||
{ |
|||
name = "Slider"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0)); |
|||
RemoveSlotsNameNotMatching(new[] { OutputSlotId }); |
|||
} |
|||
|
|||
[SliderControl("", true)] |
|||
public Vector3 value |
|||
{ |
|||
get { return m_Value; } |
|||
set |
|||
{ |
|||
if (m_Value == value) |
|||
return; |
|||
|
|||
m_Value = value; |
|||
|
|||
Dirty(ModificationScope.Node); |
|||
} |
|||
} |
|||
|
|||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode) |
|||
{ |
|||
if (!generationMode.IsPreview()) |
|||
return; |
|||
|
|||
properties.AddShaderProperty(new SliderShaderProperty() |
|||
{ |
|||
overrideReferenceName = GetVariableNameForNode(), |
|||
generatePropertyBlock = false, |
|||
value = value |
|||
}); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk(precision + " " + GetVariableNameForNode() + " = " + m_Value.x + ";", true); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties) |
|||
{ |
|||
properties.Add(new PreviewProperty(PropertyType.Float) |
|||
{ |
|||
name = GetVariableNameForNode(), |
|||
floatValue = m_Value.x |
|||
}); |
|||
} |
|||
|
|||
public IShaderProperty AsShaderProperty() |
|||
{ |
|||
return new SliderShaderProperty { value = value }; |
|||
} |
|||
|
|||
public int outputSlotId { get { return OutputSlotId; } } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 39d5ba890306e584c9fb4fede8c37f9c |
|||
timeCreated: 1445864587 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1c5103f75b5ec7445bb4c7b5a36f6aec |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEditor.Experimental.UIElements; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing.Controls |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Property)] |
|||
public class IntegerControlAttribute : Attribute, IControlAttribute |
|||
{ |
|||
string m_Label; |
|||
|
|||
public IntegerControlAttribute(string label = null) |
|||
{ |
|||
m_Label = label; |
|||
} |
|||
|
|||
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
return new IntegerControlView(m_Label, node, propertyInfo); |
|||
} |
|||
} |
|||
|
|||
public class IntegerControlView : VisualElement |
|||
{ |
|||
AbstractMaterialNode m_Node; |
|||
PropertyInfo m_PropertyInfo; |
|||
|
|||
public IntegerControlView(string label, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
m_Node = node; |
|||
m_PropertyInfo = propertyInfo; |
|||
if (propertyInfo.PropertyType != typeof(int)) |
|||
throw new ArgumentException("Property must be of type integer.", "propertyInfo"); |
|||
label = label ?? ObjectNames.NicifyVariableName(propertyInfo.Name); |
|||
|
|||
if (!string.IsNullOrEmpty(label)) |
|||
Add(new Label(label)); |
|||
|
|||
var intField = new IntegerField { value = (int)m_PropertyInfo.GetValue(m_Node, null) }; |
|||
intField.OnValueChanged(OnChange); |
|||
Add(intField); |
|||
} |
|||
|
|||
void OnChange(ChangeEvent<long> evt) |
|||
{ |
|||
m_Node.owner.owner.RegisterCompleteObjectUndo("Integer Change"); |
|||
m_PropertyInfo.SetValue(m_Node, (int)evt.newValue, null); |
|||
Dirty(ChangeType.Repaint); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 57d18a57866821542806ab5253cf4310 |
|||
timeCreated: 1507817885 |
|
|||
using System; |
|||
using System.Reflection; |
|||
using UnityEditor.Experimental.UIElements; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEditor.Graphing; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing.Controls |
|||
{ |
|||
[AttributeUsage(AttributeTargets.Property)] |
|||
public class SliderControlAttribute : Attribute, IControlAttribute |
|||
{ |
|||
string m_Label; |
|||
bool m_DisplayMinMax; |
|||
|
|||
public SliderControlAttribute(string label = null, bool displayMinMax = false) |
|||
{ |
|||
m_Label = label; |
|||
m_DisplayMinMax = displayMinMax; |
|||
} |
|||
|
|||
public VisualElement InstantiateControl(AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
return new SliderControlView(m_Label, m_DisplayMinMax, node, propertyInfo); |
|||
} |
|||
} |
|||
|
|||
public class SliderControlView : VisualElement, INodeModificationListener |
|||
{ |
|||
GUIContent m_Label; |
|||
AbstractMaterialNode m_Node; |
|||
PropertyInfo m_PropertyInfo; |
|||
bool m_DisplayMinMax; |
|||
int m_UndoGroup = -1; |
|||
Vector3 m_Value; |
|||
|
|||
VisualElement m_SliderPanel; |
|||
Slider m_Slider; |
|||
FloatField m_SliderInput; |
|||
FloatField m_MinField; |
|||
FloatField m_MaxField; |
|||
|
|||
public SliderControlView(string label, bool displayMinMax, AbstractMaterialNode node, PropertyInfo propertyInfo) |
|||
{ |
|||
m_Node = node; |
|||
m_PropertyInfo = propertyInfo; |
|||
m_DisplayMinMax = displayMinMax; |
|||
|
|||
if (propertyInfo.PropertyType != typeof(Vector3)) |
|||
throw new ArgumentException("Property must be of type Vector3.", "propertyInfo"); |
|||
m_Label = new GUIContent(label ?? ObjectNames.NicifyVariableName(propertyInfo.Name)); |
|||
m_Value = (Vector3)m_PropertyInfo.GetValue(m_Node, null); |
|||
|
|||
m_SliderPanel = new VisualElement { name = "SliderPanel" }; |
|||
if (!string.IsNullOrEmpty(label)) |
|||
m_SliderPanel.Add(new Label(label)); |
|||
Action<float> changedSlider = (s) => { OnChangeSlider(s); }; |
|||
m_Slider = new Slider(m_Value.y, m_Value.z, changedSlider); |
|||
m_Slider.value = m_Value.x; |
|||
m_SliderPanel.Add(m_Slider); |
|||
m_SliderInput = AddField(m_SliderPanel, "", 0, m_Value); |
|||
Add(m_SliderPanel); |
|||
|
|||
if(m_DisplayMinMax) |
|||
{ |
|||
var fieldsPanel = new VisualElement { name = "FieldsPanel" }; |
|||
m_MinField = AddField(fieldsPanel, "Min", 1, m_Value); |
|||
m_MaxField = AddField(fieldsPanel, "Max", 2, m_Value); |
|||
Add(fieldsPanel); |
|||
} |
|||
} |
|||
|
|||
public void OnNodeModified(ModificationScope scope) |
|||
{ |
|||
if (scope == ModificationScope.Graph) |
|||
{ |
|||
Dirty(ChangeType.Repaint); |
|||
} |
|||
} |
|||
|
|||
void OnChangeSlider(float newValue) |
|||
{ |
|||
m_Node.owner.owner.RegisterCompleteObjectUndo("Slider Change"); |
|||
var value = (Vector3)m_PropertyInfo.GetValue(m_Node, null); |
|||
value.x = newValue; |
|||
m_PropertyInfo.SetValue(m_Node, value, null); |
|||
if(m_SliderInput != null) |
|||
m_SliderInput.value = newValue; |
|||
Dirty(ChangeType.Repaint); |
|||
} |
|||
|
|||
FloatField AddField(VisualElement panel, string label, int index, Vector3 initValiue) |
|||
{ |
|||
var field = new FloatField { userData = index, value = initValiue[index] }; |
|||
|
|||
if(label != "") |
|||
{ |
|||
var l = new Label(label); |
|||
panel.Add(l); |
|||
var dragger = new FieldMouseDragger<double>(field); |
|||
dragger.SetDragZone(l); |
|||
} |
|||
|
|||
field.RegisterCallback<MouseDownEvent>(Repaint); |
|||
field.RegisterCallback<MouseMoveEvent>(Repaint); |
|||
field.OnValueChanged(evt => |
|||
{ |
|||
var value = (Vector3)m_PropertyInfo.GetValue(m_Node, null); |
|||
value[index] = (float)evt.newValue; |
|||
m_PropertyInfo.SetValue(m_Node, value, null); |
|||
m_UndoGroup = -1; |
|||
UpdateSlider(m_SliderPanel, index, value); |
|||
Dirty(ChangeType.Repaint); |
|||
}); |
|||
field.RegisterCallback<InputEvent>(evt => |
|||
{ |
|||
if (m_UndoGroup == -1) |
|||
{ |
|||
m_UndoGroup = Undo.GetCurrentGroup(); |
|||
m_Node.owner.owner.RegisterCompleteObjectUndo("Change " + m_Node.name); |
|||
} |
|||
float newValue; |
|||
if (!float.TryParse(evt.newData, out newValue)) |
|||
newValue = 0f; |
|||
var value = (Vector3)m_PropertyInfo.GetValue(m_Node, null); |
|||
value[index] = newValue; |
|||
m_PropertyInfo.SetValue(m_Node, value, null); |
|||
Dirty(ChangeType.Repaint); |
|||
}); |
|||
field.RegisterCallback<KeyDownEvent>(evt => |
|||
{ |
|||
if (evt.keyCode == KeyCode.Escape && m_UndoGroup > -1) |
|||
{ |
|||
Undo.RevertAllDownToGroup(m_UndoGroup); |
|||
m_UndoGroup = -1; |
|||
m_Value = (Vector3)m_PropertyInfo.GetValue(m_Node, null); |
|||
UpdateSlider(m_SliderPanel, index, m_Value); |
|||
evt.StopPropagation(); |
|||
} |
|||
Dirty(ChangeType.Repaint); |
|||
}); |
|||
panel.Add(field); |
|||
return field; |
|||
} |
|||
|
|||
void UpdateSlider(VisualElement panel, int index, Vector3 value) |
|||
{ |
|||
value.x = Mathf.Max(Mathf.Min(value.x, value.z), value.y); |
|||
panel.Remove(m_Slider); |
|||
Action<float> changedSlider = (s) => { OnChangeSlider(s); }; |
|||
m_Slider = new Slider(value.y, value.z, changedSlider); |
|||
m_Slider.lowValue = value.y; |
|||
m_Slider.highValue = value.z; |
|||
m_Slider.value = value.x; |
|||
panel.Add(m_Slider); |
|||
|
|||
panel.Remove(m_SliderInput); |
|||
if(index != 0) |
|||
m_SliderInput = AddField(panel, "", 0, value); |
|||
m_SliderInput.value = value.x; |
|||
panel.Add(m_SliderInput); |
|||
} |
|||
|
|||
void Repaint<T>(MouseEventBase<T> evt) where T : MouseEventBase<T>, new() |
|||
{ |
|||
evt.StopPropagation(); |
|||
Dirty(ChangeType.Repaint); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c74a50771637c2d49980f713bbb7f4ea |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEditor.Experimental.UIElements; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEditor.Graphing; |
|||
using Object = UnityEngine.Object; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing.Inspector |
|||
{ |
|||
public class MasterPreviewView : VisualElement |
|||
{ |
|||
AbstractMaterialGraph m_Graph; |
|||
|
|||
PreviewRenderData m_PreviewRenderHandle; |
|||
PreviewTextureView m_PreviewTextureView; |
|||
|
|||
Vector2 m_PreviewScrollPosition; |
|||
ObjectField m_PreviewMeshPicker; |
|||
|
|||
MasterNode m_MasterNode; |
|||
|
|||
public MasterPreviewView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph) |
|||
{ |
|||
m_Graph = graph; |
|||
|
|||
AddStyleSheetPath("Styles/MaterialGraph"); |
|||
|
|||
m_PreviewRenderHandle = previewManager.masterRenderData; |
|||
m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged; |
|||
|
|||
var topContainer = new VisualElement() { name = "top" }; |
|||
{ |
|||
var title = new Label(assetName + " master node preview") { name = "title" }; |
|||
topContainer.Add(title); |
|||
} |
|||
Add(topContainer); |
|||
|
|||
var middleContainer = new VisualElement {name = "middle"}; |
|||
{ |
|||
m_PreviewTextureView = new PreviewTextureView { name = "preview", image = Texture2D.blackTexture }; |
|||
m_PreviewTextureView.AddManipulator(new Draggable(OnMouseDragPreviwMesh, true)); |
|||
middleContainer.Add(m_PreviewTextureView); |
|||
|
|||
m_PreviewScrollPosition = new Vector2(0f, 0f); |
|||
|
|||
middleContainer.Add(m_PreviewTextureView); |
|||
} |
|||
Add(middleContainer); |
|||
|
|||
var bottomContainer = new VisualElement() { name = "bottom" }; |
|||
{ |
|||
m_PreviewMeshPicker = new ObjectField { name = "picker", objectType = typeof(Mesh) }; |
|||
m_PreviewMeshPicker.OnValueChanged(OnPreviewMeshChanged); |
|||
|
|||
bottomContainer.Add(m_PreviewMeshPicker); |
|||
} |
|||
Add(bottomContainer); |
|||
} |
|||
|
|||
MasterNode masterNode |
|||
{ |
|||
get { return m_PreviewRenderHandle.shaderData.node as MasterNode; } |
|||
} |
|||
|
|||
void OnPreviewChanged() |
|||
{ |
|||
m_PreviewTextureView.image = m_PreviewRenderHandle.texture ?? Texture2D.blackTexture; |
|||
m_PreviewTextureView.Dirty(ChangeType.Repaint); |
|||
} |
|||
|
|||
void OnPreviewMeshChanged(ChangeEvent<Object> changeEvent) |
|||
{ |
|||
Mesh changedMesh = changeEvent.newValue as Mesh; |
|||
|
|||
masterNode.Dirty(ModificationScope.Node); |
|||
|
|||
if (m_Graph.previewData.serializedMesh.mesh != changedMesh) |
|||
{ |
|||
m_Graph.previewData.rotation = Quaternion.identity; |
|||
} |
|||
|
|||
m_Graph.previewData.serializedMesh.mesh = changedMesh; |
|||
} |
|||
|
|||
void OnMouseDragPreviwMesh(Vector2 deltaMouse) |
|||
{ |
|||
Vector2 previewSize = m_PreviewTextureView.contentRect.size; |
|||
|
|||
m_PreviewScrollPosition -= deltaMouse * (Event.current.shift ? 3f : 1f) / Mathf.Min(previewSize.x, previewSize.y) * 140f; |
|||
m_PreviewScrollPosition.y = Mathf.Clamp(m_PreviewScrollPosition.y, -90f, 90f); |
|||
Quaternion previewRotation = Quaternion.Euler(m_PreviewScrollPosition.y, 0, 0) * Quaternion.Euler(0, m_PreviewScrollPosition.x, 0); |
|||
m_Graph.previewData.rotation = previewRotation; |
|||
|
|||
masterNode.Dirty(ModificationScope.Node); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 546947d46a85b284a971a3f056495735 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEditor.ShaderGraph.Drawing; |
|||
|
|||
|
|||
public class ResizeBorderFrame : VisualElement |
|||
{ |
|||
public Action OnResizeFinished; |
|||
|
|||
public ResizeBorderFrame(VisualElement target) |
|||
{ |
|||
pickingMode = PickingMode.Ignore; |
|||
|
|||
AddToClassList("reszieBorderFrame"); |
|||
|
|||
ResizeSideHandle topLeft = new ResizeSideHandle(target, ResizeHandleAnchor.TopLeft); |
|||
ResizeSideHandle top = new ResizeSideHandle(target, ResizeHandleAnchor.Top); |
|||
ResizeSideHandle topRight = new ResizeSideHandle(target, ResizeHandleAnchor.TopRight); |
|||
ResizeSideHandle right = new ResizeSideHandle(target, ResizeHandleAnchor.Right); |
|||
ResizeSideHandle bottomRight = new ResizeSideHandle(target, ResizeHandleAnchor.BottomRight); |
|||
ResizeSideHandle bottom = new ResizeSideHandle(target, ResizeHandleAnchor.Bottom); |
|||
ResizeSideHandle bottomLeft = new ResizeSideHandle(target, ResizeHandleAnchor.BottomLeft); |
|||
ResizeSideHandle left = new ResizeSideHandle(target, ResizeHandleAnchor.Left); |
|||
|
|||
topLeft.OnResizeFinished += HandleResizefinished; |
|||
top.OnResizeFinished += HandleResizefinished; |
|||
topRight.OnResizeFinished += HandleResizefinished; |
|||
right.OnResizeFinished += HandleResizefinished; |
|||
bottomRight.OnResizeFinished += HandleResizefinished; |
|||
bottom.OnResizeFinished += HandleResizefinished; |
|||
bottomLeft.OnResizeFinished += HandleResizefinished; |
|||
left.OnResizeFinished += HandleResizefinished; |
|||
|
|||
Add(topLeft); |
|||
Add(top); |
|||
Add(topRight); |
|||
Add(right); |
|||
Add(bottomRight); |
|||
Add(bottom); |
|||
Add(bottomLeft); |
|||
Add(left); |
|||
} |
|||
|
|||
void HandleResizefinished() |
|||
{ |
|||
if (OnResizeFinished != null) |
|||
{ |
|||
OnResizeFinished(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1128492b211994d46be4acd2ccac15fb |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.UIElements; |
|||
using UnityEditor.Experimental.UIElements; |
|||
|
|||
namespace UnityEditor.ShaderGraph.Drawing |
|||
{ |
|||
public class WindowDraggable : MouseManipulator |
|||
{ |
|||
bool m_ResizeWithParentWindow; |
|||
|
|||
bool m_Active; |
|||
|
|||
bool m_DockLeft; |
|||
bool m_DockTop; |
|||
|
|||
Vector2 m_LocalMosueOffset; |
|||
Rect m_PreviousParentRect; |
|||
|
|||
public Action OnDragFinished; |
|||
|
|||
public WindowDraggable(bool resizeWithParentwindow = false) |
|||
{ |
|||
m_ResizeWithParentWindow = resizeWithParentwindow; |
|||
m_Active = false; |
|||
m_PreviousParentRect = new Rect(0f, 0f, 0f, 0f); |
|||
} |
|||
|
|||
protected override void RegisterCallbacksOnTarget() |
|||
{ |
|||
target.RegisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture); |
|||
target.RegisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture); |
|||
target.RegisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture); |
|||
target.RegisterCallback<PostLayoutEvent>(InitialLayoutSetup); |
|||
} |
|||
|
|||
protected override void UnregisterCallbacksFromTarget() |
|||
{ |
|||
target.UnregisterCallback(new EventCallback<MouseDownEvent>(OnMouseDown), Capture.NoCapture); |
|||
target.UnregisterCallback(new EventCallback<MouseMoveEvent>(OnMouseMove), Capture.NoCapture); |
|||
target.UnregisterCallback(new EventCallback<MouseUpEvent>(OnMouseUp), Capture.NoCapture); |
|||
} |
|||
|
|||
void OnMouseDown(MouseDownEvent evt) |
|||
{ |
|||
m_Active = true; |
|||
m_LocalMosueOffset = target.WorldToLocal(evt.mousePosition); |
|||
|
|||
target.TakeMouseCapture(); |
|||
evt.StopPropagation(); |
|||
} |
|||
|
|||
void OnMouseMove(MouseMoveEvent evt) |
|||
{ |
|||
if (m_Active) |
|||
{ |
|||
Rect layout = target.layout; |
|||
layout.position = target.parent.WorldToLocal(evt.mousePosition - m_LocalMosueOffset); |
|||
target.layout = layout; |
|||
} |
|||
} |
|||
|
|||
void OnMouseUp(MouseUpEvent evt) |
|||
{ |
|||
bool emitDragFinishedEvent = m_Active; |
|||
|
|||
m_Active = false; |
|||
|
|||
if (target.HasMouseCapture()) |
|||
{ |
|||
target.ReleaseMouseCapture(); |
|||
} |
|||
|
|||
evt.StopPropagation(); |
|||
|
|||
RefreshDocking(); |
|||
|
|||
if (emitDragFinishedEvent && OnDragFinished != null) |
|||
{ |
|||
OnDragFinished(); |
|||
} |
|||
} |
|||
|
|||
void RefreshDocking() |
|||
{ |
|||
Vector2 windowCenter = new Vector2(target.layout.x + target.layout.width * .5f, target.layout.y + target.layout.height * .5f); |
|||
windowCenter /= target.parent.layout.size; |
|||
|
|||
m_DockLeft = windowCenter.x < .5f; |
|||
m_DockTop = windowCenter.y < .5f; |
|||
} |
|||
|
|||
void InitialLayoutSetup(PostLayoutEvent postLayoutEvent) |
|||
{ |
|||
m_PreviousParentRect = target.parent.layout; |
|||
target.UnregisterCallback<PostLayoutEvent>(InitialLayoutSetup); |
|||
target.RegisterCallback<PostLayoutEvent>(OnPostLayout); |
|||
|
|||
RefreshDocking(); |
|||
} |
|||
|
|||
void OnPostLayout(PostLayoutEvent postLayoutEvent) |
|||
{ |
|||
Rect windowRect = target.layout; |
|||
|
|||
Vector2 scaling = target.parent.layout.size / m_PreviousParentRect.size; |
|||
|
|||
Vector2 minSize = new Vector2(60f, 60f); |
|||
|
|||
if (!Mathf.Approximately(target.style.minWidth, 0f)) |
|||
{ |
|||
minSize.x = target.style.minWidth; |
|||
} |
|||
|
|||
if (!Mathf.Approximately(target.style.minHeight, 0f)) |
|||
{ |
|||
minSize.y = target.style.minHeight; |
|||
} |
|||
|
|||
Vector2 distanceFromParentEdge = Vector2.zero; |
|||
distanceFromParentEdge.x = m_DockLeft ? target.layout.x : (m_PreviousParentRect.width - target.layout.x - target.layout.width); |
|||
distanceFromParentEdge.y = m_DockTop ? target.layout.y: (m_PreviousParentRect.height - target.layout.y - target.layout.height); |
|||
|
|||
Vector2 normalizedDistanceFromEdge = distanceFromParentEdge / m_PreviousParentRect.size; |
|||
|
|||
if (m_ResizeWithParentWindow) |
|||
{ |
|||
if (scaling.x > 1f) |
|||
{ |
|||
scaling.x = target.parent.layout.width * .33f < minSize.x ? 1f : scaling.x; |
|||
} |
|||
|
|||
if (scaling.y > 1f) |
|||
{ |
|||
scaling.y = target.parent.layout.height * .33f < minSize.y ? 1f : scaling.y; |
|||
} |
|||
|
|||
windowRect.size *= scaling; |
|||
} |
|||
else |
|||
{ |
|||
normalizedDistanceFromEdge = distanceFromParentEdge / target.parent.layout.size; |
|||
} |
|||
|
|||
if (m_DockLeft) |
|||
{ |
|||
windowRect.x = normalizedDistanceFromEdge.x * target.parent.layout.width; |
|||
} |
|||
else |
|||
{ |
|||
windowRect.x = (1f - normalizedDistanceFromEdge.x) * target.parent.layout.width - windowRect.width; |
|||
} |
|||
|
|||
if (m_DockTop) |
|||
{ |
|||
windowRect.y = normalizedDistanceFromEdge.y * target.parent.layout.height; |
|||
} |
|||
else |
|||
{ |
|||
windowRect.y = (1f - normalizedDistanceFromEdge.y) * target.parent.layout.height- windowRect.height; |
|||
} |
|||
|
|||
windowRect.width = Mathf.Max(Mathf.Min(windowRect.width, target.parent.layout.width), minSize.x); |
|||
windowRect.height = Mathf.Max(Mathf.Min(windowRect.height, target.parent.layout.height), minSize.y); |
|||
|
|||
float maximumXPosition = Mathf.Max(target.parent.layout.width - windowRect.width, 0f); |
|||
float maximumYPosition = Mathf.Max(target.parent.layout.height - windowRect.height, 0f); |
|||
|
|||
windowRect.x = Mathf.Clamp(windowRect.x, 0f, maximumXPosition); |
|||
windowRect.y = Mathf.Clamp(windowRect.y, 0f, maximumYPosition); |
|||
|
|||
m_PreviousParentRect = target.parent.layout; |
|||
|
|||
target.layout = windowRect; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 604681490aa779348a355368c95cfcf5 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7fc29d436587748dcaaefd8669c3d946 |
|||
timeCreated: 1510659384 |
|
|||
Shader "Hidden/BlitNoAlpha" |
|||
{ |
|||
Properties |
|||
{ |
|||
_MainTex ("Texture", any) = "" {} |
|||
} |
|||
SubShader { |
|||
Pass { |
|||
ZTest Always Cull Off ZWrite Off |
|||
|
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#include "UnityCG.cginc" |
|||
|
|||
UNITY_DECLARE_SCREENSPACE_TEXTURE(_MainTex); |
|||
uniform float4 _MainTex_ST; |
|||
|
|||
struct appdata_t { |
|||
float4 vertex : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
UNITY_VERTEX_INPUT_INSTANCE_ID |
|||
}; |
|||
|
|||
struct v2f { |
|||
float4 vertex : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
UNITY_VERTEX_OUTPUT_STEREO |
|||
}; |
|||
|
|||
v2f vert (appdata_t v) |
|||
{ |
|||
v2f o; |
|||
UNITY_SETUP_INSTANCE_ID(v); |
|||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); |
|||
o.vertex = UnityObjectToClipPos(v.vertex); |
|||
o.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex); |
|||
return o; |
|||
} |
|||
|
|||
fixed4 frag (v2f i) : SV_Target |
|||
{ |
|||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); |
|||
return half4(UNITY_SAMPLE_SCREENSPACE_TEXTURE(_MainTex, i.texcoord).xyz, 1.0); |
|||
} |
|||
ENDCG |
|||
|
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 50b406436c6214c49aaaa6011b71dde8 |
|||
timeCreated: 1502007198 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c66cc68d0d0862b4c8ddfc00093d0ae0 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
fileFormatVersion: 2 |
|||
guid: 15ad3dc0ff22d7748af5e82ef5503d32 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: aa03a542537ab4fb4a01a004efa97f58 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f3d072ddeeee848848f2e59dbb5cf1d9 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6eaf1bad910084b85ac9ead4319c7820 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0e15b8359c9db4d0ea27f4deab94137e |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 34929a6d0bb40407fb00206ab0a10fa1 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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); |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
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; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4defde87a9d5e44d8b8900d3f8ef6440 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0f6f860c0f1e24214b5d2974cc624227 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: acb4138f9cef644dfa59102e871d1820 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
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; |
|||
} |
|||
";
|
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue