Jump to content

Render scene on rendertarget and back buffer


yankeeg
 Share

Recommended Posts

Hello, I'm just starting with babylon and I was wondering if someone could enlighten me on the engine's flow.

 

What I'm trying to achieve is: render the scene in half resolution on a rendertargettexture, using programs that output packed depth and color(in 2 channels YCoCg). This texture would then be used to extract bloom and ssao and produce a combined texture with these. Finally the scene will be rendered again in the back buffer in full resolution, switching programs to ones that make use of the ssao-bloom texture.

 

My question is how should I go about doing that using the postprocessing pipeline? By peeking at scene render() I thought of overriding the babylon.depthrenderer but I think that would be too hacky. Any help would be appreciated

Link to comment
Share on other sites

Hey! Welcome on this forum.

 

I made a small playground that will hopefully help you understand how BJS does things on this topic: http://www.babylonjs-playground.com/#DUCK2

 

What happens there is:

  • I'm setting up a render target texture with POT dimensions, which is a downscaled version of the main buffer (reduced 8 times for clearer result)
  • Also setting up a depth texture using the DepthRenderer (very useful)
  • Wrapping all this in a custom post process, for which I had to write a fragment shader in an awkward series of concatenated strings because that's how we have to do it in the playground

 

So, the upper tier of the screen is the main buffer, middle tier is downscaled buffer and lower tier is depth value.

 

Some other things that may help:

- BJS already has an SSAO implementation (stating the obvious just in case), as well as a blur post process

- My example does not use the PostProcessRenderPipeline class from BJS, which can help you with more advanced PP effects; source here and documentation here

 

PS: guys... please, take note of this playground ID.  :blink:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...