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 CookieSteve · Oct 13, 2017 at 06:02 AM · meshlightingtransparencyspherelayering

Is it possible for transparent spheres to look like they're intersecting?

This is an interesting problem I'm having, and I'm not sure there's going to be an easy solution to it.

For my game, it's necessary for the user to be able to see the intersecting line between transparent spheres. If I use an opaque material, you can see what I'm talking about:

alt text

Notice how the line between the two spheres is clearly visible? That's the effect I'm looking for, only with transparent spheres instead of opaque ones (so you can see part of one sphere overlapping inside of the other).

However, when I make the sphere materials transparent, this is what happens instead:

alt text

The spheres do not appear to intersect at all. Instead, it always seems as if one sphere is completely in front of the other one. (Note that the only difference between these two shots is that the position of the camera has shifted slightly, which causes one sphere to take priority over the other one.) It's not just in the editor either; this effect also applies when the game is actually in runtime.

Is there any way to fix this? Is the effect I'm trying to even achieve even possible within Unity?

(These images were taken with Legacy Specular and Legacy Transparent Diffuse, though it didn't seem like any of the other default transparent shaders worked any better)

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
0

Answer by Bunny83 · Oct 13, 2017 at 06:34 AM

Uhm, do the sphere's actually have any alpha value smaller than 1? It looks like you still render them opaque.

Almost all transparent shaders do not write into the depth buffer to prevent unwanted clipping. However that only makes sense then the objects are actually transparent. One solution is to create a shader that writes to the depth buffer, however keep in mind that transparent geometry is sorted from back to front based on the distance of objects origin from the camera.

That however means when your shader writes to the depth buffer only one sphere can be seen inside the other. The one that is drawn first will be visible inside the other. The one that is drawn last won't be visible in the inside of the first sphere as the depth buffer prevents that. Though that's actually what forms the intersection line.

The only proper solution would be to split the two sphere meshes at the intersection circle into two parts each and render them in the right order. Which means the two smaller caps which are inside should be drawn first and the larger part of the spheres would be drawn last. This is of course not really feasible if those spheres should move / intersect dynamically.

Another way would be to use a multipass shader and some stencil operations

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 CookieSteve · Oct 13, 2017 at 10:13 AM 0
Share

I had the spheres at a nearly opaque level so the effect could be seen more clearly. The problem still persists at different alpha levels.

Shame about that depth buffer stuff. It's pretty much necessary for the spheres to intersect dynamically, so I suppose splitting the spheres isn't a feasible option. I'm curious about that multipass approach, though. Could you elaborate on it a bit more?

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

95 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

Related Questions

Light creates distortion on mesh? 1 Answer

Light and 2D Sprite overlapping issue 1 Answer

How Can I Make a Large Flat Surface Lit By Many Lights? 3 Answers

Why are some of my sprites brighter than others? 1 Answer

Randomize Sphere & Smooth Vertex ( like in blender) 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