Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to handle Z clipping

Discussion in 'General Graphics' started by Deleted User, Sep 17, 2023.

  1. Deleted User

    Deleted User

    Guest

    How would I handle Z clipping for Rigidbodys in unity?
    ezgif-4-699deb4141.gif
     
  2. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    620
    The best solution for z-fighting is simply to not have two overlapping polygons in the exact same plane. Move the triangles or the grass plane a little bit up or down.

    There is something called depth-bias but that's usually a measure of last resort.
     
  3. Deleted User

    Deleted User

    Guest

    These objects are rigidbodys and can often end up on the same plane/terrain due to gravity.
     
  4. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    620
    Colliders don't have to be identical to the rendered mesh. It's actually a good practice to use a simpler mesh for colliders for performance reasons. Often it's even sufficient to use a simple box, sphere or capsule collider instead of a mesh collider.

    Even with a mesh collider you can probably give it a different transform that the rendered mesh (but haven't checked).
     
    Last edited: Sep 17, 2023
  5. Deleted User

    Deleted User

    Guest

    Adding 0.01 to all angles of the collider stops the Z fighting when the rigidbody is not moving.

    For HDRP what other methods can be used for fighting Z clipping?
     
  6. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    620
    Why do you need a different solution for HDRP?
     
  7. Deleted User

    Deleted User

    Guest

    to solve z clipping when snapping objects to eachother.