Admittedly, I'm still new to GLSL, perhaps I've missed something fundamental. Sample vertex shader is provided below:
uniform sampler2D Texture;
vec3 LumConst = vec3(0.2990, 0.5870, 0.1140);
varying float Z;
void main(void)
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 Texel = texture2DLod(Texture, gl_TexCoord[0].st, 0.0);
Z = dot(Texel.rgb, LumConst);
gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xy, gl_Vertex.z + Z, gl_Vertex.w);
}
What's happening there is that I'm grabbing the RGB value for each texel at the vertices, apply RGB-to-luminance transform and use the result to displace the Z component of the vertex position.
The only problem is, the program does not seem to fetch the texel. The computed Z value is always 0. The texel coordianes are correct at each vertex, I checked (I've fed either the .s or .t component to Z value for testing). The texture also seems to be bound correctly, because i can render it in the fragment shader using the same uniform name. The actual texture itself is uploaded as a 16-bit height map, I'm not sure if that would be a problem though.
My hardware is an 8600 GT with GL 2.1 capable drivers.