Blur.hx 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package hrt.texgraph.nodes;
  2. @name("Blur")
  3. @description("Blur texture")
  4. @width(100)
  5. @group("Operation")
  6. class Blur extends TexNode {
  7. var inputs = [
  8. { name : "input1", type: h3d.mat.Texture }
  9. ];
  10. var outputs = [
  11. { name : "output", type: h3d.mat.Texture }
  12. ];
  13. @prop var radius : Float = 10;
  14. override function apply(vars : Dynamic) : Array<h3d.mat.Texture> {
  15. var out = createTexture();
  16. var blurPass = new h3d.pass.Blur(radius);
  17. blurPass.apply(ctx, cast getInputData(vars, 0), out);
  18. return [ out ];
  19. }
  20. #if editor
  21. override function getSpecificParametersHTML() {
  22. var el = new hide.Element('
  23. <div class="fields">
  24. <label>Radius</label>
  25. <input type="range" id="radius"/>
  26. </div>');
  27. var radiusEl = el.find("#radius");
  28. radiusEl.val(radius);
  29. radiusEl.on("mousemove", function(e) {
  30. this.radius = Std.parseFloat(radiusEl.val());
  31. var substanceEditor = Std.downcast(editor.editor, hide.view.textureeditor.TextureEditor);
  32. substanceEditor.generate();
  33. });
  34. return el;
  35. }
  36. #end
  37. }