Step.hx 677 B

1234567891011121314151617181920212223242526272829
  1. package hrt.shgraph.nodes;
  2. using hxsl.Ast;
  3. @name("Step")
  4. @description("Generate a step function by comparing a[i] to edge[i]")
  5. @width(80)
  6. @group("Math")
  7. class Step extends ShaderFunction {
  8. @input("Edge") var edge = SType.Number;
  9. @input("A") var x = SType.Number;
  10. public function new() {
  11. super(Step);
  12. }
  13. override public function computeOutputs() {
  14. if (x != null && !x.isEmpty() && edge != null && !edge.isEmpty())
  15. addOutput("output", edge.getVar(x.getType()).t);
  16. else if (x != null && !x.isEmpty() )
  17. addOutput("output", x.getType());
  18. else if (edge != null && !edge.isEmpty())
  19. addOutput("output", edge.getType());
  20. else
  21. removeOutput("output");
  22. }
  23. }