View Full Version : Floats from a shader?

09-01-2005, 06:16 AM
Iím looking for a way to retrieve unaltered floating point values (preferably via the GL_RGBA32F_ARB format) from a pixel shader. Iím lead to believe I can do this by writing said values out of the shader as a gl_FragColor( ... ), rendering to a FBO, calling glClampColorARB( ... ) to turn of clamping and using glReadPixels( ... ) to grab the data. However I just canít seem to get this to work, so my questions are as follows:

Is this actually possible?
If so what steps do I need to take in order to do this?


Jay Cornwall
09-01-2005, 07:34 AM
Yes, it is possible. A large amount of my code wouldn't function at all if it weren't. :D

There isn't much more to it than what you've already said, except that I've never seen glClampColorARB() have any effect on NVIDIA drivers. All I do is upload textures with GL_RGBA32F_ARB as the internal format parameter (not format; that remains GL_RGBA) and read back with GL_RGBA / GL_FLOAT as glReadPixels parameters.

09-02-2005, 04:54 AM
Thatís weird glClampColorARB aside thatís pretty much what Iím doing and still itís not working.

09-02-2005, 05:11 AM
Does anybody know of / have a little example of how this works that I could take a look at and check my code against?

Thanks in advance

Jay Cornwall
09-02-2005, 07:29 AM
Here's something I threw together out of a bare bones test case I just made. The code's not pretty, but it works, and it gets the concept across. :D

fbo_float.zip (http://www.esuna.co.uk/~jay/misc/fbo_float.zip)

09-09-2005, 04:06 AM
Thank you, thank you, thank you, thank you, thank you, thank you, thank you, that's just solved a major headache :D