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?