initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
@ -0,0 +1,137 @@
|
|||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Matrix", "Matrix 2x2")]
|
||||
class Matrix2Node : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode
|
||||
{
|
||||
public const int OutputSlotId = 0;
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
[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;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
|
||||
public Matrix2Node()
|
||||
{
|
||||
name = "Matrix 2x2";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Matrix2MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
|
||||
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
|
||||
}
|
||||
|
||||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
return;
|
||||
|
||||
properties.AddShaderProperty(new Vector2ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m0", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row0
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector2ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m1", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row1
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
{
|
||||
sb.AppendLine("$precision2 _{0}_m0 = $precision2 ({1}, {2});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.y));
|
||||
sb.AppendLine("$precision2 _{0}_m1 = $precision2 ({1}, {2});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.y));
|
||||
}
|
||||
sb.AppendLine("$precision2x2 {0} = $precision2x2 (_{0}_m0.x, _{0}_m0.y, _{0}_m1.x, _{0}_m1.y);", GetVariableNameForNode());
|
||||
}
|
||||
|
||||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
|
||||
{
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector2)
|
||||
{
|
||||
name = string.Format("_{0}_m0", GetVariableNameForNode()),
|
||||
vector4Value = m_Row0
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector2)
|
||||
{
|
||||
name = string.Format("_{0}_m1", GetVariableNameForNode()),
|
||||
vector4Value = m_Row1
|
||||
});
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
return GetVariableNameForNode();
|
||||
}
|
||||
|
||||
public AbstractShaderProperty AsShaderProperty()
|
||||
{
|
||||
return new Matrix2ShaderProperty
|
||||
{
|
||||
value = new Matrix4x4()
|
||||
{
|
||||
m00 = row0.x,
|
||||
m01 = row0.y,
|
||||
m02 = 0,
|
||||
m03 = 0,
|
||||
m10 = row1.x,
|
||||
m11 = row1.y,
|
||||
m12 = 0,
|
||||
m13 = 0,
|
||||
m20 = 0,
|
||||
m21 = 0,
|
||||
m22 = 0,
|
||||
m23 = 0,
|
||||
m30 = 0,
|
||||
m31 = 0,
|
||||
m32 = 0,
|
||||
m33 = 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int outputSlotId { get { return OutputSlotId; } }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a01da6bf9ffa118478ae371b28d2e166
|
||||
timeCreated: 1446473341
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,166 @@
|
|||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Matrix", "Matrix 3x3")]
|
||||
class Matrix3Node : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode
|
||||
{
|
||||
public const int OutputSlotId = 0;
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
[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;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
|
||||
public Matrix3Node()
|
||||
{
|
||||
name = "Matrix 3x3";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Matrix3MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
|
||||
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
|
||||
}
|
||||
|
||||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
return;
|
||||
|
||||
properties.AddShaderProperty(new Vector3ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m0", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row0
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector3ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m1", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row1
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector3ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m2", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row2
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
{
|
||||
sb.AppendLine("$precision3 _{0}_m0 = $precision3 ({1}, {2}, {3});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.z));
|
||||
sb.AppendLine("$precision3 _{0}_m1 = $precision3 ({1}, {2}, {3});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.z));
|
||||
sb.AppendLine("$precision3 _{0}_m2 = $precision3 ({1}, {2}, {3});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.z));
|
||||
}
|
||||
sb.AppendLine("$precision3x3 {0} = $precision3x3 (_{0}_m0.x, _{0}_m0.y, _{0}_m0.z, _{0}_m1.x, _{0}_m1.y, _{0}_m1.z, _{0}_m2.x, _{0}_m2.y, _{0}_m2.z);", GetVariableNameForNode());
|
||||
}
|
||||
|
||||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
|
||||
{
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector3)
|
||||
{
|
||||
name = string.Format("_{0}_m0", GetVariableNameForNode()),
|
||||
vector4Value = m_Row0
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector3)
|
||||
{
|
||||
name = string.Format("_{0}_m1", GetVariableNameForNode()),
|
||||
vector4Value = m_Row1
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector3)
|
||||
{
|
||||
name = string.Format("_{0}_m2", GetVariableNameForNode()),
|
||||
vector4Value = m_Row2
|
||||
});
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
return GetVariableNameForNode();
|
||||
}
|
||||
|
||||
public AbstractShaderProperty AsShaderProperty()
|
||||
{
|
||||
return new Matrix3ShaderProperty
|
||||
{
|
||||
value = new Matrix4x4()
|
||||
{
|
||||
m00 = row0.x,
|
||||
m01 = row0.y,
|
||||
m02 = row0.z,
|
||||
m03 = 0,
|
||||
m10 = row1.x,
|
||||
m11 = row1.y,
|
||||
m12 = row1.z,
|
||||
m13 = 0,
|
||||
m20 = row2.x,
|
||||
m21 = row2.y,
|
||||
m22 = row2.z,
|
||||
m23 = 0,
|
||||
m30 = 0,
|
||||
m31 = 0,
|
||||
m32 = 0,
|
||||
m33 = 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int outputSlotId { get { return OutputSlotId; } }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fec4ad06a8bd71044af822b7d2258a69
|
||||
timeCreated: 1446473341
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,198 @@
|
|||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Graphing;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.ShaderGraph.Internal;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
[Title("Input", "Matrix", "Matrix 4x4")]
|
||||
class Matrix4Node : AbstractMaterialNode, IGeneratesBodyCode, IPropertyFromNode
|
||||
{
|
||||
public const int OutputSlotId = 0;
|
||||
const string kOutputSlotName = "Out";
|
||||
|
||||
[SerializeField]
|
||||
Vector4 m_Row0;
|
||||
|
||||
[SerializeField]
|
||||
Vector4 m_Row1;
|
||||
|
||||
[SerializeField]
|
||||
Vector4 m_Row2;
|
||||
|
||||
[SerializeField]
|
||||
Vector4 m_Row3;
|
||||
|
||||
[MultiFloatControl("", " ", " ", " ", " ")]
|
||||
public Vector4 row0
|
||||
{
|
||||
get { return m_Row0; }
|
||||
set { SetRow(ref m_Row0, value); }
|
||||
}
|
||||
|
||||
[MultiFloatControl("", " ", " ", " ", " ")]
|
||||
public Vector4 row1
|
||||
{
|
||||
get { return m_Row1; }
|
||||
set { SetRow(ref m_Row1, value); }
|
||||
}
|
||||
|
||||
[MultiFloatControl("", " ", " ", " ", " ")]
|
||||
public Vector4 row2
|
||||
{
|
||||
get { return m_Row2; }
|
||||
set { SetRow(ref m_Row2, value); }
|
||||
}
|
||||
|
||||
[MultiFloatControl("", " ", " ", " ", " ")]
|
||||
public Vector4 row3
|
||||
{
|
||||
get { return m_Row3; }
|
||||
set { SetRow(ref m_Row3, value); }
|
||||
}
|
||||
|
||||
void SetRow(ref Vector4 row, Vector4 value)
|
||||
{
|
||||
if (value == row)
|
||||
return;
|
||||
row = value;
|
||||
Dirty(ModificationScope.Node);
|
||||
}
|
||||
|
||||
public Matrix4Node()
|
||||
{
|
||||
name = "Matrix 4x4";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
AddSlot(new Matrix4MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
|
||||
RemoveSlotsNameNotMatching(new[] { OutputSlotId });
|
||||
}
|
||||
|
||||
public override void CollectShaderProperties(PropertyCollector properties, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
return;
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m0", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row0
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m1", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row1
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m2", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row2
|
||||
});
|
||||
|
||||
properties.AddShaderProperty(new Vector4ShaderProperty()
|
||||
{
|
||||
overrideReferenceName = string.Format("_{0}_m3", GetVariableNameForNode()),
|
||||
generatePropertyBlock = false,
|
||||
value = m_Row3
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
|
||||
{
|
||||
if (!generationMode.IsPreview())
|
||||
{
|
||||
sb.AppendLine("$precision4 _{0}_m0 = $precision4 ({1}, {2}, {3}, {4});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.z),
|
||||
NodeUtils.FloatToShaderValue(m_Row0.w));
|
||||
sb.AppendLine("$precision4 _{0}_m1 = $precision4 ({1}, {2}, {3}, {4});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.z),
|
||||
NodeUtils.FloatToShaderValue(m_Row1.w));
|
||||
sb.AppendLine("$precision4 _{0}_m2 = $precision4 ({1}, {2}, {3}, {4});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.z),
|
||||
NodeUtils.FloatToShaderValue(m_Row2.w));
|
||||
sb.AppendLine("$precision4 _{0}_m3 = $precision4 ({1}, {2}, {3}, {4});", GetVariableNameForNode(),
|
||||
NodeUtils.FloatToShaderValue(m_Row3.x),
|
||||
NodeUtils.FloatToShaderValue(m_Row3.y),
|
||||
NodeUtils.FloatToShaderValue(m_Row3.z),
|
||||
NodeUtils.FloatToShaderValue(m_Row3.w));
|
||||
}
|
||||
sb.AppendLine("$precision4x4 {0} = $precision4x4 (_{0}_m0.x, _{0}_m0.y, _{0}_m0.z, _{0}_m0.w, _{0}_m1.x, _{0}_m1.y, _{0}_m1.z, _{0}_m1.w, _{0}_m2.x, _{0}_m2.y, _{0}_m2.z, _{0}_m2.w, _{0}_m3.x, _{0}_m3.y, _{0}_m3.z, _{0}_m3.w);",
|
||||
GetVariableNameForNode());
|
||||
}
|
||||
|
||||
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
|
||||
{
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector4)
|
||||
{
|
||||
name = string.Format("_{0}_m0", GetVariableNameForNode()),
|
||||
vector4Value = m_Row0
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector4)
|
||||
{
|
||||
name = string.Format("_{0}_m1", GetVariableNameForNode()),
|
||||
vector4Value = m_Row1
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector4)
|
||||
{
|
||||
name = string.Format("_{0}_m2", GetVariableNameForNode()),
|
||||
vector4Value = m_Row2
|
||||
});
|
||||
|
||||
properties.Add(new PreviewProperty(PropertyType.Vector4)
|
||||
{
|
||||
name = string.Format("_{0}_m3", GetVariableNameForNode()),
|
||||
vector4Value = m_Row3
|
||||
});
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
return GetVariableNameForNode();
|
||||
}
|
||||
|
||||
public AbstractShaderProperty AsShaderProperty()
|
||||
{
|
||||
return new Matrix4ShaderProperty
|
||||
{
|
||||
value = new Matrix4x4()
|
||||
{
|
||||
m00 = row0.x,
|
||||
m01 = row0.y,
|
||||
m02 = row0.z,
|
||||
m03 = row0.w,
|
||||
m10 = row1.x,
|
||||
m11 = row1.y,
|
||||
m12 = row1.z,
|
||||
m13 = row1.w,
|
||||
m20 = row2.x,
|
||||
m21 = row2.y,
|
||||
m22 = row2.z,
|
||||
m23 = row2.w,
|
||||
m30 = row3.x,
|
||||
m31 = row3.y,
|
||||
m32 = row3.z,
|
||||
m33 = row3.w,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public int outputSlotId { get { return OutputSlotId; } }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d3889ae2c6ffabd40a2ee45f5b051d3b
|
||||
timeCreated: 1446473341
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,119 @@
|
|||
using UnityEditor.Graphing;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using UnityEditor.ShaderGraph.Drawing.Controls;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.ShaderGraph
|
||||
{
|
||||
enum TransformationMatrixType
|
||||
{
|
||||
None = -1,
|
||||
ModelView,
|
||||
View,
|
||||
Projection,
|
||||
ViewProjection,
|
||||
TransposeModelView,
|
||||
InverseTransposeModelView,
|
||||
ObjectToWorld,
|
||||
WorldToObject
|
||||
};
|
||||
|
||||
internal enum UnityMatrixType
|
||||
{
|
||||
Model,
|
||||
InverseModel,
|
||||
View,
|
||||
InverseView,
|
||||
Projection,
|
||||
InverseProjection,
|
||||
ViewProjection,
|
||||
InverseViewProjection
|
||||
}
|
||||
|
||||
[Title("Input", "Matrix", "Transformation Matrix")]
|
||||
class TransformationMatrixNode : AbstractMaterialNode, IMayRequireTransform
|
||||
{
|
||||
static Dictionary<UnityMatrixType, string> m_MatrixList = new Dictionary<UnityMatrixType, string>
|
||||
{
|
||||
{UnityMatrixType.Model, "UNITY_MATRIX_M"},
|
||||
{UnityMatrixType.InverseModel, "UNITY_MATRIX_I_M"},
|
||||
{UnityMatrixType.View, "UNITY_MATRIX_V"},
|
||||
{UnityMatrixType.InverseView, "UNITY_MATRIX_I_V"},
|
||||
{UnityMatrixType.Projection, "UNITY_MATRIX_P"},
|
||||
{UnityMatrixType.InverseProjection, "UNITY_MATRIX_I_P"},
|
||||
{UnityMatrixType.ViewProjection, "UNITY_MATRIX_VP"},
|
||||
{UnityMatrixType.InverseViewProjection, "UNITY_MATRIX_I_VP"},
|
||||
};
|
||||
|
||||
static Dictionary<TransformationMatrixType, UnityMatrixType> m_MatrixUpgrade = new Dictionary<TransformationMatrixType, UnityMatrixType>
|
||||
{
|
||||
{TransformationMatrixType.ModelView, UnityMatrixType.Model},
|
||||
{TransformationMatrixType.View, UnityMatrixType.View},
|
||||
{TransformationMatrixType.Projection, UnityMatrixType.Projection},
|
||||
{TransformationMatrixType.ViewProjection, UnityMatrixType.ViewProjection},
|
||||
{TransformationMatrixType.TransposeModelView, UnityMatrixType.Model},
|
||||
{TransformationMatrixType.InverseTransposeModelView, UnityMatrixType.Model},
|
||||
{TransformationMatrixType.ObjectToWorld, UnityMatrixType.Model},
|
||||
{TransformationMatrixType.WorldToObject, UnityMatrixType.InverseModel},
|
||||
};
|
||||
|
||||
[SerializeField]
|
||||
private TransformationMatrixType m_matrix = TransformationMatrixType.ModelView;
|
||||
|
||||
[SerializeField]
|
||||
private UnityMatrixType m_MatrixType = UnityMatrixType.Model;
|
||||
|
||||
private const int kOutputSlotId = 0;
|
||||
private const string kOutputSlotName = "Out";
|
||||
|
||||
public override bool hasPreview { get { return false; } }
|
||||
|
||||
[EnumControl("")]
|
||||
public UnityMatrixType matrixType
|
||||
{
|
||||
get { return m_MatrixType; }
|
||||
set
|
||||
{
|
||||
if (m_MatrixType == value)
|
||||
return;
|
||||
|
||||
m_MatrixType = value;
|
||||
Dirty(ModificationScope.Graph);
|
||||
}
|
||||
}
|
||||
|
||||
public TransformationMatrixNode()
|
||||
{
|
||||
name = "Transformation Matrix";
|
||||
UpdateNodeAfterDeserialization();
|
||||
}
|
||||
|
||||
public sealed override void UpdateNodeAfterDeserialization()
|
||||
{
|
||||
if (m_matrix != TransformationMatrixType.None)
|
||||
{
|
||||
m_MatrixType = m_MatrixUpgrade[m_matrix];
|
||||
m_matrix = TransformationMatrixType.None;
|
||||
}
|
||||
|
||||
AddSlot(new Matrix4MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output));
|
||||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId });
|
||||
}
|
||||
|
||||
public override string GetVariableNameForSlot(int slotId)
|
||||
{
|
||||
return m_MatrixList[matrixType].ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public bool RequiresVertexColor()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability = ShaderStageCapability.All)
|
||||
{
|
||||
return new[] { new NeededTransform(matrixType) };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 080829bc2938e23489292a936367364d
|
||||
timeCreated: 1481123160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue