Matt Dean
8 年前
当前提交
c7fbf38f
共有 15 个文件被更改,包括 395 次插入 和 1 次删除
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
18MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
21MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
-
5MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SlotValue.cs
-
40MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix2NodePresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix2NodePresenter.cs.meta
-
41MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix3NodePresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/Matrix3NodePresenter.cs.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix.meta
-
103MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix2Node.cs.meta
-
103MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
class Matrix2ControlPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var tNode = node as UnityEngine.MaterialGraph.Matrix2Node; |
|||
if (tNode == null) |
|||
return; |
|||
|
|||
tNode[0] = EditorGUILayout.Vector2Field("", tNode[0]); |
|||
tNode[1] = EditorGUILayout.Vector2Field("", tNode[1]); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return (EditorGUIUtility.singleLineHeight * 2 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class Matrix2NodePresenter : PropertyNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<Matrix2ControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter>(base.GetControlData()) { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7a56e192798ff9a45a01f10c9113e539 |
|||
timeCreated: 1476871291 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
class Matrix3ControlPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var tNode = node as UnityEngine.MaterialGraph.Matrix3Node; |
|||
if (tNode == null) |
|||
return; |
|||
|
|||
tNode[0] = EditorGUILayout.Vector3Field("", tNode[0]); |
|||
tNode[1] = EditorGUILayout.Vector3Field("", tNode[1]); |
|||
tNode[2] = EditorGUILayout.Vector3Field("", tNode[2]); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return (EditorGUIUtility.singleLineHeight * 3 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class Matrix3NodePresenter : PropertyNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<Matrix3ControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter>(base.GetControlData()) { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8cb077290891de74d905d2361f73441b |
|||
timeCreated: 1476871291 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 278936628273864438e48ff64aa20e32 |
|||
folderAsset: yes |
|||
timeCreated: 1495662409 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/Matrix 2")] |
|||
public class Matrix2Node : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
private Vector2[] m_Value = new Vector2[2]; |
|||
|
|||
public Vector2 this[int index] |
|||
{ |
|||
get { return m_Value[index]; } |
|||
set |
|||
{ |
|||
if (m_Value[index] == value) |
|||
return; |
|||
|
|||
m_Value[index] = value; |
|||
|
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
} |
|||
|
|||
public Matrix2Node() |
|||
{ |
|||
name = "Matrix2"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix2, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public string propertyName |
|||
{ |
|||
get |
|||
{ |
|||
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_")); |
|||
} |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return propertyName; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
|
|||
// return;
|
|||
|
|||
visitor.AddShaderChunk(precision + "2 " + propertyName + " = " + precision + "2x2 (" + precision + "2(" + m_Value[0].x + ", " + m_Value[0].y + "), " + precision + "2(" + m_Value[1].x + ", " + m_Value[1].y + "))", true); |
|||
} |
|||
|
|||
[SerializeField] |
|||
private string m_Description = string.Empty; |
|||
|
|||
public string description |
|||
{ |
|||
get |
|||
{ |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
} |
|||
set { m_Description = value; } |
|||
} |
|||
|
|||
// TODO - Remove Property entries everywhere?
|
|||
// Matrix cant be a shader property
|
|||
/*public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Matrix2; } |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed) |
|||
visitor.AddShaderProperty(new VectorPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible)); |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
visitor.AddShaderChunk(precision + "2 " + propertyName + ";", true); |
|||
}*/ |
|||
|
|||
/*public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Vector2, |
|||
m_Vector4 = m_Value |
|||
}; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a01da6bf9ffa118478ae371b28d2e166 |
|||
timeCreated: 1446473341 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/Matrix 3")] |
|||
public class Matrix3Node : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
private Vector3[] m_Value = new Vector3[3]; |
|||
|
|||
public Vector3 this[int index] |
|||
{ |
|||
get { return m_Value[index]; } |
|||
set |
|||
{ |
|||
if (m_Value[index] == value) |
|||
return; |
|||
|
|||
m_Value[index] = value; |
|||
|
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
} |
|||
|
|||
public Matrix3Node() |
|||
{ |
|||
name = "Matrix3"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public string propertyName |
|||
{ |
|||
get |
|||
{ |
|||
return string.Format("{0}_{1}_Uniform", name, guid.ToString().Replace("-", "_")); |
|||
} |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return propertyName; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
//if (exposedState == ExposedState.Exposed || generationMode.IsPreview())
|
|||
// return;
|
|||
|
|||
visitor.AddShaderChunk(precision + "3x3 (" + precision + "3(" + m_Value[0].x + ", " + m_Value[0].y + ", " + m_Value[0].z + "), " + precision + "3(" + m_Value[1].x + ", " + m_Value[1].y + ", " + m_Value[1].z + "), " + precision + "3(" + m_Value[2].x + ", " + m_Value[2].y + ", " + m_Value[2].z + "))", true); |
|||
} |
|||
|
|||
[SerializeField] |
|||
private string m_Description = string.Empty; |
|||
|
|||
public string description |
|||
{ |
|||
get |
|||
{ |
|||
return string.IsNullOrEmpty(m_Description) ? name : m_Description; |
|||
} |
|||
set { m_Description = value; } |
|||
} |
|||
|
|||
// TODO - Remove Property entries everywhere?
|
|||
// Matrix cant be a shader property
|
|||
/*public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.Matrix2; } |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed) |
|||
visitor.AddShaderProperty(new VectorPropertyChunk(propertyName, description, m_Value, PropertyChunk.HideState.Visible)); |
|||
}*/ |
|||
|
|||
/*public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
if (exposedState == ExposedState.Exposed || generationMode.IsPreview()) |
|||
visitor.AddShaderChunk(precision + "2 " + propertyName + ";", true); |
|||
}*/ |
|||
|
|||
/*public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Vector2, |
|||
m_Vector4 = m_Value |
|||
}; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fec4ad06a8bd71044af822b7d2258a69 |
|||
timeCreated: 1446473341 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue