Z fighting tricks

Discussion in 'Rendering Technology and APIs' started by sergi.gonzalez, Apr 13, 2008.

  1. sergi.gonzalez

    Newcomer

    Joined:
    May 11, 2007
    Messages:
    35
    Likes Received:
    0
    Location:
    Barcelona
    Hi,

    What method to avoid z fighting do you prefer?

    1. Polygon offset function
    2. Eric Lengyel's projection matrix trick (GPG1)
    3. Another method (which?)

    I know that the first method is the most accurate but I think it has performance penalty...

    Your thoughts?

    Cheers,

    S.
     
  2. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    15,720
    Likes Received:
    2,859
    increasing the z buffer depth ;)
     
  3. SuperCow

    Newcomer

    Joined:
    Sep 12, 2002
    Messages:
    106
    Likes Received:
    4
    Location:
    City of cows
    3. Increase the front clip plane parameter passed to your projection matrix function.
     
  4. catisfit

    Regular

    Joined:
    Oct 27, 2007
    Messages:
    638
    Likes Received:
    0
    The combination of these two should be more than enough. What type of scene are you specifically having problems with?

    Read this link, especially the quick example section, and push your near plane out as much as you can.
     
  5. sergi.gonzalez

    Newcomer

    Joined:
    May 11, 2007
    Messages:
    35
    Likes Received:
    0
    Location:
    Barcelona
    I'm looking for a robust method to render decals without z fighting problems.
     
  6. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,560
    Likes Received:
    157
    Location:
    In the Island of Sodor, where the steam trains lie
    Also, if you are using a floating point Z, reverse the "typical" depth mapping so that you instead have screen space 1=>near clip and screen space 0=> far/infinity**.


    **The far clip distance typically has negligible effect on the depth accuracy so you can put far clip at infinity.
     
  7. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    For coplanar objects those two are not sufficient. Any amount of precision won't help. You'll need some kind of bias, either in the projection matrix, in world space or a depth bias.
     
  8. Simon F

    Simon F Tea maker
    Moderator Veteran

    Joined:
    Feb 8, 2002
    Messages:
    4,560
    Likes Received:
    157
    Location:
    In the Island of Sodor, where the steam trains lie
    Perhaps a preprocess step in the modelling phase and multi-texturing in the rendering?
     
  9. OpenGL guy

    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    2,357
    Likes Received:
    28
    That's doable for static decals, but if you have a rectangular wall, and want to add a scorch mark from someone's rocket, that seems like a lot of work to avoid Z fighting as opposed to simply using polygon offset.
     
  10. Thowllly

    Regular

    Joined:
    Feb 6, 2002
    Messages:
    551
    Likes Received:
    4
    Location:
    Norway
    Isn't that exactly what the suggestion was; adding a bias (through moving the near plane)? Or maybe I misinterpretated, coz it was what I was expecting to read...
     
  11. Humus

    Humus Crazy coder
    Veteran

    Joined:
    Feb 6, 2002
    Messages:
    3,217
    Likes Received:
    77
    Location:
    Stockholm, Sweden
    Well, that might work if you apply it only on the decal pass, but the way I understood it I assumed he meant globally pushing the near plane forward, which is something that won't help in that particular case. I'm not sure how well it would work to change the near plane for just one pass though.
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...