Jump to content
  • Advertisement
Sign in to follow this  
leo77

float(32) texture

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi... I have a simple question... I have a floating point matrix, its an aditional information to each pixel in my texture (it has the same size (512x512)). I want to load this matrix in the fragment shader, how can I do that? I belive it can be a texture made of float... but I dont want it to be clamped in [0,1]... thanks ps: using OpenGL/C++, and a NVidia 6800

Share this post


Link to post
Share on other sites
Advertisement
My understanding: You have a 512x512 array of floats. You wish to access this array in a fragment shader.

I've never used shaders, but passing it in as a texture seems like a doable idea. One way around the clamping issue would be to prenormalize it yourself and remember the scaling factor, and then multiply while doing the shader operations, since if memory serves you get alot more range freedom while executing.

Share this post


Link to post
Share on other sites
Do you need to access each element of your array seperately? If not you could consider merely creating a dynamic 32-bit texture in your core code containing the information you want to pass in and then just passing the texture to the shader. Alternatively, you should be able to pass it in as a 512x512 float array, but the problem will then be converting the texture coordinates into the 512pixel format you need to access it. You see, since the textures are read as 0...1 then you would need to convert those floating point values into (int)0...512 before you can access the pixel. Also, I'm not sure about the specifics but fragment shaders can only handle so much information at a time, I don't know if a 512x512 array would cause problems with that.

Share this post


Link to post
Share on other sites
I have to access one value for each pixel, thats why I belive using a texture might be the best Idea. the problem is that I dont know how to create a texture with one 32bit float instead of RGBA '8 bits/channel'...
I know OpenGL has an option in the function glTexImage2D (type GL_FLOAT), but it didnt work... I've also heard of some NVidia extensions, but I dont know how to use it...

can you give me a hand?

Share this post


Link to post
Share on other sites
I am not quite as versed in OpenGL as I am in DX, but I know when I need a floating point texture in directX I can just use a single 32-bit Red channel. I COULD use RGBA all in 32-bit but that is unnecessarily resource intensive. I recommend you try and look up how to create a single channel texture.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!