Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 judy18 · Jul 13, 2017 at 01:29 AM · shaderrenderingmaterialzdepth

z-fighting problem with shaders

Hi, I have a set of muscles in Unity with a standard fade shader applied and for each muscle I have a texture map with an alpha channel and a normal map. The muscles overlap each other and aren't rendering in the correct depth order and I keep seeing weird artifacts as seen here:https://i.gyazo.com/a4ab8a10d015321aef5921f5cd8c9d8e.gif. Apparently, this is a common zdepth rendering problem with transparency shaders. I have tried to address this by using this shader (http://wiki.unity3d.com/index.php?title=AlphaVertexLitZ) or writing in a zOff as per this discussion (http://answers.unity3d.com/questions/562613/transparency-render-issue.html). However, the AlphaVertexLitZ shader doesn't support normal maps and the zOff in shader isn't working for me. I am looking for a solution where I can incorporate texture map with its alpha channel, normal map, and correct rendering depth. I am aware that all of these may be a long shot but any suggestions are appreciated!

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
0

Answer by FortisVenaliter · Jul 13, 2017 at 07:55 PM

There are some code solutions to this... but they tend to be very complicated and often need engine-level support.

Honestly, the best way to solve this problem is not with code, but with art. Unity doesn't sort triangles by depth, but it does sort objects by depth. So if you separate your transparent mesh into separate meshes on separate objects, then it can resolve their depths and draw them in the correct order to maintain the correct visual.

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 judy18 · Jul 13, 2017 at 07:59 PM 0
Share

Thanks for you answer but I already have the muscles as separate objects. Unity is sorting them by depth but in certain views some of the deeper objects switch to surface and surface muscles appear to be behind deeper muscles. Do you by any chance know of any work-arounds to this offhand?

avatar image FortisVenaliter judy18 · Jul 13, 2017 at 08:02 PM 0
Share

Okay, two questions:

You mean that each of the muscles are separate objects, right? It's not just separated between bone and muscle?

Also, it looks like the materials are opaque... for what reason do you need the transparent shader?

avatar image judy18 · Jul 13, 2017 at 09:26 PM 0
Share

yes, each muscle is a separate object. I have the transparent shader because my texture maps have an alpha channel which allows the portions of the muscle to fade out as they approach their attachment sites to bone and other muscle -so it looks like they fade into fibres rather than solid chunkiness. I also have visibility sliders in the UI which allow the user to change the opacity of any object from opaque to completely transparent, so even if I changed the muscle material to opaque inititially I run into the same problem with the visibility sliders.

avatar image FortisVenaliter judy18 · Jul 14, 2017 at 03:43 PM 0
Share

Oookay, gotcha. What I would do then would be to remove those transparent tails into their own separate meshes. That way you could run the rest as opaque, and only the tails would have to be sorted, which, since they take much less screen/depth space, would be much easier to sort and display properly.

avatar image
0

Answer by judy18 · Jul 14, 2017 at 04:54 PM

OK thank you! I also got another suggestion to remove the back of the meshes (so it would just be one-sided surface, no volume)

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

112 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 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

Using Color.Lerp with Lightweight Render Pipeline 1 Answer

How can i get my quad to only render my texture without stretching it? 1 Answer

Standard Terrain Shader Upgrade to URP 1 Answer

URP material set texture scale 0 Answers

How does Material's "SetShaderPassEnabled" work? 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