SmoothStep.hx 703 B

123456789101112131415161718192021222324252627282930
  1. package hrt.shgraph.nodes;
  2. using hxsl.Ast;
  3. @name("Smooth Step")
  4. @description("Linear interpolation between A and B using Mix")
  5. @width(100)
  6. @group("Math")
  7. class SmoothStep extends ShaderFunction {
  8. @input("A") var x = SType.Number;
  9. @input("B") var y = SType.Number;
  10. @input("Mix") var a = SType.Number;
  11. public function new() {
  12. super(Smoothstep);
  13. }
  14. override public function computeOutputs() {
  15. if (x != null && !x.isEmpty() && y != null && !y.isEmpty())
  16. addOutput("output", x.getVar(y.getType()).t);
  17. else if (x != null && !x.isEmpty() )
  18. addOutput("output", x.getType());
  19. else if (y != null && !y.isEmpty())
  20. addOutput("output", y.getType());
  21. else
  22. removeOutput("output");
  23. }
  24. }