Tim Cooper
7 年前
当前提交
0e092ee5
共有 4 个文件被更改,包括 0 次插入 和 255 次删除
-
115MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix2Node.cs.orig.meta
-
126MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig
-
7MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs.orig.meta
|
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/Matrix 2")] |
|||
public class Matrix2Node : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
const int kOutputSlotId = 0; |
|||
const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
Vector2 m_Row0; |
|||
|
|||
[SerializeField] |
|||
Vector2 m_Row1; |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector2 row0 |
|||
{ |
|||
get { return m_Row0; } |
|||
set { SetRow(ref m_Row0, value); } |
|||
} |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector2 row1 |
|||
{ |
|||
get { return m_Row1; } |
|||
set { SetRow(ref m_Row1, value); } |
|||
} |
|||
|
|||
void SetRow(ref Vector2 row, Vector2 value) |
|||
{ |
|||
if (value == row) |
|||
return; |
|||
row = value; |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
|
|||
public Matrix2Node() |
|||
{ |
|||
name = "Matrix2"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new Matrix2MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public string propertyName |
|||
{ |
|||
get |
|||
{ |
|||
return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); |
|||
} |
|||
} |
|||
|
|||
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 " + name + " = " + precision + "2x2 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row1.x + ", " + m_Row1.y + ");", true); |
|||
} |
|||
|
|||
[SerializeField] |
|||
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_Vector2 = m_Value |
|||
}; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 060d1826a682e4d4e9c45b4b4c93cb51 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEditor.MaterialGraph.Drawing.Controls; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/Matrix 3")] |
|||
public class Matrix3Node : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
const int kOutputSlotId = 0; |
|||
const string kOutputSlotName = "Value"; |
|||
|
|||
[SerializeField] |
|||
Vector3 m_Row0; |
|||
|
|||
[SerializeField] |
|||
Vector3 m_Row1; |
|||
|
|||
[SerializeField] |
|||
Vector3 m_Row2; |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector3 row0 |
|||
{ |
|||
get { return m_Row0; } |
|||
set { SetRow(ref m_Row0, value); } |
|||
} |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector3 row1 |
|||
{ |
|||
get { return m_Row1; } |
|||
set { SetRow(ref m_Row1, value); } |
|||
} |
|||
|
|||
[MultiFloatControl("", " ", " ", " ", " ")] |
|||
public Vector3 row2 |
|||
{ |
|||
get { return m_Row2; } |
|||
set { SetRow(ref m_Row2, value); } |
|||
} |
|||
|
|||
void SetRow(ref Vector3 row, Vector3 value) |
|||
{ |
|||
if (value == row) |
|||
return; |
|||
row = value; |
|||
if (onModified != null) |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
|
|||
public Matrix3Node() |
|||
{ |
|||
name = "Matrix3"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
<<<<<<< HEAD:MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Input/Matrix/Matrix3Node.cs |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix3, Vector3.zero)); |
|||
======= |
|||
AddSlot(new Matrix3MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output)); |
|||
>>>>>>> exposed-prop-subgraph:MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/Matrix3Node.cs |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public string propertyName |
|||
{ |
|||
get { return string.Format("{0}_{1}_Uniform", name, GetVariableNameForNode()); } |
|||
} |
|||
|
|||
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 " + propertyName + " = " + precision + "3x3 (" + m_Row0.x + ", " + m_Row0.y + ", " + m_Row0.z + ", " + m_Row1.x + ", " + m_Row1.y + ", " + m_Row1.z + ", " + m_Row2.x + ", " + m_Row2.y + ", " + m_Row2.z + ");", true); |
|||
} |
|||
|
|||
[SerializeField] |
|||
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_Vector3 = m_Value |
|||
}; |
|||
}*/ |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c8c352d3b6e0d8548ae31d044b0266a8 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue