Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Objects behind other objects...

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    burbank, ca
    Posts
    5

    Objects behind other objects...

    I'm using gluperspective for a program (solar sys type thing), and the program draws objects that are behind other objects.
    What commands determine whether something is drawn or not?
    With gluperspective, you shift the system, while when I used glortho, objects were drawn correctly, not overdrawing each other.

    More specifically, when an object moves about the center of the system, the system rotates with it so that you "ride" the planet so to speak. Since the arctangent function returns a number between pi/2 and
    -pi/2, at pi/2 increasing, the vector orthogonalizes and rather than follow earth around, you're on the exact opposite side of the sun....that's fixable, however, when I use gldepthfunc gl_greater, then as you follow earth (assuming it's on the interval where it follows it correctly), the moon always ends up hidden when it passes, when I use gl_less it always end up showing, even when it's in behind the earth with respect to the viewport.
    Does that mean I have to constantly toggle between the depthfunc constants? That doesn't make sense since to do that I could just create a drawing order.
    All help appreciated.




    [This message has been edited by Kurt B (edited 05-23-2000).]

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    burbank, ca
    Posts
    5

    Re: Objects behind other objects...

    Whoops..meant to edit and wound up reposting the message...sorry

    [This message has been edited by Kurt B (edited 05-23-2000).]

  3. #3
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: Objects behind other objects...

    Hmmm ... yuo must have done some mistake in your code, you should really not need to switch depth function anytime.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: Objects behind other objects...

    how you setup gluPerspective?
    you should NOT specify a hiter (near clipping plane) equal to 0: 1e-1 is a good value, instead.

    Dolo/\/\ightY
    Dolo/\/\ightY

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    burbank, ca
    Posts
    5

    Re: Objects behind other objects...

    Okay...I did have the near plane set to 0.
    I changed it to .000001 or something.Thanks

    However, I was beginning to think the problem was elsewhere and began rewriting it....
    I setup the program so that the motion was in the xy plane. Objects in general move about the xyplane. Now, if the depthfunc is only looking at the z coordinates of the objects, it would find them all to be zero. I was thinking THAT was the problem. Even though the view is zoomed into the planets and it follows them in perspective, the depthfunc doesn't know that with respect to the viewer, objects that are closer, say in X should be overdrawing others. I guess depthfunc would have to determine where the viewport is, what's going on there, and decide closeness--which I doubt it would do.
    Anyway, I'm rewriting the program to work in XZ and make the Y axis the vertical Axis.

    Thanks for the help. I'll see what happens.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Objects behind other objects...

    Would like to say a few words about near clipping plane.

    The documentation in MSCV6 says that you lose log2(far/near) bits of depthbufferprecision. This means that if you set far to, say 1000, and near to 0.000001, you will lose loads of bits in precision. If you set near to 0.1, you will gain more bits in precision, but I can guarantee you will not notice any difference (if you have your far plane at 100 or more). I usually use a near:far ratio of 1:10000.

  7. #7
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: Objects behind other objects...

    Why do i lose log2(far/near) bits of depth precision? I had far=6000 and near=1 and noticed some z aliasing with 16 bit depth buffer, but setting near=10 helped alot.
    Can someone explain why this happens? Doesn't the depthbuffer store just the depthvalue linearly between near and far?

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Objects behind other objects...

    No, Z-buffer values behave like floating-point numbers, so most of their range is concentrated toward the near clipping plane.

  9. #9
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: Objects behind other objects...

    I thought that was a W-buffer. What is then a w-buffer?

  10. #10
    Member Contributor
    Join Date
    May 2000
    Posts
    72

    Re: Objects behind other objects...

    W-buffer has even world-space distribution of depth values. There is the same precision no matter how far away an object is...

    And that "losing depth precision" thing :
    It's the ratio of near/far that matters... the bigger near is, the more concentrated depth values near you are spread out (is that comprehensible?)

Page 1 of 3 123 LastLast

Similar Threads

  1. depth buffer: far objects bleed through closer objects
    By geohoffman49431 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-15-2004, 10:47 AM
  2. Replies: 4
    Last Post: 12-30-2003, 10:49 AM
  3. GLslang: no reuse of shader objects in other program objects?
    By Ostsol in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-29-2003, 11:22 PM
  4. Can nurbs objects and curves be used as b-spline objects?
    By BigShooter in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-04-2003, 09:42 AM
  5. Replies: 2
    Last Post: 05-24-2002, 06:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean