• 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
2
Question by user-4754 (yahoo) · Sep 16, 2010 at 06:49 PM · shaderrenderingz-fighting

Z Fighting Problem

I have a bunch of planes with alpha textures attached to them. THey are seperated in the Z and do not collide at all. Whe I run in game mode the layers bug out and fight with each other for draw order and flicker back and forth. Any ideas?

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
10

Answer by Eric5h5 · Sep 16, 2010 at 09:14 PM

Make the camera's near clip plane as big as possible, and the far clip plane as small as possible, so the depth buffer's precision isn't wasted.

Comment
Add comment · Show 7 · 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
avatar image user-4754 (yahoo) · Sep 17, 2010 at 01:57 PM 1
Share

Tried that and it had no effect on the problem.

avatar image schwertfisch · Mar 06, 2011 at 05:42 PM 0
Share

I had a similar problem and found this answer very useful. Changing the clip values indeed helped make better use of the camera's depth buffer and everything looks good now. Thanks Eric.

avatar image vestax_ion · Jul 22, 2011 at 03:23 PM 0
Share

Great advice, if you just double the near clipping to 0.7 it already makes a ton of difference, if i make nearby planes overlap by 0.005 and set near clip to that it seems ok from most distances. ill use this comment to add search words: overlap overlapping mesh surfaces vertexes vertex combine mesh

avatar image Bravini · Jul 22, 2011 at 03:32 PM 3
Share

I was so hoping the question would be about dragon ball z :(

avatar image fundead · Mar 17, 2012 at 03:09 AM 0
Share

This did indeed solve the flickering problem for me when implementing an animated skinned mesh comprised of multiple 2D planes. I set the near clip of the camera to 500 and the far clip to 601 and it worked perfectly (but also did with higher and lower values).

Show more comments
avatar image
2

Answer by vestax_ion · Jul 23, 2011 at 08:37 AM

Here is a video about unity depth shader workarounds:

http://www.burgzergarcade.com/tutorials/game-engines/unity3d/unity-ios-shaderlab-tutorial-10-1-z-fighting

also his tutorial 6.2 and 6.3 are all about depth...

and this unity resource: http://unity3d.com/support/documentation/Components/SL-CullAndDepth.html

Here is a Ton of info about it with 3 solutions:

http://software.intel.com/en-us/articles/alternatives-to-using-z-bias-to-fix-z-fighting-issues/

Comment
Add comment · 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
avatar image
1

Answer by Kronnect · Feb 11, 2015 at 01:13 PM

I have ended with a custom-non-optimal-solution that at least works for me. I add a "ZFighter" component to any GameObject which I want to get a little bit distanced from a back object/wall. This separation is calculated according to Camera distance.

 using UnityEngine;
 using System.Collections;
 
 public class ZFighter : MonoBehaviour {
 
     // Use this for initialization
     private Vector3 lastLocalPosition;
     private Vector3 lastCamPos;
     private Vector3 lastPos;
 
        void Start () {
         lastLocalPosition = transform.localPosition;
         lastPos = transform.position;
         lastCamPos = Camera.main.transform.position - Vector3.up; // just to force update on first frame
     }
     
      void Update () {
         Vector3 camPos = Camera.main.transform.position;
         if (camPos != lastCamPos || transform.position != lastPos) {
             lastCamPos = camPos;
             transform.localPosition = lastLocalPosition + (camPos - transform.position) * 0.01f;
             lastPos = transform.position;
         }
     }
 }
 

Comment
Add comment · Show 1 · 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
avatar image EndUser · Dec 12, 2016 at 05:44 PM 0
Share

Interesting! Still leaves a question for water from aeroplane: it will flood all the continent be lifted.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Render texture above something else 1 Answer

Shader limits on iPad 1 Answer

How to render a RenderTexture into a specific mipLevel 0 Answers

Dynamic Batching not working even adhering to all rules 3 Answers

Silhouette Outline Shader and SpriteRenderer 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