Search Unity

Is there any z-fighting preference?

Discussion in 'Editor & General Support' started by HeyNau, Mar 18, 2019.

  1. HeyNau

    HeyNau

    Joined:
    Aug 26, 2015
    Posts:
    10
    In Unity, if you have 2 planes in the same position, there is produced what some people calls z-fighting.
    After looking for a while, I couldn't find any solution to set any kind of z-fighting prerence.

    - I mean, a way to use tags, layers or similar to say: If there is a z-fight, render the layer "Player" overall.

    - Click for an image example -

    I've seen people talking about lightly moving it's position (but it's a voxel game, so it will unsync a lot of positions) or sorting the render mode to always render a layer over the rest, but then the player would be renderer even behind the walls. The point is a preference sort when a z-fighting is there.

    Hope someone knows how to help me!
    Thank you ♥
     
    Last edited: Mar 18, 2019
  2. HeyNau

    HeyNau

    Joined:
    Aug 26, 2015
    Posts:
    10
    SOLVED

    In case anyone have the same problem, I created a default shader and added this line of code:

    Code (CSharp):
    1. Offset 0, -1000
    As big as the -1000 value is, it will be rendered over other meshes in the same position.