• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Logopolis · Feb 18, 2016 at 07:11 PM · androidunity 5depthdepth bufferz fighting

How to force Android to use a 24-bit depth buffer in Unity 5, to prevent z fighting?

I've been seeing problems in my game with "z fighting" between terrain and water. It looks perfect on PC, but on my Samsung Galaxy Note 8 Android device, the resolution of the depth buffer is inadequate and z fighting results in the appearance of what look like horizontal ridges at the water line. I was able to ameliorate t$$anonymous$$s problem by increasing the camera's near clip plane from 0.3 to 50.0, but the problem is still there (See image below).

Because it looks great on the PC, but the depth resolution is too coarse on the Android device, it appears that the Android device is using a 16-bit depth buffer rather than the standard 24-bit depth buffer.

Unity used to have a setting in the Android Player Settings, called "Use 24-bit Depth Buffer", to force an Android device to use a 24-bit depth buffer rather than 16-bit. T$$anonymous$$s option was removed in Unity 5. The notes on "What's new in Unity 5" (https://unity3d.com/unity/whats-new/unity-5.0) state "Replaced 16bit depth buffer support with the ability to completely disable depth and stencil buffers." T$$anonymous$$s seems to imply that 16-bit depth buffers are out, and all depth buffers will be 24-bit from now on, but nonetheless the poor depth resolution I'm seeing on Android (whereas the same game looks great on PC) indicates that in Unity 5 it's still using a 16-bit depth buffer on t$$anonymous$$s Android device.

Is there any way in Unity 5 to force an Android device to use a 24-bit depth buffer? Or any other solution to t$$anonymous$$s problem?

alt text

img-3003.jpg (96.3 kB)
Comment
dttngan91
dejanpej
PitaNGura

People who like this

3 Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Feb 18, 2016 at 09:16 PM 0
Share

I don't know If that's even the right direction, but I found two entries in the docs that might be the way you go:

http://docs.unity3d.com/ScriptReference/DepthTextureMode.Depth.html

http://docs.unity3d.com/ScriptReference/Camera-depthTextureMode.html

avatar image Logopolis hexagonius · Feb 20, 2016 at 12:04 AM 0
Share

Thanks for the links. I did attach a script to the camera that makes sure the depth buffer is turned on, in the start function:

     void Start ()
     {
         GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
     }

This didn't make any difference, however. The problem doesn't seem to be that it's missing a depth buffer; the depth buffer just seems to have too little depth resolution, with distinct visible "steps" of depth at a good distance from the camera. All I can imagine is that it's using a 16-bit depth buffer (on this particular Android device) rather than 24-bit. It looks fine on PC and iOS.

avatar image FortisVenaliter · Feb 18, 2016 at 10:03 PM 0
Share

Just out of curiosity, what is your clip range? As long as you follow the 1:1000 rule, you shouldn't have too much trouble with the z-fighting...

avatar image Logopolis FortisVenaliter · Feb 20, 2016 at 12:10 AM 0
Share

Near clip plane is 50, far is 2000. 1:40 ratio, so I would expect it should be fine. And it does look great on PC and iOS. It's just on Android (particularly the Samsung Galaxy Note 8) that I'm seeing the z fighting -- I think because it's using a 16-bit depth buffer rather than 24-bit.

I was originally using the default 0.3->4000 clip planes, and had much worse results on the Android device (still looked fine on PC and iOS). By decreasing the clipping range the results are greatly improved, but still poor.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by PitaNGura · Apr 20, 2020 at 07:24 PM

Did you find any solution to your problem? I have a problem with an UI mask and I read online that the only fix is changing the depth buffer to 24 bit but it doesn't seem like having any way of doing that.

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

65 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android build error: unrecognized pixel format 264 0 Answers

When I load Unity5 application on android phono. It is not working. ERROR : Unfortunatly(gameName) has stopped 1 Answer

Trouble getting to DIRECTORY_MUSIC in Android 0 Answers

Unable to run unity ARCore as AAR library 0 Answers

Control Unity Scenes with Android studio button click(Intents)... 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges