浏览代码

Fix Matrix Transpose node

- Cleanup and fixes in matrix slots and props
/main
Matt Dean 7 年前
当前提交
3ad21797
共有 8 个文件被更改,包括 23 次插入50 次删除
  1. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix2MaterialSlot.cs
  2. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix2ShaderProperty.cs
  3. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix3MaterialSlot.cs
  4. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix3ShaderProperty.cs
  5. 6
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix4MaterialSlot.cs
  6. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix4ShaderProperty.cs
  7. 5
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MatrixShaderProperty.cs
  8. 20
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixTransposeNode.cs

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix2MaterialSlot.cs


namespace UnityEditor.ShaderGraph
{
[Serializable]
public class Matrix2MaterialSlot : MaterialSlot
public class Matrix2MaterialSlot : MaterialSlot, IMaterialSlotHasValue<Matrix4x4>
{
[SerializeField]
private Matrix4x4 m_Value;

var pp = new PreviewProperty(PropertyType.Matrix2)
{
name = name,
vector4Value = new Vector4(value.GetRow(0).x, value.GetRow(0).y, 0, 0),
floatValue = value.GetRow(0).x,
colorValue = new Vector4(value.GetRow(0).x, value.GetRow(0).x, 0, 0)
vector4Value = new Vector4(value.GetRow(0).x, value.GetRow(0).y, 0, 0)
};
return pp;
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix2ShaderProperty.cs


get { return PropertyType.Matrix2; }
}
public override Vector4 defaultValue
{
get { return new Vector4(); }
}
public override PreviewProperty GetPreviewMaterialProperty()
{
return default(PreviewProperty);
}
public override INode ToConcreteNode()
{
return new Matrix2Node

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix3MaterialSlot.cs


namespace UnityEditor.ShaderGraph
{
[Serializable]
public class Matrix3MaterialSlot : MaterialSlot
public class Matrix3MaterialSlot : MaterialSlot, IMaterialSlotHasValue<Matrix4x4>
{
[SerializeField]
private Matrix4x4 m_Value;

var pp = new PreviewProperty(PropertyType.Matrix3)
{
name = name,
vector4Value = new Vector4(value.GetRow(0).x, value.GetRow(0).y, value.GetRow(0).z, 0),
floatValue = value.GetRow(0).x,
colorValue = new Vector4(value.GetRow(0).x, value.GetRow(0).x, value.GetRow(0).z, 0)
vector4Value = new Vector4(value.GetRow(0).x, value.GetRow(0).y, value.GetRow(0).z, 0)
};
return pp;
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix3ShaderProperty.cs


get { return PropertyType.Matrix3; }
}
public override Vector4 defaultValue
{
get { return new Vector4(); }
}
public override PreviewProperty GetPreviewMaterialProperty()
{
return default(PreviewProperty);
}
public override INode ToConcreteNode()
{
return new Matrix3Node

6
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix4MaterialSlot.cs


namespace UnityEditor.ShaderGraph
{
[Serializable]
public class Matrix4MaterialSlot : MaterialSlot
public class Matrix4MaterialSlot : MaterialSlot, IMaterialSlotHasValue<Matrix4x4>
{
[SerializeField]
private Matrix4x4 m_Value;

var pp = new PreviewProperty(PropertyType.Matrix4)
{
name = name,
vector4Value = new Vector4(value.GetRow(0).x, value.GetRow(0).y, value.GetRow(0).z, value.GetRow(0).w),
floatValue = value.GetRow(0).x,
colorValue = new Vector4(value.GetRow(0).x, value.GetRow(0).x, value.GetRow(0).z, value.GetRow(0).w)
vector4Value = new Vector4(value.GetRow(0).x, value.GetRow(0).y, value.GetRow(0).z, value.GetRow(0).w)
};
return pp;
}

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/Matrix4ShaderProperty.cs


get { return PropertyType.Matrix4; }
}
public override Vector4 defaultValue
{
get { return new Vector4(); }
}
public override PreviewProperty GetPreviewMaterialProperty()
{
return default(PreviewProperty);
}
public override INode ToConcreteNode()
{
return new Matrix4Node

5
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Graphs/MatrixShaderProperty.cs


return string.Empty;
}
public override Vector4 defaultValue
{
get { return new Vector4(); }
}
public override string GetPropertyDeclarationString(string delimiter = ";")
{
return "float4x4 " + referenceName + ";";

20
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Math/Matrix/MatrixTransposeNode.cs


namespace UnityEditor.ShaderGraph
{
[Title("Math", "Matrix", "TransposeMatrix")]
[Title("Math", "Matrix", "Matrix Transpose")]
name = "TransposeMatrix";
name = "Matrix Transpose";
}
public override bool hasPreview
{
get { return false; }
return GetType().GetMethod("unity_MatrixTranspose_", BindingFlags.Static | BindingFlags.NonPublic);
return GetType().GetMethod("Unity_MatrixTranspose", BindingFlags.Static | BindingFlags.NonPublic);
static string unity_MatrixTranspose_(
[Slot(0, Binding.None)] Matrix4x4 inMatrix,
[Slot(1, Binding.None)] out Matrix4x4 outMatrix)
static string Unity_MatrixTranspose(
[Slot(0, Binding.None)] DynamicDimensionMatrix In,
[Slot(1, Binding.None)] out DynamicDimensionMatrix Out)
outMatrix = Matrix4x4.identity;
outMatrix = transpose(inMatrix);
Out = transpose(In);
}
";
}
正在加载...
取消
保存