InverseLerpNode.cs 875 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Reflection;
  2. namespace UnityEditor.ShaderGraph
  3. {
  4. [Title("Math", "Interpolation", "Inverse Lerp")]
  5. class InverseLerpNode : CodeFunctionNode
  6. {
  7. public InverseLerpNode()
  8. {
  9. name = "Inverse Lerp";
  10. }
  11. protected override MethodInfo GetFunctionToConvert()
  12. {
  13. return GetType().GetMethod("Unity_InverseLerp", BindingFlags.Static | BindingFlags.NonPublic);
  14. }
  15. static string Unity_InverseLerp(
  16. [Slot(0, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector A,
  17. [Slot(1, Binding.None, 1, 1, 1, 1)] DynamicDimensionVector B,
  18. [Slot(2, Binding.None, 0, 0, 0, 0)] DynamicDimensionVector T,
  19. [Slot(3, Binding.None)] out DynamicDimensionVector Out)
  20. {
  21. return
  22. @"
  23. {
  24. Out = (T - A)/(B - A);
  25. }";
  26. }
  27. }
  28. }