浏览代码
[Shader Graph] Add channel types. This allows for visual errors if you try to promote vectors.
/main
[Shader Graph] Add channel types. This allows for visual errors if you try to promote vectors.
/main
Tim Cooper
9 年前
当前提交
7f682001
共有 30 个文件被更改,包括 527 次插入 和 101 次删除
-
8UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs
-
1UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/DrawableMaterialNode.cs
-
4UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/SimpleWidgets.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Interfaces/Interfaces.cs
-
9UnityProject/Assets/UnityShaderEditor/Editor/Source/MaterialSubGraph.cs
-
249UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BaseMaterialNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/ColorNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Function1Input.cs
-
18UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Function2Input.cs
-
9UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/MultiplyNode.cs
-
3UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PixelShaderNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PropertyNode.cs
-
34UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/SlotValue.cs
-
6UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/SubGraphInputsNode.cs
-
8UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/SubGraphNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/TextureNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector1Node.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector4Node.cs
-
10UnityProject/Assets/UnityShaderEditor/Editor/Source/PixelGraph.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Prop/ColorProperty.cs
-
6UnityProject/Assets/UnityShaderEditor/Editor/Source/Prop/FloatProperty.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Prop/MaterialProperties.cs
-
3UnityProject/Assets/UnityShaderEditor/Editor/Source/Prop/ShaderProperty.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Prop/TextureProperty.cs
-
4UnityProject/Assets/UnityShaderEditor/Editor/Source/Prop/VectorProperty.cs
-
64UnityProject/Assets/UnityShaderEditor/Editor/Source/Util/ShaderGenerator.cs
-
48UnityProject/ProjectSettings/ProjectSettings.asset
-
2UnityProject/ProjectSettings/ProjectVersion.txt
-
110UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector2Node.cs
-
12UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector2Node.cs.meta
|
|||
m_EditorVersion: 5.3.0b5 |
|||
m_EditorVersion: 5.3.0b6 |
|||
m_StandardAssetsVersion: 0 |
|
|||
using System; |
|||
using UnityEditor.Graphs; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.MaterialGraph |
|||
{ |
|||
[Title("Generate/Vector 2 Node")] |
|||
class Vector2Node : PropertyNode, IGeneratesBodyCode |
|||
{ |
|||
private const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
private Vector2 m_Value; |
|||
|
|||
public override void OnCreate() |
|||
{ |
|||
base.OnCreate(); |
|||
name = "V2Node"; |
|||
} |
|||
|
|||
public override void OnEnable() |
|||
{ |
|||
base.OnEnable(); |
|||
AddSlot(new MaterialGraphSlot(new Slot(SlotType.OutputSlot, kOutputSlotName), SlotValueType.Vector2)); |
|||
} |
|||
|
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Vector2; } |
|||
} |
|||
|
|||
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{} |
|||
|
|||
public override string GetOutputVariableNameForSlot(Slot s, GenerationMode generationMode) |
|||
{ |
|||
return GetPropertyName(); |
|||
} |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode, ConcreteSlotValueType valueType) |
|||
{ |
|||
if (HasBoundProperty() || !generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk("float2 " + GetPropertyName() + ";", true); |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (HasBoundProperty() || generationMode.IsPreview()) |
|||
return; |
|||
|
|||
visitor.AddShaderChunk(precision + "2 " + GetPropertyName() + " = " + precision + "2 (" + m_Value.x + ", " + m_Value.y + ");", true); |
|||
} |
|||
|
|||
public override float GetNodeUIHeight(float width) |
|||
{ |
|||
return 2*EditorGUIUtility.singleLineHeight; |
|||
} |
|||
|
|||
public override bool NodeUI(Rect drawArea) |
|||
{ |
|||
base.NodeUI(drawArea); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
m_Value = EditorGUI.Vector2Field(new Rect(drawArea.x, drawArea.y, drawArea.width, EditorGUIUtility.singleLineHeight), "Value", m_Value); |
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
var boundProp = boundProperty as VectorProperty; |
|||
if (boundProp != null) |
|||
{ |
|||
boundProp.defaultVector = m_Value; |
|||
} |
|||
UpdatePreviewProperties(); |
|||
ForwardPreviewMaterialPropertyUpdate(); |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public override void BindProperty(ShaderProperty property, bool rebuildShaders) |
|||
{ |
|||
base.BindProperty(property, rebuildShaders); |
|||
|
|||
var vectorProp = property as VectorProperty; |
|||
if (vectorProp) |
|||
{ |
|||
m_Value = vectorProp.defaultVector; |
|||
} |
|||
|
|||
if (rebuildShaders) |
|||
RegeneratePreviewShaders(); |
|||
else |
|||
{ |
|||
UpdatePreviewProperties(); |
|||
ForwardPreviewMaterialPropertyUpdate(); |
|||
} |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = GetPropertyName(), |
|||
m_PropType = PropertyType.Vector2, |
|||
m_Vector4 = m_Value |
|||
}; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8361d1f9d12a489438c0b1e2e48c8542 |
|||
timeCreated: 1446473341 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue