float(32) texture

Started by
4 comments, last by rjackets 18 years, 9 months ago
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
Leo
Advertisement
is it THAT difficult? or I didnt make myself clear?
Leo
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.
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.
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?
Leo
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.

This topic is closed to new replies.

Advertisement