Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Matrix4ShaderProperty.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using UnityEngine;
  3. using UnityEditor.Graphing;
  4. using UnityEditor.ShaderGraph.Internal;
  5. namespace UnityEditor.ShaderGraph
  6. {
  7. [Serializable]
  8. [BlackboardInputInfo(72)]
  9. class Matrix4ShaderProperty : MatrixShaderProperty
  10. {
  11. public Matrix4ShaderProperty()
  12. {
  13. displayName = "Matrix4x4";
  14. value = Matrix4x4.identity;
  15. }
  16. public override PropertyType propertyType => PropertyType.Matrix4;
  17. internal override string GetPropertyAsArgumentString(string precisionString)
  18. {
  19. return $"{precisionString}4x4 {referenceName}";
  20. }
  21. internal override AbstractMaterialNode ToConcreteNode()
  22. {
  23. return new Matrix4Node
  24. {
  25. row0 = new Vector4(value.m00, value.m01, value.m02, value.m03),
  26. row1 = new Vector4(value.m10, value.m11, value.m12, value.m13),
  27. row2 = new Vector4(value.m20, value.m21, value.m22, value.m23),
  28. row3 = new Vector4(value.m30, value.m31, value.m32, value.m33)
  29. };
  30. }
  31. internal override PreviewProperty GetPreviewMaterialProperty()
  32. {
  33. return new PreviewProperty(propertyType)
  34. {
  35. name = referenceName,
  36. matrixValue = value
  37. };
  38. }
  39. internal override ShaderInput Copy()
  40. {
  41. return new Matrix4ShaderProperty()
  42. {
  43. displayName = displayName,
  44. value = value,
  45. };
  46. }
  47. public override int latestVersion => 1;
  48. public override void OnAfterDeserialize(string json)
  49. {
  50. if (sgVersion == 0)
  51. {
  52. // all old matrices were declared global; yes even if flagged hybrid!
  53. // maintain old behavior on versioning, users can always change the override if they wish
  54. overrideHLSLDeclaration = true;
  55. hlslDeclarationOverride = HLSLDeclaration.Global;
  56. ChangeVersion(1);
  57. }
  58. }
  59. }
  60. }