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 3 of 3

Thread: othographic and perspective projections interacting?

  1. #1
    Intern Newbie
    Join Date
    Nov 2010
    Posts
    40

    othographic and perspective projections interacting?

    Hello,


    In my OpenGLES 2.0 app, I am drawing some cubes with a perspective projection. Then I draw some with an orthographic projection. The orthographic cube is always drawn on top of the perspective ones -- why is that? Is there any way to get them to intersect? I am not sure what that would mean -- I am just wondering how it all works. What happens to the depth information if you change the projection matrix between object draws?

    Thanks
    Bob

  2. #2
    Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    253
    if they map to the same z range, and depth testing is enabled they will intersect

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,191
    Quote Originally Posted by bsabiston View Post
    I am drawing some cubes with a perspective projection. Then I draw some with an orthographic projection. The orthographic cube is always drawn on top of the perspective ones -- why is that? Is there any way to get them to intersect? I am not sure what that would mean -- I am just wondering how it all works. What happens to the depth information if you change the projection matrix between object draws?
    Yeah, that's not going to work. What actually gets stored on your render target for depth is a 0..1 value where 0 == near plane and 1 == far plane. The mapping between EYE-SPACE ("real world") depth values and this 0..1 range is different between orthographic and perspective. For orthographic, it is a linear mapping. For perspective, it is a non-linear one.

    While you could hack things to make them both use the same depth encoding with custom shaders and some extra glue code, it still wouldn't "line up" because the mapping for EYE-SPACE X and Y (left/right and up/down dimensions) are different.

    Best bet: just draw them with the same projection so the drawing makes intuitive sense. If you absolutely must use different projections, clear the depth buffer or disable depth testing before you render with the second one.

Posting Permissions

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