compositor for 2d shader
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. class BRIGHTER extends Shader {
  2. BRIGHTER() {
  3. name = "fxBRIGHTER";
  4. params.add(new Param("mode", 2, new int[]{RANDOM}));
  5. params.add(new Param("thresh", 60, 180, new int[]{SIN, LINE, RAMPUPDOWN, TAN, COS}));
  6. params.add(new Param("thresh2", 120, 200, new int[]{SIN, LINE, RAMPUPDOWN, TAN, COS}));
  7. params.add(new Param("brighten", 140, 220, new int[]{SIN, LINE, RAMPUPDOWN, TAN, COS}));
  8. /*
  9. params.add(new Param("mode", 2));
  10. params.add(new Param("thresh", 60, 180));
  11. params.add(new Param("thresh2", 120, 200));
  12. params.add(new Param("brighten", 140, 220));*/
  13. }
  14. /*
  15. float inc1, inc2, inc3;
  16. float speed;
  17. void animate() {
  18. inc1+=(speed + .006);
  19. inc2+=(speed + .0045);
  20. inc3+=(speed + .002);
  21. //gui.brickP5.getController("knobOne-"+str(brick)).setValue(int(map(sin(inc1), 2, -1, 0, 255)));
  22. //gui.brickP5.getController("knobTwo-"+str(brick)).setValue(int(map(cos(inc2), -1, 1, 0, 255)));
  23. //if (mode == 0) {
  24. // gui.brickP5.getController("knobThree-"+str(brick)).setValue(int(map(cos(inc2), -1, 1, 0, int(map(cos(inc2), -1, 1, 0, 255)))));
  25. //} else if (mode == 1) {
  26. // gui.brickP5.getController("knobThree-"+str(brick)).setValue(int(map(cos(inc2), -1, 1, int(map(cos(inc2), -1, 1, 0, 255)), 255 )));
  27. //}
  28. if (random(1) > .99) {
  29. for (int i = 0; i < params.size(); i++)
  30. params.get(i).randomize();
  31. }
  32. }
  33. */
  34. void apply() {
  35. int mode = (int)params.get(0).value;
  36. float brighten = params.get(1).value;
  37. float thresh = params.get(2).value;
  38. float thresh2 = params.get(3).value;
  39. renderer.beginDraw();
  40. renderer.colorMode(HSB);
  41. colorMode(HSB);
  42. renderer.loadPixels();
  43. if (mode == 0) {
  44. for (int i = 0; i < renderer.width*renderer.height; i++) {
  45. float hue = hue(renderer.pixels[i]);
  46. float sat = saturation(renderer.pixels[i]);
  47. float bright = brightness(renderer.pixels[i]);
  48. if (bright < thresh && bright > thresh2) {
  49. bright += brighten;
  50. constrain(bright, 0, 255);
  51. }
  52. color c = color(hue, sat, bright);
  53. renderer.pixels[i] = c;
  54. }
  55. } else if (mode == 1) {
  56. for (int i = 0; i < renderer.width*renderer.height; i++) {
  57. float hue = hue(renderer.pixels[i]);
  58. float sat = saturation(renderer.pixels[i]);
  59. float bright = brightness(renderer.pixels[i]);
  60. if (bright > thresh && bright < thresh2) {
  61. bright += brighten;
  62. constrain(bright, 0, 255);
  63. }
  64. color c = color(hue, sat, bright);
  65. renderer.pixels[i] = c;
  66. }
  67. }
  68. renderer.updatePixels();
  69. renderer.colorMode(RGB);
  70. colorMode(RGB);
  71. renderer.endDraw();
  72. }
  73. }