Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Distorted coordinate system

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    9

    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?

    Click image for larger version. 

Name:	Curved abscissa.JPG 
Views:	86 
Size:	10.7 KB 
ID:	815

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,188
    What projection are you using? Sounds like you want ortho. And your viewing transform? Sounds like you want a top down view.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    9
    Hi,

    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.

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,188
    Quote Originally Posted by VladoB View Post
    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.
    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.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    9
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •