PDA

View Full Version : OpenGL framebuffer and float format textures


martinsm
05-12-2006, 01:03 AM
Hello.

I am implementing some image processing algorithms using OpenGL framebuffer and GLSL shaders. To do so I create framebuffer with float (32-bit) format, and also texture (also with 32-bit float internal format) - using GL_NV_texture_rectangle and GL_NV_float_buffer extensions. I want to use this texture as lookup in shader while I draw big quad all over the framebuffer. Is it possible?
The problem is that I always get 0 pixel values from texture2D() function in shader. If I change that lookup texture format to usual 32-bit RGBA (each color component is 8-bit byte), then shader recieves correct values and I get what I want. So is it possible to use float format textures in GLSL to render to framebuffer?

I have tested my code on GeForce FX 5200 and GeForce 7x00 (don't remeber exact number). Results are same on both videocards.

I can post some source code which I'm using for testing, if needed.

Reedbeta
05-12-2006, 08:06 AM
I've used float lookup textures in GLSL on my ATI Radeon 9600, to render HDR images, so it is definitely possible. If you're interested, look for the "Torrance-Sparrow" demo on my website (address is in my signature), as it contains code for setting up the float buffers, and GLSL shaders that sample them. You could compare it to your own and see if there are any major differences, be warned however that I haven't really tested this code on nVIDIA chipsets at all.

martinsm
05-12-2006, 10:08 AM
From your sourcecode I understood that you are using PBuffers to perform rendering to texture.
But I want to use framebuffer object from GL_EXT_framebuffer_object extension. It doesn't depends on windowing system (wgl, glX) and performance is better, because there is no need to switch rendering contexts.

tbp
05-12-2006, 11:49 AM
I've made a small post-processing thingy that works with fp16/FBO/NPOT etc etc... here
http://ompf.org/forum/viewtopic.php?t=106

I've used fp16 because there's hardware support for filtering. But it worked with fp32 as well.

As i'm lazy at some point i've switched and put ogl 2.0 as a req.

Large pix here: http://ompf.org/ray/wip/pix/20060506-02-bite_my_shiny.png

martinsm
05-12-2006, 12:25 PM
Thanx tbp!
I understood what problem I had. I used NV_float_buffer extension to get GL_FLOAT_RGBA32_NV texture internal format. Looking at your source code I found out that you are using ARB_texture_float extension to get GL_RGBA32F_ARB texture internal format. After changing this I get what I wanted :)

tbp
05-12-2006, 12:29 PM
At your service. Dunno if you got the binary to work on your box as well, if so i'd be glad to know :)

Like i've said i now require ogl 2.0 because there was a tad too many extensions to fish for; but it's not strictly necessary. I'm afraid i don't have the source code for that anymore.

martinsm
05-12-2006, 03:16 PM
No no, I didn't ran your code. I just looked at your source code, and changed a little bit mine.