PDA

View Full Version : Offscreen Rendering vs Render-to-texture



McLeary
02-23-2011, 12:05 PM
After read the OpenGL Programming Guide unnumbered times about Frame Buffer Objects I didn't find the difference between Offscreen Rendering and Render-to-texture techniques.

Here is what I understood from the two concepts:

Offscreen rendering: Using a FBO, OpenGL is capable of rendering an entire scene onto a FBO. At least a color and a depth buffers must be attached to the FBO.

Render-to-texture: Same as above, but textures are attached onto the FBO instead of render buffers. It's possible to detach the texture and use it in another place.

Please, correct me if I'm missing something.

The question is, what is the advantage of Offscreen rendering over render-to-texture?

As far as I know, it's only possible to copy rectangular areas from buffers generated with offscreen rendering to the displayable frame buffer.

Thanks in advance

skynet
02-23-2011, 12:27 PM
The purpose of renderbuffers is
a) expose renderable pixelformats that can't be used as texture formats (for instance, multisampled renderbuffers in the days when ARB_texture_multisample was not born yet)
b) since the driver knows that a renderbuffer can't be ever used for a texture, it has the opportunity to chose a different, more render-optimized memory layout for the renderbuffer.

So, my advice is to use renderbuffers instead of textures whenever you can (i.e. don't need to sample the rendered data in a shader afterwards).

McLeary
02-25-2011, 11:41 AM
Thanks Skynet. I came with another doubt. Like you said, it's a good thing the use of render buffer instead of render-to-texture, but, one can't use the result image of a render buffer as a texture. The only way of using the result produced with render buffer is to copy rectangular data to the displayable framebuffer?

Alfonse Reinheart
02-25-2011, 01:39 PM
The only way of using the result produced with render buffer is to copy rectangular data to the displayable framebuffer?

That would be just as true for textures too. You cannot render directly to the visible framebuffer with FBOs.

McLeary
02-25-2011, 02:00 PM
That would be just as true for textures too. You cannot render directly to the visible framebuffer with FBOs.

But when one use Textures it's is possible to detach the texture and use it just the way you like. I guess render buffers can be more optimized for some operations rather than textures. I don't see any other advantage then performance (I'm not saying this is not an important issue)

kyle_
02-25-2011, 02:31 PM
I dont see much advantage at all (perhaps if there are some renderbuffer only internal formats, but dont know that).

Internally rb and tex would probably be the same thing. You can blit from renderbuffers - which probably wont be done with specialized FF as there are format conversions, scissoring and probably more things that affect blit.

I wouldnt expect any perf difference at all would be nice if sb that measured this could provide some data.

McLeary
02-25-2011, 03:34 PM
Maybe the only advantage is that the driver could optimize something.
Thanks for your reply