- Home /
Custom Transparency shader occasionally losing transparency?
These images display the issue:
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
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...
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
No, the planet is the top one, it just has 'Cull Back'. Which means don't render any faces not pointing at the camera.
Hmmm, strange for it to cause problems. Try adding the Queue="Geometry" tag to your planet; should be automatic though.
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.
Yeah, that was my first thought, but the planet is not transparent... and it's an issue between the planet and the clouds.
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
Follow this Question
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