I am trying to send an array of float values(height map) to GLSL as a GL_TEXTURE_2D. While I have the samplers set right, the issue comes from the clamping that happens when I upload the texture using glTexImage2D().
glGenTextures(1, &_idnewTID); glBindTexture(GL_TEXTURE_2D, _idnewTID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, regMesh._cols, regMesh._rows, 0, GL_RED, GL_FLOAT, regMesh._heightMap);
The values that I am sending are in the range 900.0f to 1590.0f. But this gets completely clamped out to 1.0f as it loads into the GL_TEXTURE_2D.
How do I preserve the values from being clamped to [0,1]. How should I modify the glTexImage2D() function to get this achieved? Thanks in advance!
P.S I know the sampler works fine because when I divide the values by 1500.0f and upload it to GPU and scale it in the shader, I get the proper height map structure.