Stuart McDonald
03-22-2007, 08:20 PM
Three easy questions...
I have a 3D sampler that I use for random values in my fragment shader. I setup the texture with
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA,
64, 64, 64, 0, GL_RGBA,
GL_UNSIGNED_BYTE, m_pBytes);and access it with
uniform sampler3D Random_3D;
vec4 random(const in vec3 pos3v)
{
vec4 texel4v = texture3D(Random_3D, pos3v);
return texel4v;
}Everything works fine, but I just realised something I don't understand.
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!
I have a 3D sampler that I use for random values in my fragment shader. I setup the texture with
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA,
64, 64, 64, 0, GL_RGBA,
GL_UNSIGNED_BYTE, m_pBytes);and access it with
uniform sampler3D Random_3D;
vec4 random(const in vec3 pos3v)
{
vec4 texel4v = texture3D(Random_3D, pos3v);
return texel4v;
}Everything works fine, but I just realised something I don't understand.
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!