Jump to content

  • Log In with Google      Sign In   
  • Create Account

Rendering a (cal3D) 3D mesh in glOrtho: faces get front/back messed up. FIXED


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 owl   Banned   -  Reputation: 364

Like
0Likes
Like

Posted 17 June 2008 - 02:22 PM

Hi, I'm trying to render a 3D mesh within an orthographic projection and the mesh faces are not being rendered in the proper way, the ones behind appear mixed/screwed up with the ones on the front. This gets more obvious when you rotate the mesh. With or without enabling GL_DEPTH_TEST I'm getting the same result. The mesh is being rendered as a vertex array with glDrawElements (as they do in the CAL3D examples) I'm setting glOrtho as usual. Light0 is on and set up, blending is on, texturing is off. I set it like this:
glViewport(0, w, h, 0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 1, 0, 1, -100000.0, 100000.0);
    glMatrixMode(GL_MODELVIEW);
If I comment the ortho part and I render this mesh with a perspective projection it looks perfect. The problem is with the orthographic one. I don't have the exact source code with me right now. I'll try to bring it on later. Thanks in advance. [Edited by - owl on June 18, 2008 9:40:10 AM]

Sponsor:

#2 zimerman   Members   -  Reputation: 176

Like
0Likes
Like

Posted 17 June 2008 - 07:49 PM

hi owl,

your enormous depth range (-100000..100000) kills the precision of the depth buffer. try to reduce the depth range to the real extents of your scene...

regards
zimerman


#3 haegarr   Crossbones+   -  Reputation: 4338

Like
1Likes
Like

Posted 17 June 2008 - 08:25 PM

In addition to zimerman's answer: If you compare your set-up using glOrtho with your set-up using glFrustum, then you'll see a significant difference in the value of zNear. You've set zNear to -100000.0 for glOrtho, i.e. a value far behind the camera. Then, of course, scene stuff located behind the camera becomes visible, too. It is questionable whether this is really "as usual" for glOrtho. However, for glFrustum you use a relatively small zNear in front of the camera, didn't you? So set zNear for glOrtho to, e.g., 0 and you'll benefit from a doubled z-buffer resolution as well. Then think about the 100000 for zFar, as zimerman has suggested.

#4 owl   Banned   -  Reputation: 364

Like
0Likes
Like

Posted 18 June 2008 - 03:39 AM

Quote:
Original post by zimerman
hi owl,

your enormous depth range (-100000..100000) kills the precision of the depth buffer. try to reduce the depth range to the real extents of your scene...

regards
zimerman


That was it. Thank you very much.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS