cansik / processing-postfx

A shader based postFX library for processing.
148 stars 13 forks source link

Imcompability with peasycam #28

Closed cgiles closed 6 years ago

cgiles commented 6 years ago

Hi, as I tried to use postfx with peasycam : http://mrfeinberg.com/peasycam/ , I got this bug : image As you can see, the original is displayed in the background, and the post fx render appears in the front, scaled down.

I tried to move the focus point of my peasycam object, but it doesn't fix the issue :/

a sketch which reproduce this bug :

import ch.bildspur.postfx.builder.*;
import ch.bildspur.postfx.pass.*;
import ch.bildspur.postfx.*;

import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.geometry.*;

PeasyCam cam;

PostFX fx;
void setup(){
  size(400,400,P3D);
  cam=new PeasyCam(this, 800);
  fx = new PostFX(this);  
}
void draw(){
  background(100);
  pushMatrix();
translate(width/2,height/2);
rotateY(frameCount/17.0);
box(200);
    popMatrix();
 fx.render()
    .bloom(0.5, 20, 40)
    .compose();

}

regards

cgiles commented 6 years ago

I posted the issue here too : https://github.com/jdf/peasycam/issues/33

cansik commented 6 years ago

I have to tell you that this behaviour is not directly an issue. The PostFX library uses 2d textures to apply shaders, so compose() is drawing the output texture onto the screen. If you are using peasycam, which changes the view matrix, then you have to reset the matrix before drawing the effect texture.

With peasycam you can use beginHUD() and endHUD() to reset the view matrix:

cam.beginHUD();
fx.render()
  .bloom(0.5, 20, 40)
  .compose();
cam.endHUD();

I have added your example to the examples: PeasyCamExample.pde

cgiles commented 6 years ago

Great, thanks, it works 👍