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 Jason-H · Apr 13, 2011 at 10:49 PM · texturetexture2d

Two flat textures interfere with each other when both on z=0

Hi everyone, sorry if this has been posted before, I wasn't sure what to search for!

I have two flat game objects moving past each other both flat on the z-plane (z=0) but when they go past each other one texture is never in front of the other, they sort of merge and then snap from one texture to the other. Is there a way to fix this? I assume it's something with layers or tags?

Thanks!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Apr 13, 2011 at 11:01 PM

That's known as z-fighting. A good fix is to use two different shaders, where one is a copy of the other but has Offset -1, -1 in it somewhere. That way it's always drawn in front of the other object even when the surfaces are in the same plane.

Comment
Add comment · Show 4 · 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 Jason-H · Apr 13, 2011 at 11:25 PM 0
Share

Hi Eric, I'm using the "$$anonymous$$obile/Transparent/Vertex color" shader on two different GO's each with a different texture2d. I've put the first GO's material as -1,-1 offset in the inspector but it hasn't changed anything. Is that how I was supposed to do it or am I missing something? Thanks.

avatar image Eric5h5 · Apr 13, 2011 at 11:51 PM 0
Share

@jasonh: No, I'm talking about the shader, not the material. Change the actual shader so it has literally "Offset -1, -1" in the shader itself (put it in the subshader section). Not the offset in the material in the inspector, which is about offsetting UVs.

avatar image Jason-H · Apr 14, 2011 at 09:13 PM 0
Share

I duplicated the shader and added "Offset -1, -1" in the script in this section - Category { SubShader { Pass { Offset -1, -1 } } }

But it hasn't changed anything. Is that the right place to put it? And if so, what else could it be? Thanks.

avatar image Eric5h5 · Apr 14, 2011 at 11:46 PM 0
Share

@jasonh: Not sure if it makes any difference, but try putting it in the SubShader part rather than Pass. Also remember that you need two different materials.

avatar image
1

Answer by Jean-Fabre · Apr 14, 2011 at 08:08 AM

Hi,

Eric5h5 suggestion is good. There is also another way out of this if you control the mesh themselves, by using having the center of each model apart. The one with the center closer to the camera will render first ( If I understand properly this thing...).

Also, if you plan on doing much work with flat textures in 3d, I suggest SM2 if you can afford it for your project, that will be a savvier and propose solutions for z fighting.

Bye,

Jean

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

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

No one has followed this question yet.

Related Questions

Texture2D Copy help 0 Answers

What are possible causes and solutions to randomly garbled textures on standalone builds? 1 Answer

Is it possible to split Texture2D.LoadImage into multiple parts? 1 Answer

How do you crop a Texture2d 1 Answer

How to create mapping areas on a texture 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