# Heightmap in Shader not working

I'm trying to implement GPU-based geometry clipmapping and have problems to apply a simple heightmap to my terrain. For the heightmap I use a simple texture with the surface format "single". I've taken the texture from Catalinz's XNA blog.

What I'm trying to do is just getting the single float value from the texture at the vertex world coordinate and apply the value to the Y-Value of the Vertex. I'm applying the heightmap through the shader, because there is no fixed grid in-code it could be applied on. What I've tried so far was using the tex2Dlod function, but there seems to be no output or an output of 0. The Direct X vertex shader's code looks like this:

float4 worldPos = mul(float4(pos.x,0.0f,pos.y, 1.0f), worldMatrix);
float elevation = tex2Dlod(HeightmapSampler, float4(worldPos.x, worldPos.z,0,0));
worldPos.y = elevation * 128;


Where HeightmapSampler is a point-mirror sampler of the heightmap texture. Here is the output, I actually get no elevation:

And here's the heightmap I'm using:

• You need to provide less code, and more details. What have you tried so far? What isn't working exactly? If you want to get an answer, try to ask a good question, check the FAQ for infos. – Laurent Couvidou Sep 1 '12 at 21:43
• I've updated my question to be more precise. – CShark Sep 2 '12 at 11:47
• is this a vertex or fragment shader (whatever they are called in directx)? Can you post a screen-shot of what you are getting, and what you are expecting to get? – Will Sep 2 '12 at 11:56
• I expect at least some elevation characteristics. The camera is at height 40 and the maximum elevation is by 128, so I shall see something... The center of the grid is in the center of the window. – CShark Sep 2 '12 at 13:10
• Thank you for implementing the pictures... I wasn't able to do it because of my reputation level <10 – CShark Sep 2 '12 at 17:39

float elevation = tex2Dlod(HeightmapSampler, float4(worldPos.x*0.001, worldPos.z*0.001,0,0));