Matrix2ShaderProperty.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using UnityEditor.Graphing;
  3. using UnityEditor.ShaderGraph.Internal;
  4. using UnityEngine;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. [Serializable]
  8. class Matrix2ShaderProperty : MatrixShaderProperty
  9. {
  10. public Matrix2ShaderProperty()
  11. {
  12. displayName = "Matrix2x2";
  13. value = Matrix4x4.identity;
  14. }
  15. public override PropertyType propertyType => PropertyType.Matrix2;
  16. internal override string GetPropertyAsArgumentString()
  17. {
  18. return $"{concretePrecision.ToShaderString()}2x2 {referenceName}";
  19. }
  20. internal override AbstractMaterialNode ToConcreteNode()
  21. {
  22. return new Matrix2Node
  23. {
  24. row0 = new Vector2(value.m00, value.m01),
  25. row1 = new Vector2(value.m10, value.m11)
  26. };
  27. }
  28. internal override PreviewProperty GetPreviewMaterialProperty()
  29. {
  30. return new PreviewProperty(propertyType)
  31. {
  32. name = referenceName,
  33. matrixValue = value
  34. };
  35. }
  36. internal override ShaderInput Copy()
  37. {
  38. return new Matrix2ShaderProperty()
  39. {
  40. displayName = displayName,
  41. hidden = hidden,
  42. value = value
  43. };
  44. }
  45. }
  46. }