mixing two seperately rendered frames

Hi, I’m quite new to OpenGL; however I’m working on two fully developed OpenGL apps.

Basically, both are real time simulations; one of ice, another of snow. I want to visually combine the results of each, so as to have ice and snow on the screen at once. This is purely visual… I don’t care about them interacting for now.

I would like to do this with minimal modifications to each app. So my idea is to have each basically render its entire frame each time, but to an off-screen buffer, and then to pull the areas (pixels) that I would like to display from each and combine them to be displayed (ie: if a portion of the ice frame is displayed, the rest is snow). Ideally, I would like to be able to choose which parts of each frame to be displayed almost arbitrarily (ie: not just the top half ice and the bottom half snow, but practically any combination).
drak10687

Does this sound plausible? Would I be able to do something like render to two different frame buffers and then take any area I wish of each and combine them? Is there an alternative/better approach to do something similar?

Thank a lot!

If you make sure both apps render with identical camera (and depth buffer) settings, you can combine the two images taking depth into account and get one that looks as if it was rendered by one app - this is a parallel rendering technique called sort-last (search it for more details).

You may also want to look at EXT_framebuffer_blit to copy rectangular areas between FBOs.

The easiest way to do this is:

renderIce();
glCopyTexSubImage2D(…); // save framebuffer to texture a
renderSnow();
glCopyTexSubImage2D(…); // save framebuffer to texture b
bindCombinerShader(); // using textures a,b
renderFullscrenQuad();

You get get rid of the framebuffer->texture copies with FBOs, but not needed for quick testing.

Thats going to kill your framerate, id recommend sticking to fbos, setting them up doesn’t take very long.

Create framebuffer bind with a texture. Please Use glFramebufferTexture2DEXT.
Then render ice and snow to separate textures.
For combining, create a pixel shader to combine these textures.