Reputation: 2057
I am confused with the internal format related to texture2D() in GLSL and glTexImage2D() in OpenGL, When I use(pay attention to the third
and the eighth
parameters):
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA16F_ARB, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA,
GL_FLOAT, floatDataPtr);
I got the nonclampedvalue
of sampler2D in the glsl without clamped to [0, 1]:
vec4 nonclampedvalue = texture2D(my16floattex2d, texcoord1);
When I use:
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA8, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA,
GL_UNSIGNED_BYTE, byteDataPtr);
I got the clampedvalue
of sampler2D in the glsl clamped to [0, 1]:
vec4 clampedvalue = texuture2D(myunsignedbytetex2d, texcoord2);
So my questions are this:
What value will I get in glsl when invoke the glTexImage2D like this(clamped or not clamped):
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA8, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA,
GL_FLOAT, floatDataPtr);
What value will I get in glsl when invoke the glTexImage2D like this(clamped or not clamped):
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA16F_ARB, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA,
GL_UNSIGNED_BYTE, byteDataPtr);
As I can't find the detailed information in OpenGL official website, What value will be return in the sampler2D texture with different internal format as well as different type(such as GL_FLOAT or GL_UNSIGNED_BYTE mentioned above) of the data passed to the texture when invoke the glTexImage2D()? what's all the rules?
Does anyone can help?
Upvotes: 1
Views: 3997
Reputation: 474406
What value will I get in glsl when invoke the glTexImage2D like this(clamped or not clamped):
This is governed only by the "internal format" parameter. Normalized internal formats are... normalized. They don't store floating point values; they store integer values which are interpreted as floats. The maximum integer value becomes 1.0 and the minimum becomes 0.0 (or -1.0 if it's an SNORM format).
As I can't find the detailed information in OpenGL official website
Look harder next time; it's right there on the Wiki. The "internal format" used for creating textures and renderbuffers. It even explains that the last three parameters govern pixel transfer operations: uploading data to the image.
Upvotes: 3