Problem with drawing PGraphics in 3D-space
in
Core Library Questions
•
1 year ago
hey, ich have the following problem and i hope somebody of you might know a solution:
check out the following code:
- import processing.video.*;
- Movie movie;
- PGraphics pg;
- PShader shader;
- void setup() {
- size(600, 600, P3D);
- pg = createGraphics(320, 180, P2D);
- movie = new Movie(this, "clipcanvas.mp4");
- movie.loop();
- shader = loadShader("edges.glsl");
- }
- void draw() {
- background(0);
- translate(width/2-200, height/2);
- rotateY(sin(frameCount/60.0));
- drawOnPG();
- if(mousePressed){
- image(pg, 0, 0);
- } else {
- image(movie, 0, 0);
- }
- }
- /**
- * the movie needs to be drawn on a pgraphics
- * inbetween in order to be able to apply a
- * shader on the video
- */
- void drawOnPG() {
- pg.beginDraw();
- pg.shader(shader);
- pg.image(movie, 0, 0);
- pg.endDraw();
- }
- void movieEvent(Movie m) {
- m.read();
- }
when you run the sketch you will see that, when you keep the mousebutton pressed and the video is rotated, the "further away"-part of the video is not animated/moving anymore. this gets really annoying when increase the distance of the camera to the video even more, because then the entire video is stuck.
you can see the different to the sketch running without you pressing the mouse, then it works how it should be. the problem only occurs when you draw the video to a PGraphics inbetween, which is needed when you want to apply a shader on a video.
1. is there a way to apply a shader to a video without buffering it into a pgraphics inbetween?
2. is there any way to avoid the bug of the video not moving anymore?
here you can download the sketch including the video. its only 1mb, so dont worry.
thanks in advance,
mrzzzzzl
1