Gaussian Blur |Post Processing Bloom| MultiPass Rendering in jpct ae

Started by SonicBurst2, April 29, 2017, 02:02:32 PM

Previous topic - Next topic

SonicBurst2

Hi,
     I am trying to experiment with MultiPass Rendering with jpct ae . I was trying to do 2 pass Gaussian blur . I was able to get individual blurs Successfully , i.e horizontal and vertical blurs individually . But what I want is ->
1) Render the "Bright" part to a texture.
1) the output from the 1st step should undergo horizontal blurring .
2) the output from the 2nd step should undergo vertical blurring
3) The output from the 3rd step would be blended in some way with the original rendered image for the post processing bloom effect .

   So how do we do multipass rendering in jpct ae ? And pass the result from one render phase to the other for further processing? Also I have to composite the processed Bloom with the final image .
I just know the theory for now..... a pointer to actual implementation would help a lot .  :)
Thanks in advance. :)

EgonOlsen


SonicBurst2

   I tried something like this->

                        fb.setRenderTarget(target1);

fb.setBlittingShader(shader1);
fb.clear(new RGBColor(123, 223, 237));
world.renderScene(fb);
world.draw(fb);
fb.display();


fb.setRenderTarget(target2);
fb.setBlittingShader(shader2);
fb.clear(new RGBColor(123, 223, 237));
world.renderScene(fb);
world.draw(fb);
fb.display();
fb.removeRenderTarget();

fb.blit(target2, 0, 0, 0, fb.getHeight(), target1.getWidth(), target1.getHeight() , fb.getWidth(), -fb.getHeight(), -1, false);




But this only shows me the output of second pass , ignoring the first one .
Am i missing something or do I have to remove something ?

EgonOlsen

Where the relation between target1 and target2 in that code? You render into target1, then into target2 and then you blit target2. I don't see where target1 is actually used here!?

SonicBurst2

Yes ... this code is not correct :(
there is something missing ...
But that's what my question is .... How to set this relation between target1 and target2 .
What is happening actually is , the target1 is having the vertical blurring . Now  this target1 texture has to be fed to the input of second pass....
So that the already vertically blurred image can be processed again with horizontal blur . You mentioned that this can be achieved with 2 render targets .So for now  I have created 2 render Targets... but then I was blank....I am not sure how to do this part in jpct ae.

EgonOlsen

How is the general idea? You render the scene into target1, which includes the first blur. Then you want to use the same texture (target1) as the source for the other blur step and blit the resulting image?

SonicBurst2

Yes exactly!
At least this is what should happen according to my understanding... in theory,
So Yes I need to know jpct ae steps to execute the same idea .
Is this realizable this way ?
Or....
If you have some alternate feasible / better way, please suggest. :)

Cause I would be then using this idea further for Post processing blur , So i guess I would have to do a third pass as well, for combining the blurred bright texture with the normal rendered image texture...

EgonOlsen

I would try something like this:


  • set target1, render the scene
  • set target2, set the second blur shader as blitting shader and blit target1 fullscreen into target2
  • remove the render target and blit target2 to the screen

In your code, you render the scene twice and I'm not sure if that's needed here. If target2's size isn't the same size as the screen, you might have to adjust the blitting coordinates. Here's some basic example that shows this: http://www.jpct.net/forum2/index.php/topic,4609.msg31858.html#msg31858

Another approach is to use an Overlay instead of blit(). You can obtain the Object3D from an overlay and assign your own shader to that one (just like you would with setBlittingShader()). That method has to no need to convert the coordinates.

SonicBurst2

Hi Egon,

You said
Quoteblit target1 fullscreen into target2
.
I got confused with this...did you mean that I should simply use fb.blit() ?? just after setting rendering to target 2 with blurring ?
like this->

// the first step you mentioned
                        fb.setRenderTarget(target1);
fb.setBlittingShader(shader1);
fb.clear(new RGBColor(123, 223, 237));
world.renderScene(fb);
world.draw(fb);
fb.display();
//the 2nd step->
fb.setRenderTarget(target2);
fb.setBlittingShader(shader2);
fb.blit(target1, 0, 0, 0, fb.getHeight(), target1.getWidth(), target1.getHeight() , fb.getWidth(), -fb.getHeight(), -1, false);   // this ? I'm not sure...

// the 3rd step->
fb.removeRenderTarget();
fb.blit(target2, 0, 0, 0, fb.getHeight(), target1.getWidth(), target1.getHeight() , fb.getWidth(), -fb.getHeight(), -1, false);



this did not worked... so this must be wrong, I know ...
But I'm asking this... because I failed to find any method which allows me to blit a texture to another in fullscreen...

AeroShark333

Is using an shader for an Overlay-Object3D here better than using a blitshader?
I think effectively you can reach the same goals..? But what would be faster here?

EgonOlsen

Quote from: SonicBurst2 on May 02, 2017, 08:51:57 PM
You said
Quoteblit target1 fullscreen into target2
.
I got confused with this...did you mean that I should simply use fb.blit() ?? just after setting rendering to target 2 with blurring ?
Yes, that's what I meant. In which way does it not work?

EgonOlsen

Quote from: AeroShark333 on May 03, 2017, 01:14:00 AM
Is using an shader for an Overlay-Object3D here better than using a blitshader?
I think effectively you can reach the same goals..? But what would be faster here?
It shouldn't really matter. Which one is better is merely a matter of taste. Blitting into render targets can require some coordinate adjustments, so using an Overlay might be more intuitive for some though.

AeroShark333

Quote from: EgonOlsen on May 03, 2017, 09:01:06 AM
Quote from: AeroShark333 on May 03, 2017, 01:14:00 AM
Is using an shader for an Overlay-Object3D here better than using a blitshader?
I think effectively you can reach the same goals..? But what would be faster here?
It shouldn't really matter. Which one is better is merely a matter of taste. Blitting into render targets can require some coordinate adjustments, so using an Overlay might be more intuitive for some though.
And performance-wise?

EgonOlsen

It depends. I would say it's like the difference between starting a marathon with your left or with your right leg...

SonicBurst2

QuoteIn which way does it not work?
It displays some weird artifacts like this (please see attachment)

and after few seconds , it crashes due to out of memory exception... :(

The Code is the same , the earlier posted code....