Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by pdunton · Jan 30, 2014 at 04:55 AM · meshplane

Rendering Issue

I have two planes that represent different grounds in my scene. The first is a blank texture with A value of 150 and alpha of 130 (it's grey), and the second has a value of 100 and alpha of 130 (it's black). I need to have them at similar levels, because they way the game works is if you step on the black you lose health, but I know that if i put them both at a y of 0 they will flicker, so I put the black one 0.1 below the gray one, but they still flicker, this is really annoying and looks bad, can you help? Thanks!

Comment
Add comment · Show 2
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 Manco Capac · Jan 30, 2014 at 05:42 AM 0
Share

this depends on your game world size. try increasing the distance between them, just check that it isnt visible, and set it to not cast shadows. also it's better to use cubes (at least for my game it is :p )

avatar image pdunton · Feb 01, 2014 at 03:14 AM 0
Share

Good Idea $$anonymous$$anco, I will use cubes.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by supernat · Jan 30, 2014 at 06:26 AM

There are several ways to do it. Look up how to add decals for one. However, in the short term, you can adjust your camera's near clip plane to a higher value and the far clip plane to a lower value. The reason for the Z fighting (flicker) is due to the resolution you are provided in the Z (Depth) Buffer. So, let's say you draw one plane. That plane will set a value in the Depth buffer for each pixel saying "I've drawn a pixel at this depth!", so when the second plane draws, the render pipeline says "Is there anything already in the depth buffer for this pixel, and if so, is it closer than the pixel I want to draw now?" So what happens is you can only store a depth value with some pre-defined precision, and that precision is based on your near and far clip planes. Without getting into the math, it's basically a ratio of your near plane over your far plane. Check out: http://en.wikipedia.org/wiki/Z-fighting

Often times, when you draw two things too close together, they are considered co-planar if the depth buffer can't distinguish the distance between them. What I mean is that the depth buffer will have the same value of depth for both of them in some places and not others. The Z fighting occurs when you move, because you are seeing the implication of a single bit of precision change in the depth buffer.

Anyway, you should always set the near plane to be as far out as makes sense for your game, and always set the far plane as close as makes sense. Another thing you can do is add a bias to the shader for one of the planes. The bias adds a "fake" offset that makes the plane either closer or farther away (it can be + and -). The common name for this is Z Bias, but Unity calls it Offset in the shader: http://docs.unity3d.com/Documentation/Components/SL-CullAndDepth.html

Another approach you could take is to set the Z Test to always pass when drawing the tile that should ALWAYS be drawn on top of the other tile. That means the thing drawn on top will be stored in the depth and color buffers, and anything you draw later will still obey and overwrite that. You have to make sure you set the shader queue up properly though so the shader for the bottom tile always draws first.

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 pdunton · Feb 01, 2014 at 03:59 AM 0
Share

Ok, so I tried some things on all of the suggestions you told me. As for changing the clipping planes, I changed them to what made sense for my game and it didn't appear to do anything. For adding the Z Bias, I looked at the Wiki and the other page you referenced, and I have no idea how I would add the Offset. I guess I didn't know shaders were scripts, and know nothing about them. Again with the Z Test, no idea what's going on here. I appreciate your hard work on this, this must have taken a while to write. Thanks!

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.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

How would I deform a plane surface with a bumped line? (image attached) 1 Answer

How do I transform only the mesh I want in unity? 0 Answers

How do you use the Plane struct 1 Answer

Plane: vertices and triangles 2 Answers

Creating a 3D Plane Mesh Without a Filled Center 1 Answer


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