Matrix3ShaderProperty.cs 1.4 KB

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