0
votes

Is it possible to render to a FBO with render calls that use fbos themselves? for instance here is a bit of pseudo code.

Bind (top level FBO)

render water <-- (generate and use own sub fbos)

render shadows <-- (generate and use sub fbos)

render regular scene etc..

unbind (top level FBO)

Blur Top level FBO, bloom, render final scene to a quad using the top level FBO generated texture. I'm interested in doing post processing like bloom to my final game scene.

1
why not? anytime you can bind any FBO as render target if you want. With this you can implement a kind of FBO stack that you might use for postprocessing. You also can use textures that you have rendered to with FBOs in your render sequence. Just don't read from a texture, while simultaneously having it bound as your render target ;)Pavel Beliy

1 Answers

0
votes

If I get your question right you want to compose a final scene from different rendering results,right?So first,this is completely possible.You can reserve an FBO per effect if you want.But your pseudo-code lack efficiency and would impact performance.No need to create sub-FBOs in runtime all the time.It is expensive operation.If you are after a pipeline with post-processing stage you would usually need no more than 2 FBOs (offscreen).Also remember you always have the default FBOs (front,back,left,right) which are created by the context.So you can render your 3D stuff into FBO -1 than use its texture as source for FBO-2 to apply post-processing effects.Then blit the results into the default screen FBO.

I don't see a reason to create FBO per effect.The execution is still serial.That's, you render effect after effect so you can reuse the same FBO again and again.Also,you may consider,instead of multiple FBOs use multiple render buffers or texture attachments of one FBO and decide into which of those you want to render your stuff.