Sign in to follow this  
giant

Storing non 0.0-1.0 values in a texture.

Recommended Posts

giant    205
Hey Ive spent a few hours looking and cant find any information on this, probably because it cant be done and Im foolish for thinking that it may be possible, however before giving up I thought it good to ask here so that a) I may find an answer and b) if someone else looks in the future they too can find the answer here. I have a shader in GLSL. If creates some noise using BFM. Originally I tried to split this noise (which represents a height) into 3 or 4 floats in the range 0.0 to 1.0, and store them in the RGBA of the texture, however I would like to know if its possible to setup a texture in some way so that it allows full floats to be stored in each of its RGBA values i.e. in the RGB of a texture I can store a complete vertex position. (1234.56, 78.90123, 45.67866) The best direction I could find in some google research was to use GL_RGBA_FLOAT32_ATI as below, however this does not seem to work for me. I will keep trying and post back here if I find a solution, however any tips, advice (on if possible or not) would be greatly appreciated.
glGenTextures(1, &m_uiTexture);
glBindTexture(GL_TEXTURE_2D, m_uiTexture);
/*glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_uiWidth, m_uiHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);*/

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA_FLOAT32_ATI, m_uiWidth, m_uiHeight, 0, GL_RGBA, GL_FLOAT, 0);

glBindTexture(GL_TEXTURE_2D, 0);



Thanks alot. Ciaran

Share this post


Link to post
Share on other sites
Geometrian    1810
You can apply a transform instead, and just use standard textures (e.g., [-100.0,100.0] -> [0.0,1.0] in the texture and back again). I've used this technique to store cloth and particle vertices in standard textures. Of course, you may need more precision for your coordinates (I did), and you'll need higher bit depth textures anyway.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this