Floats from a shader?

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?


Yes, it is possible. A large amount of my code wouldn’t function at all if it weren’t. :smiley:

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.

That’s weird glClampColorARB aside that’s pretty much what I’m doing and still it’s not working.

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

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. :smiley:


Thank you, thank you, thank you, thank you, thank you, thank you, thank you, that’s just solved a major headache :smiley: