Results 1 to 7 of 7

Thread: Sprite Z-fighting again.....

  1. #1
    Member Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Sprite Z-fighting again.....

    Hello, I am working on the particle system for my game again and ran into a new/old problem. I sort the particles and draw them in order and such and, in most cases, there is no z-fighting. However I've noticed that if any of the particles (that are near each other) have different scales or spins (rotations along the viewer's axis) a large amount of z-fighting occurs.

    Here is a screen shot:

    (looks worse in real-time)


    I understand that if the particles are to close for the depth buffer to handle that z-fighting will occur, but how would the sprites being at different scales cause the problem??

    Thanks in advance
    -Josh

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Sprite Z-fighting again.....

    1) Your z depth seem to be badly distributed. Try to put the near plane farther (and the far plane nearer if possible)
    2) If the particles are sorted, why using depth writes at all ? Keep depth testing so that particles are occluded by terrain, but disable depth writes so that so z-fighting can not occur between your particles.

  3. #3
    Member Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Re: Sprite Z-fighting again.....

    Thanks for the reply,
    I disabled depth writes and it did "fix" the problem , but as you mentioned occlusion doesn't occur. Along with that, there is this strange flickering that doesn't look like z-fighting. I think it is related to my sorting function. Perhaps that or something related to that is causing the z-fighting.

    I'll still do not understand why z-fighting would not occur if all particle are the same size, and not if they are different sizes.
    -Josh

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Sprite Z-fighting again.....

    but as you mentioned occlusion doesn't occur.
    With depth writes only for terrain and not for particles, there should be correct occlusion.

    Maybe you don't do the scaling/rotating of particles at the right place, so they twist a bit, and then end up as not parallel.

    So it would not really be z-fighting. You can trying moving the near and far planes as I said : if there no significant changes on the picture, then it is not z-fighting.

  5. #5
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: Sprite Z-fighting again.....

    Zbuffer is right, but your popping is unavoidable with a moving eye as one particle's depth intersects anothers, the best way to improve this is manage more smaller particles (feasible since you'll be heavily fill limited at the moment) or manage their alpha etc but this could take a pretty sophisticated system.

  6. #6
    Member Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Re: Sprite Z-fighting again.....

    There is a popping issue as well, but I don't think the flickering is part of it because it occurs even when the camera is only zooming and not rotating/panning.

    It would not be bad to lower the far plane and and increase the near, but the game will be oriented around distant ocean views, but also close up views when managing characters on the battlefield. So unless there is no other way I'd like to keep it high.

    (After thought) Would it be possible to dynamically manage the near/far clipping plane so that the range increases when the camera zooms out and decreases when the camera zooms in?

    Maybe you don't do the scaling/rotating of particles at the right place, so they twist a bit, and then end up as not parallel.
    I'll look into this, it would make a lot of sense for this to be the case since the z-fighting only occurs when the particles are at different scales/spins.
    -Josh

  7. #7
    Member Contributor
    Join Date
    Sep 2006
    Location
    US(California)
    Posts
    58

    Re: Sprite Z-fighting again.....

    Just wanted to add:
    I decreased the range of depth from 1-800 to 20-200 and that did not affect the z-fighting.
    Perhaps the problem is that there truly is 2 quads on the exact same location for every sprite. This might not be a problem if they were the same size because traded pixels would be the same no matter which pixel takes the nearer depth. And once they become different sizes the pixels would be different.

    [EDIT]
    Confirmed. Case closed Duplicate particles are drawn in exactly the same location.
    [/EDIT]
    -Josh

Similar Threads

  1. Replies: 4
    Last Post: 06-16-2016, 04:47 AM
  2. sorry ... once again z-fighting
    By dawn in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 10-02-2002, 05:15 AM
  3. z-fighting (again?)
    By JacekPoplawski in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 08-11-2002, 11:44 AM
  4. Z-fighting
    By LordKronos in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 04-18-2001, 03:54 PM
  5. Fighting
    By FatalError in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-01-2001, 11:15 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