Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IMayRequireTransform.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections.Generic;
  2. using UnityEditor.ShaderGraph.Internal;
  3. namespace UnityEditor.ShaderGraph
  4. {
  5. public struct NeededTransform
  6. {
  7. static Dictionary<UnityMatrixType, NeededTransform> s_TransformMap = new Dictionary<UnityMatrixType, NeededTransform>
  8. {
  9. {UnityMatrixType.Model, ObjectToWorld},
  10. {UnityMatrixType.InverseModel, WorldToObject},
  11. // TODO: Define the rest.
  12. {UnityMatrixType.View, None},
  13. {UnityMatrixType.InverseView, None},
  14. {UnityMatrixType.Projection, None},
  15. {UnityMatrixType.InverseProjection, None},
  16. {UnityMatrixType.ViewProjection, None},
  17. {UnityMatrixType.InverseViewProjection, None},
  18. };
  19. public static NeededTransform None => new NeededTransform(NeededCoordinateSpace.None, NeededCoordinateSpace.None);
  20. public static NeededTransform ObjectToWorld => new NeededTransform(NeededCoordinateSpace.Object, NeededCoordinateSpace.World);
  21. public static NeededTransform WorldToObject => new NeededTransform(NeededCoordinateSpace.World, NeededCoordinateSpace.Object);
  22. public NeededTransform(NeededCoordinateSpace from, NeededCoordinateSpace to)
  23. {
  24. this.from = from;
  25. this.to = to;
  26. }
  27. // Secondary constructor for certain nodes like TransformationMatrix.
  28. internal NeededTransform(UnityMatrixType matrix)
  29. {
  30. if (s_TransformMap.TryGetValue(matrix, out var transform))
  31. {
  32. from = transform.from;
  33. to = transform.to;
  34. }
  35. else
  36. {
  37. from = NeededCoordinateSpace.None;
  38. to = NeededCoordinateSpace.None;
  39. }
  40. }
  41. public NeededCoordinateSpace from;
  42. public NeededCoordinateSpace to;
  43. }
  44. interface IMayRequireTransform
  45. {
  46. NeededTransform[] RequiresTransform(ShaderStageCapability stageCapability = ShaderStageCapability.All);
  47. }
  48. }