Distorted coordinate system

Hi, everybody!

I have a terrain, generated using a data texture and a vertex shader. It is coloured according to the altitude by the fragment shader. I want to make a polar grid overlaid over the terrain, so that the lines of the grid follow the mountains, etc. I have tried to paint vertices with specific coordiantes in separate colours. It works very well for gl_Vertex.x = 0 (+/-1.5) - it gives me a nicely red coloured y-axis. But gl_Vertex.y = 0 does not give me a coloured horizontal axis, instead, it gives me a coloured curved line. I made a sketch, to visualize the problem (this is the terrain from a bird’s eye).

I take the values for gl_Vertex right in the beginning of the main() in the Vertex shader, so the vertices have not been processed yet. And I am using the default Modelview and Projection matrices.

So does anybody have an idea where might the problem be. Could it be in the default Modelview or Projection matrix?


What projection are you using? Sounds like you want ortho. And your viewing transform? Sounds like you want a top down view.


I am using Perspective Projection, althugh I really use for a top down view. It is a little complicated to explain why, since someone else statred working on this programme before me.

So in this current case I am looking top down at the terrain, but the camera is actually looking fwd (at -z) and the terrain is “vertical”. Hard to explain. Anyway, the coordinate axes are as shown in the picture.

I am not xperienced with OpenGL but I found out that Modelview Maatrix and Projection Matrix are not define anywhere, so I guess that, when they are called, they are using some default values.

Why is the distortion a problem? Assign the same height to all terrain points. Does the warping go away? If so, this is likely just normal perspective foreshortening. If you don’t want that, use Ortho. Or use an eyepoint very far away with a very narrow Perspective frustum (cumbersome) which is an approximation of Ortho.

The distortion is a problem, because I wan to overlay a polar grid over the terrain and it looks a little bit like the milky way - spiralling more and more as it gets further away from the centre. The spiralling is not too big, but is quite enough to be a problem. And it occurs regardless of the height.
In this case I am using a top down view, because it shows the problem in a most clear way. However I also need the first person view (camera moving parallel to the terrain) and then the distortion is also a problem (because of the spiralling of the grid line). So I cannot just use Ortho, it will solve (if at all) only half of the problem.
And I know that it is not the perspective because I coloured multiple lines with constant value of gl_Vertex.y and the are all bent in the same direction. If it was because of the perspective, they would bend in different directions for y>0 and y<0.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.