Render-to-texture examples?

Could somebody point me in the right direction on how to render to textures using FBOs? Using glCopyTexImage2D I found a NeHe tutorial (http://www.java-tips.org/other-api-tips/jogl/radial-blur-and-rendering-to-a-texture---nehe-tutorial-jogl-port.html) but I can’t find any nice examples doing the same using FBOs.

Any help would be greatly appreciated.

Unfortunately we don’t have any FBO render-to-texture examples in the jogl-demos workspace yet. There is one attached to this bug report. At one point I asked the author for permission to include it in the jogl-demos workspace but never heard back. If you write your own and are willing to contribute it please let me know.

Would it be useful if I made an FBO version of the radial blur demo?

Hey, you would make me happy at least :smiley:

Took a look at the code that Ken pointed to and I must say it seems overly complicated to use as a demo without rewriting it, it is also structured in a strange way, but that might just be me.

cough Of course, a version that uses FBOs and a fallback to glCopyTexImage2D if FBOs aren’t supported would even be better!

Not asking for too much, am I? ;D

If you have the time that would be great.

I’ve updated the radial blur demo to use an fbo if possible. There are some issues with this though. The demo uses a luminance texture for the blur effect. Unfortunately luminance textures (or any single channel texture for that matter) can’t be used as render targets in a portable (i.e. non vendor specific) way. What I’m doing now is rendering to the fbo’s color buffer and then copying to the luminance texture from there. Currently I’m using a rgba texture as the color buffer, but I might replace this with a simple render color buffer, since there’s not really a point in using a texture there.
If anyone has a better idea on how to implement this please let me know :slight_smile:

By the way does anyone know off the top of their head whether it is possible to render to a float texture, and if so what sort of hw support is out there and any caveats they know of?

I’m quite sure this is possible as this is how many engines are supporting HDR. The HDR demo in the jogl-demos package uses a floating-point pbuffer rather than a floating-point FBO but I’m pretty sure you should be able to convert it over. My understanding is that support is reasonable on Windows and Linux but I think floating-point FBOs aren’t supported yet on Mac OS X. On OS X I’m pretty sure there are also restrictions like floating-point pbuffer support only working on ATI hardware or something similar.

ARB_texture_float, ATI_texture_float and NV_float_buffer cover floating point textures. The GPGPU tutorial lists which extensions are supported on which hardware and which formats can be used for render targets. Not sure how up to date this info is though.