Multiply.hx 1010 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package hrt.texgraph.nodes;
  2. class MultiplyShader extends h3d.shader.ScreenShader {
  3. static var SRC = {
  4. @param var tex1 : Sampler2D;
  5. @param var tex2 : Sampler2D;
  6. function fragment() {
  7. pixelColor = tex1.get(calculatedUV) * tex2.get(calculatedUV);
  8. }
  9. }
  10. }
  11. @name("Multiply")
  12. @description("The output is the result of the inputs multiplied")
  13. @width(80)
  14. @group("Operation")
  15. class Multiply extends TexNode {
  16. var inputs = [
  17. { name : "input1", type: h3d.mat.Texture },
  18. { name : "input2", type: h3d.mat.Texture },
  19. ];
  20. var outputs = [
  21. { name : "output", type: h3d.mat.Texture }
  22. ];
  23. override function apply(vars : Dynamic) : Array<h3d.mat.Texture> {
  24. var engine = h3d.Engine.getCurrent();
  25. var out = createTexture();
  26. var shader = new MultiplyShader();
  27. shader.tex1 = cast getInputData(vars, 0);
  28. shader.tex2 = cast getInputData(vars , 1);
  29. var pass = new h3d.pass.ScreenFx(shader);
  30. engine.pushTarget(out);
  31. pass.render();
  32. engine.popTarget();
  33. return [ out ];
  34. }
  35. }