Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Crazy Z Fighting in Editor

Discussion in 'Editor & General Support' started by simonwittber, Sep 12, 2011.

  1. simonwittber

    simonwittber

    Joined:
    May 13, 2008
    Posts:
    228
    I'm getting extreme Z Fighting on objects that are not very close together at all, in the main scene view. Screenshot is attached.

    Is anyone else getting this behaviour? Is there a fix?
     

    Attached Files:

  2. Bovine

    Bovine

    Joined:
    Oct 13, 2010
    Posts:
    177
    I have the same unsightly problem, presumably to do with the near and far clip planes and how the z-buffer weights objects further from the camera?
     
  3. DamienSturdy

    DamienSturdy

    Joined:
    Jan 30, 2010
    Posts:
    39
    What are you compiling for? If I compile for Android, I get this due to Unity using a smaller 16-bit Z buffer (Don't think there's a reason for this, but I find it handy as you WILL get the same problem on the device itself.)

    If you're not compiling for a mobile device, you might simply be using a 16 bit buffer, for some other reason (usually drivers.)
     
  4. funshark

    funshark

    Joined:
    Mar 24, 2009
    Posts:
    225
    Check your camera settings first ( near far ) and do a F ( focus ) on the big object that is flickering.
     
  5. Bovine

    Bovine

    Joined:
    Oct 13, 2010
    Posts:
    177
    Sounds like it's to do with emulation - I'm building ATM, so it may be I can just turn of OpenGL ES 2.0 emulation - will take a look shortly...

    I have to say that I don't see this z-fighting in game, even in the game window in the editor and I don't see it on the device, only in the editor window and it only appeared since 3.4...

    I've done some to the metal coding of OpenGL ES on my iPhone 3G and 3G S (before I had my shiny new 4S), but I don't recall being limited to a 16bit z-buffer, but maybe that is an option - certainly it was for the colour buffer...

    UPDATE: turning off emulation makes it go away, but I don't get why it would be there in the first place. Fine if it's emulating the z-depth precision on the device, but IMHO it doesn't appear to be showing an accurate representation of it. Near and far clip planes affect the extent to which one will get z-fighting. My near clip plane is 0.3 - if I changed this to 0.01 say, then I'd see much of the nasty z-fighting as in the editor I suspect, so as the z-fighting it a function of these different parameters, there really should be some place I can set the near and far clip-planes
     
    Last edited: Oct 23, 2011
  6. Bovine

    Bovine

    Joined:
    Oct 13, 2010
    Posts:
    177
    This is in the editor, not on the device: so to my knowledge there is no camera to edit :eek:/
     
    Last edited: Oct 23, 2011
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Try it. Select the flickering object, press F with the mouse over it. It will fix it. The editor has it's own camera with it's own z buffer problems, solved with this workflow.
     
  8. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,623
    As pointed earlier it is due to gles emulation. On Android - there are some devices with 16bit only depth buffer, and they can show your scene like this. On the other hand, it will be "fixed" in 3.5:
    on ios - all devices support 24bit depth and we use it, so no need to emulate it like this
    on android - there will be checkbox to try and force 24bit depth on device; if you set this - you will see no artefacts [as 24bit depth will be created in editor too]
     
  9. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628
    I get this same issue in 4x android in 2013...any ideas?
     
  10. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,628


    Bump, still same issue.
     
    Last edited: Jul 24, 2013
  11. smtabatabaie

    smtabatabaie

    Joined:
    May 6, 2013
    Posts:
    45
    Any solutions to this ? I'm having the same problem in my project
     
  12. funshark

    funshark

    Joined:
    Mar 24, 2009
    Posts:
    225
    Describe your problem precisely because we can't help otherwise
     
  13. MODev

    MODev

    Joined:
    Jul 30, 2013
    Posts:
    229
    Have you tried to increase znear and decrease zfar as much as you can accept this? ZBuffor will have less problems with resolving zfighting things:)