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
1
Question by d112570 · Nov 17, 2013 at 07:55 PM · shaderstransparencymultiplefighting

Overlapping transparency Shader fighting.

I have 2 Transparent meshes that start fighting on who gets the overhand.

I have 3 picts, the first picts shows how the layer should look without fighting, the 2nd pict shows layer 2 mesh got the overhand the 3rd pict shows the Atmosphere layer is back in place.

1st layer Titan Satellite Sphere, Bumped Specular, Size of 1.

2nd layer Clouds. Transparent Bumped Specular, Size 1.005.

3rd layer Atmosphere. Atmosphere Shader, Size 1.03.

When I turn half way around the 2nd layer kinder blended the 3rd layer out, another half way around the 3rd layer was correctly shown. So 50/50.

Can I please get some insights how to solver this shader fighting? When I turn clouds off, it works 100%. This will also fix my other planets and satellites. Also will fix my planet ring transparency which has a transparency way in the background.

alt text

1.jpg (135.7 kB)
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

1 Reply

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

Answer by duck · Nov 18, 2013 at 09:02 PM

Depth sorting for semi-transparent objects is an ongoing challenge in realtime engines. For a quick summary of why, see this article: http://www.opengl.org/wiki/Transparency_Sorting

So the problem you have, is that the transparent objects are being sorted against each other by their position only, not per screen pixel, because there's no way for the depth buffer to record a semi-transparent depth measurement at the screen pixels that your object is occupying.

Because your three concentric spheres are (I'm guessing) at exactly the same position in world space, Unity can't sensibly decide which to draw first, and the decision is probably coming down to arbitrary inaccuracies and variations in the floating point math when examining their distance from the camera, which is why you probably aren't seeing a sensible pattern as to when they pop back and forth.

There are a couple of workarounds that spring to mind.

  1. Modify the source code for the transparent shader that you want to be in front, and change the part where it says "Queue"="Transparent" to "Queue"="Transparent+1". If it's a built-in unity shader, to do this you'll need to download the source code for the shader that you're using from here. Duplicate it into your project, give it a name such as "priority transparent shader" or something. Then use this shader instead.

  2. An alternative approach could be to have some code on the transparent sphere objects that runs in Update, which constantly keeps the spheres to be drawn in front slightly closer to the camera than the other ones. This will require calculating the direction to the camera and offsetting the position in that direction by a small amount.

Both methods should work. Give whichever one you feel like a try!

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 d112570 · Nov 19, 2013 at 02:34 AM 0
Share

Thankyou so much, I asked this question about a year ago and not did you only answer the question you also solved my z-fighting problem for all my shaders. I only had to change the Atmosphere shader, so if I understand correctly if I would have like another transparent shader I would to like +1 and then other would be +2 correct. Like layer depth.

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

18 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

Related Questions

How to a 3d character transparent? 2 Answers

Can I draw Opaque geometry on top of Sprites, cheaply? 0 Answers

Transparent shader decreases frame rate. Which material i should use for transparent object? 3 Answers

How to paint transparent texture on terrain? 0 Answers

Transparent object makes other objects act strange 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