Matrix4ShaderProperty.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using UnityEngine;
  3. using UnityEditor.Graphing;
  4. using UnityEditor.ShaderGraph.Internal;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. [Serializable]
  8. class Matrix4ShaderProperty : MatrixShaderProperty
  9. {
  10. public Matrix4ShaderProperty()
  11. {
  12. displayName = "Matrix4x4";
  13. value = Matrix4x4.identity;
  14. }
  15. internal override bool isGpuInstanceable => true;
  16. public override PropertyType propertyType => PropertyType.Matrix4;
  17. internal override AbstractMaterialNode ToConcreteNode()
  18. {
  19. return new Matrix4Node
  20. {
  21. row0 = new Vector4(value.m00, value.m01, value.m02, value.m03),
  22. row1 = new Vector4(value.m10, value.m11, value.m12, value.m13),
  23. row2 = new Vector4(value.m20, value.m21, value.m22, value.m23),
  24. row3 = new Vector4(value.m30, value.m31, value.m32, value.m33)
  25. };
  26. }
  27. internal override PreviewProperty GetPreviewMaterialProperty()
  28. {
  29. return new PreviewProperty(propertyType)
  30. {
  31. name = referenceName,
  32. matrixValue = value
  33. };
  34. }
  35. internal override ShaderInput Copy()
  36. {
  37. return new Matrix4ShaderProperty()
  38. {
  39. displayName = displayName,
  40. hidden = hidden,
  41. value = value
  42. };
  43. }
  44. }
  45. }