Trouble accessing texture data from the vertex shader

Hey, I’m having a bit of trouble trying to pull out some texture data in my vs. I have read several tutorials and i seem to be doing everything as is suggested. here are some code snippets. Any help would be appreciated.

The same uniform sampler seems to work okay in my fragment shader so I don’t think there is anything wrong with the texture that I can see.

This code is setting my v.y to just under 1.2 across the entire surface.

uniform sampler2D displacementMap;
void main(void)
   vertexPosition.x = gl_Vertex.x/10.0;
   vertexPosition.y = -gl_Vertex.z/10.0;
   vec4 v = vec4(gl_Vertex);
   vec4 texel = texture2DLod(displacementMap, vertexPosition, 0.0); //vertexPosition is filled with the values 0.0-199.0
   v.y = (texel.r+texel.g+texel.b);                                                //the texture size is 200x200
   gl_Position = gl_ModelViewProjectionMatrix * v;

The texture loading code:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);                                     
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_BGR, GL_UNSIGNED_BYTE, data);

I am using OpenGL 3.1 on an NVIDIA Quadro NVS 135M currently.

Any thoughts?

Anyone have any thoughts? The only thing I can think of is maybe my card won’t support the texture format or something… Any information at all would be helpful.

Solved the problem. Apparently even though a query of the number of textures my card has access to from the vertex shader returned differently, my cards vertex shader can only access textures 0-3. I was mapping it to texture 4.


Huh. I didn’t think of that. Thanks, I’m having a similar problem at the moment.