Results 1 to 5 of 5

Thread: Depth sorting problem

  1. #1
    Member Contributor
    Join Date
    Jun 2001
    Posts
    64

    Depth sorting problem

    I've encountered a strange problem when depth sorting objects and
    I can't figure out what's going on. I use a simple call to qsort()
    to sort objects based on their center points. When I don't sort,
    the objects are rendered with no problems. However, when I do
    sort, there are alot of z-buffer artifacts (tiny black specs) all
    over my model. I though it might have to do with toggling
    glDepthMask from FALSE to TRUE when rendering translucent objects,
    so I removed all translucent objects and commented out the glDepthMask
    toggling, and I still got the same problem with sorting solid objects
    only. I know my zbuffer is setup fine. What the heck is going on?

    I just hoping someone else has came across the same problem before.

  2. #2
    Member Contributor
    Join Date
    Jun 2001
    Posts
    64

    Re: Depth sorting problem

    Any suggestions?

    I have a 16-bit zbuffer that is fixed at znear=1 and zfar=1000
    which renders ok. Objects in the scene are typically less
    than 100 units or so. Qsort() sorts all objects, solid and
    translucent, from back to front.

    I don't see what is wrong with this setup.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    London
    Posts
    14

    Re: Depth sorting problem

    Have you tried making your own sorting method for the faces. Also y do you want to sort the faces in the first place?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Depth sorting problem

    The proper rendering order is as follows:

    1. Farthest triangles e.g. background, sky, etc.
    2. Solid triangles with depth testing and depth writing enabled
    3. Transparent triangles with depth testing enabled, but depth writes disabled (masked)
    4. Nearest triangles e.g. foreground, text, etc.

    Note, for step 1 you can disable both depth testing and depth writes, however, if your scene has no transparent triangles, you might get a performance boost if you do this step as step 3.5 with depth testing enabled.
    For step 2, it would be best if the solid triangles were presorted in nearest to farthest order, however how much performance you gain from this will of course vary, so you may want to try both sorting them and not sorting them to see the performance difference, if any.
    For step 3, the transparent triangles should be sorted from farthest to nearest, unless then blending being used is commutative, in which case the order doesn't matter, normally the order will matter however.


    [This message has been edited by DFrey (edited 10-20-2001).]

  5. #5
    Member Contributor
    Join Date
    Jun 2001
    Posts
    64

    Re: Depth sorting problem

    DFrey:

    It worked!

    I sorted the solid objects from nearest to farthest, and the
    translucent/transparent objects from farthest to nearest,
    instead of sorting everything one particular way.

    Why changing the sorting order of solid objects worked, I still
    don't understand. It shouldn't matter, as far as I know, but
    it did.

Similar Threads

  1. Depth sorting.
    By MrShoe in forum OpenGL: Advanced Coding
    Replies: 15
    Last Post: 08-25-2004, 03:17 AM
  2. problem w/ depth sorting
    By duhroach in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-18-2003, 04:05 PM
  3. Do I need Depth Sorting?
    By B_old in forum OpenGL: Basic Coding
    Replies: 15
    Last Post: 12-09-2002, 12:04 PM
  4. Depth Sorting
    By imported_Theo in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-13-2001, 01:09 PM
  5. How can i do depth sorting
    By mczhao in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-09-2000, 05:20 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