OpenGL floating point textures

Started by
2 comments, last by MARS_999 15 years, 1 month ago
Hi, I'm using an OpenGL texture as buffer to contain the painting in a painting program (this program is geared towards myself for editing textures for my own game projects). I'm doing this as a 8-bit per channel texture now, but for some image operations it's better of the drawing is represented by something with higher precision than 8-bit per channel. I'm considering two options: 1) Keep using 8-bit per channel texture for OpenGL, and use a floating point buffer to contain the image, and constantly convert it to the OpenGL texture to draw it. But, I think this would be really slow, is that true or not? 2) Use a floating point OpenGL texture (32 bit floating point per channel). I have some questions for this option though... -Are such floating point textures supported on all video cards? Or will there be compatibility problems? -Does such a texture also support alpha channel? -Are the values in range 0.0-1.0, and what happens to smaller and larger values? -What's the performance of floating point textures? (and how does it compare to option 1) above?) -If I'd use approach 1), what's the fastest way to convert a float or double buffer of RGBA values to a 8-bit per channel OpenGL texture? Is there an OpenGL call that can do it directly? Thanks! [Edited by - Lode on March 13, 2009 6:00:43 AM]
Advertisement
1) I'll leave that up to you. It's your app and you know what is best for your needs.

2) http://www.opengl.org/wiki/Floating_point_and_mipmapping_and_filtering
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Quote:Original post by Lode
-Are such floating point textures supported on all video cards? Or will there be compatibility problems?
In general, anything OpenGL 2.0+ will support floating point textures, but even recent intel integrated cards seem to have issues.
Quote:-If I'd use approach 1), what's the fastest way to convert a float or double buffer of RGBA values to a 8-bit per channel OpenGL texture? Is there an OpenGL call that can do it directly?
glTexImage2D(GL_TEXTURE_2D, 0, G_RGBA, width, height, 0 GL_RGBA, GL_FLOAT, data), or similar.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

-Are such floating point textures supported on all video cards? Or will there be compatibility problems?

Possibly... would have to check for texture float extension support on GL1.5 or GL2.0 is supposed to ARB for floating point textures.

-Does such a texture also support alpha channel?
Yes, 16/32bit to boot RGBA


-Are the values in range 0.0-1.0, and what happens to smaller and larger values?

This extension introduces texel values that can be
outside [0, 1]. No clamping occurs to these values during
texture filtering. For the fixed-function pipeline, the
filtered texel is now clamped before it is used for texture
environment blending. The ARB_color_buffer_float extension
can be used to control this clamping. For the programmable
pipelines, no clamping occurs.



-What's the performance of floating point textures? (and how does it compare to option 1) above?)
From what I have done with them I didn't see any difference, but YMMV and I would guess size and amount of floating point textures will probably play a role in this also.

This topic is closed to new replies.

Advertisement