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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. void mousePressed()
  2. {
  3. if (mouseButton == LEFT) {
  4. if (sourceManager.dir != null) {
  5. sourceManager.importURI(sourceManager.dir + "/" + sourceManager.selection[(int)random(sourceManager.selection.length)]);
  6. }
  7. }
  8. if (mouseButton == RIGHT) {
  9. snapshot();
  10. }
  11. }
  12. boolean videoRecord;
  13. void mouseWheel(MouseEvent event) {
  14. if (event.getCount() < 0) renderSize += 8;
  15. else renderSize -= 8;
  16. renderSize = constrain(renderSize, 8, 15000);
  17. println("Render size: " + renderSize);
  18. }
  19. String[] params;
  20. void keyPressed() {
  21. if (key == 'c') {
  22. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new DARKER());
  23. }
  24. if (key == 'r') {
  25. for (int i = 0; i < fxManager.fxList.size(); i ++) {
  26. for (int j = 0; j < fxManager.fxList.get(i).shader.params.size(); j++) {
  27. fxManager.fxList.get(i).shader.params.get(j).randomize();
  28. }
  29. }
  30. }
  31. if (key == 'x') {
  32. videoRecord = !videoRecord;
  33. if (videoRecord) {
  34. println("Started video recording");
  35. videoExport = new VideoExport(this, "data/videos/" + str(frameCount + int(uptime)) + ".mp4", renderer);
  36. //String[] settings = {"[ffmpeg]","-y","-f","rawvideo","-vcodec","rawvideo","-s",str(renderer.width)+"x"+str(renderer.height),};
  37. videoExport.setFrameRate(frameRate);
  38. videoExport.setQuality(100, 0); // (crf, audiobitrate)
  39. String videoSize = str(renderer.width)+"x"+str(renderer.height);
  40. videoExport.setFfmpegVideoSettings(
  41. new String[]{
  42. "[ffmpeg]", // ffmpeg executable
  43. "-y", // overwrite old file
  44. "-f", "rawvideo", // format rgb raw
  45. "-vcodec", "rawvideo", // in codec rgb raw
  46. "-s", videoSize, // size
  47. "-pix_fmt", "rgb24", // pix format rgb24
  48. "-r", "[fps]", // frame rate
  49. "-i", "-", // pipe input
  50. //"-vf", "scale="+str(renderer.width)+":"+str(renderer.height)+":force_original_aspect_ratio=decrease",
  51. "-an", // no audio
  52. "-vcodec", "h264", // out codec h264
  53. "-pix_fmt", "yuv420p", // color space yuv420p
  54. "-crf", "[crf]", // quality
  55. "-metadata", "comment=[comment]", // comment
  56. "[output]" // output file
  57. });
  58. videoExport.setDebugging(true);
  59. videoExport.startMovie();
  60. } else {
  61. println("Ended video recording");
  62. videoExport.endMovie();
  63. videoExport.dispose();
  64. }
  65. }
  66. if (key == 'f') {
  67. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new FM());
  68. }
  69. if (key == 'j') {
  70. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new DRAWSTROKES());
  71. }
  72. if (key == 'h') {
  73. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new DRAWGENERATIVE());
  74. }
  75. if (key == 'd') {
  76. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new ASDFPIXELSORT());
  77. }
  78. if (key == 'b') {
  79. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new BRIGHTER());
  80. }
  81. if (key == 'e') {
  82. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new DISTORTER());
  83. }
  84. if (key == 'w') {
  85. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new WZIP());
  86. }
  87. if (key == 'g') {
  88. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new GRAUZONE());
  89. }
  90. if (key == 'q') {
  91. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new SLITSCAN());
  92. }
  93. if (key == ' ') {
  94. }
  95. if (key == 'o') {
  96. renderSize = 10000;
  97. }
  98. if (key == '1') {
  99. mode = 0;
  100. }
  101. if (key == '2') {
  102. if (mode != 1) sourceManager.fallback();
  103. mode = 1;
  104. }
  105. if (keyCode == KeyEvent.VK_F10) {
  106. airisRender(5000); //15000 would be fine as well i guess
  107. }
  108. if (key == 'a') {
  109. if (fxManager.fxList.size() < maxFx) fxManager.addFx(new AUECHO());
  110. }
  111. if (key == 'v') {
  112. fxManager.removeFx(fxManager.fxList.size()-1); //remove last in arraylist
  113. // fxManager.removeFx(2); //remove at position in arraylist
  114. }
  115. /* if (key == 'a') {
  116. params = loadStrings(dataPath("params.txt"));
  117. for (int i = 0; i < params.length; i++) {
  118. println(params[i]);
  119. }
  120. }*/
  121. }
  122. int guiOffsetTop = 0;
  123. boolean guiHidden;
  124. String noparams = "no directly controllable parameters, try play/ pausing to randomize";
  125. void drawGUI(int topOffset) {
  126. fill(255);
  127. for (int i = 0; i < fxManager.fxList.size(); i++) {
  128. textSize(20);
  129. textAlign(RIGHT);
  130. int fi = i+1;
  131. float textOffset = textWidth(fxManager.fxList.get(i).shader.name);
  132. fill(0, 0, 0, 255);
  133. rect(width-(textOffset+54), 8+(i*65)+topOffset, textOffset+54, 30);
  134. fill(255);
  135. text("[" + fi + "] " + fxManager.fxList.get(i).shader.name, -10, 10+(i*65)+topOffset, width, 100);
  136. String playText = (fxManager.fxList.get(i).shader.animating) ? "animated" : "manual set";
  137. fill(75, 75, 75, 255);
  138. rect(width-(textOffset+54+textWidth(playText)), 10+(i*65)+5+topOffset, textWidth(playText), 25);
  139. fill(255);
  140. textAlign(RIGHT);
  141. textSize(15);
  142. text(playText, -(textOffset+65), 10+(i*65)+5+topOffset, width, 100);
  143. textOffset = 0;
  144. for (int j = 0; j < fxManager.fxList.get(i).shader.params.size(); j ++) {
  145. textOffset += textWidth(fxManager.fxList.get(i).shader.params.get(j).name) + textWidth(fxManager.fxList.get(i).shader.params.get(j).formattedValue()) +15;
  146. }
  147. fill(75, 75, 75, 255);
  148. textOffset = (textOffset == 0) ? textWidth(noparams)+15 : textOffset;
  149. rect(width-textOffset-15, 37+(i*65)+topOffset, textOffset+15, 25);
  150. fill(255);
  151. textOffset = 0;
  152. textAlign(RIGHT);
  153. if (fxManager.fxList.get(i).shader.params.size()>0) {
  154. for (int j = 0; j < fxManager.fxList.get(i).shader.params.size(); j ++) {
  155. text(fxManager.fxList.get(i).shader.params.get(j).name + ": " + fxManager.fxList.get(i).shader.params.get(j).formattedValue(), -textOffset-10, 40+(i*65)+topOffset, width, 100);
  156. textOffset += textWidth(fxManager.fxList.get(i).shader.params.get(j).name) + textWidth(fxManager.fxList.get(i).shader.params.get(j).formattedValue()) +15;
  157. }
  158. } else {
  159. text(noparams, -textOffset-10, 40+(i*65)+topOffset, width, 100);
  160. }
  161. }
  162. }
  163. PImage droppedImage;
  164. void dropEvent(DropEvent theDropEvent) {
  165. sourceManager.importURI(theDropEvent.filePath());
  166. }