Q1)
Why are the values floats between 0.0 and 1.0 and when is the conversion done? I thought the glTexImage3D meant the internal structure was 4 bytes 0 to 255.

Q2)
Then I wondered how I could have a sampler to look up floats and since glTexImage doesn't have an internal format of GL_FLOAT I couldn't see how.

Q4)
glTexImage can take GL_FLOAT as the input type. Does GL_FLOAT have a defined portable layout so I could create a file to load the data? Or would I have to use some other format and then load and convert the data?

Thanks,

STU!

Zengar

03-23-2007, 05:50 AM

The textures are usually stored as RGBA color values, and each color component is defined as value in range 0 to 1. When using bytes, this floating point value is mapped to byte range, so 0 corresponds to 0.0 and 255 to 1.0 If you use RGBA as internal format, the texture data will be converted to match it. You can supply texture data as floats, but this will be clamped to [0.0..1.0] range. It is possible, however, to use floating-point textures with newer hardware, see http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_float.txt

But if you only want to have 0..255 values in the shader, you could just multiply the texel value with 255.

V-man

03-24-2007, 04:31 AM

The texture is really stored as RGBA8 when that's is your internal format, but the GPU fetches those and immediatly converts to float (0.0 to 1.0)

That's normal operation!

Also, it's not pleseant to work with bytes. It's easier to do math (lighting equations and such) with floats.