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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Jazzer008 · Aug 13, 2013 at 06:06 AM · shadertransparencycustomblackdepth-buffer

Custom Transparency shader occasionally losing transparency?

These images display the issue:

NormalProblem

So as you can see, the first image is the desired outcome. But for some unknown reason almost every 3/5 generations the cloud shader loses it's transparency.

The cloud shader uses the same techniques as the planet shader, a perlin noise generator provides the information I need to colour the planet. In the cloud shader I use this perlin info to choose the alpha. The cloud color is white, so anything black should be alpha less!

UPDATE:

I've just found that it is actually still transparent, but for some reason it is interacting with the planet shader. I can move an object behind the cloud layer and it is perfectly visible, and yet the planet layer won't show up unless I deactivate the clouds. Hmm. : /

UPDATE 2:

I've now narrowed it down to a z-buffer issue. Adding ZWrite Off to the cloud shader now means the planet will always be visible, but now occasionally the cloud layer will disappear, it's actually being rendered, behind the planet. But why only occasionally? The only varying factor in my code is the perlin seed.

My shader tagging setup for all three:

Planet shader

 Cull Back

Cloud shader

 Tags{
 
                 "Queue"="Transparent"
                 "IgnoreProjector"="True"
                 "RenderType"="Transparent"
 
                 }
 
             Cull Back
             ZWrite Off
 
             Blend SrcAlpha OneMinusSrcAlpha

Atmosphere shader

 Tags
     {
         
         "Queue"="Transparent"
         "IgnoreProjector"="True"
         "RenderType"="Transparent"
 
     }
 
        
 Cull Back
 ZWrite Off
 ZTest Less


Anyway, if you've seen this before or have any ideas as to what might be the problem then I would be really grateful for your help. I plan to upload this as a package to the asset store, so I can't reveal too much of my shader code. :P But if you have any specific areas you would like me to check then go for it.

PS: Sorry for being so messy, community edit has been switched on. :P

Comment
Add comment · Show 13
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 Joyrider · Aug 13, 2013 at 06:48 AM 0
Share

I get your predicament, but it's kinda difficult to help you out without seeing the code... unless you have a very specific error, or a very common or identifiable event, problems can come from a variety of stuff, ranging from stupid overlooked typos to advanced implementation procedures...

avatar image Jazzer008 · Aug 13, 2013 at 06:58 AM 0
Share

Yep, I understand but I can't reveal too much. I've actually been slowly narrowing the issue down.

Seems like it's a problem with the z buffering. The clouds and atmosphere are always in the right order, but the planet and the clouds sometimes get mixed up. Now that I've added ZWrite Off to the cloud shader, the clouds will now occasionally go 'behind' the planet, and therefore disappear.

$$anonymous$$y tag setup for all three shaders is as follows:

Planet shader

 Cull Back

Cloud shader

 Tags{
 
                 "Queue"="Transparent"
                 "IgnoreProjector"="True"
                 "RenderType"="Transparent"
 
                 }
 
             Cull Back
             ZWrite Off
 
             Blend SrcAlpha One$$anonymous$$inusSrcAlpha

Atmosphere shader

 Tags
     {
         
         "Queue"="Transparent"
         "IgnoreProjector"="True"
         "RenderType"="Transparent"
 
     }
 
        
 Cull Back
 ZWrite Off
 ZTest Less
avatar image Joyrider · Aug 13, 2013 at 07:02 AM 0
Share

your planet has transparency too?

avatar image Jazzer008 · Aug 13, 2013 at 07:03 AM 0
Share

No, the planet is the top one, it just has 'Cull Back'. Which means don't render any faces not pointing at the camera.

avatar image Joyrider · Aug 13, 2013 at 07:06 AM 0
Share

Hmmm, strange for it to cause problems. Try adding the Queue="Geometry" tag to your planet; should be automatic though.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Paulius-Liekis · Aug 13, 2013 at 07:40 AM

This might be a sorting issue if all your objects are on Transparent queue. You could try setting queue for your clouds to Transparent+1.

Comment
Add comment · Show 2 · 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 Joyrider · Aug 13, 2013 at 07:41 AM 0
Share

Yeah, that was my first thought, but the planet is not transparent... and it's an issue between the planet and the clouds.

avatar image Jazzer008 · Aug 13, 2013 at 07:51 AM 0
Share

Yes, only my clouds and atmosphere are transparent. And they sort correctly. It's just the planet and clouds that get mixed up occasionally.

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 handle eyeballs on a transparent character? 0 Answers

Modifying the depth buffer of an image effect? 0 Answers

Mesh based volumetric lighting with RenderTexture 1 Answer

Is it possible to create a blur effect based on the alpha of a transparent texture on a plane? 0 Answers

Apply a bumped shader on top of a custom vertex shader 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