- Home /
Standard Shader - Transparent/Fade Issue
Hello,
I have a model of a car that is currently using the Standard-Opaque shader, with a metallic look applied to it.
At some point in my game, I wish for this car to Fade out, by turning Transparent. However, when I change the material to Standard-Transparent, the mesh z-depth appears very incorrect.
As you can see, mesh from a non-visible angle are appearing. In fact using the Transparent / Fade shader on any complex mesh always gives incorrect results.
Am I missing something here?
This is considered normal behaviour. Even modern graphic cards have trouble z-sorting of surfaces on the same object, which means that there is only one way around it, which may or may not be applicable to you: Each transparent surface that is behind another transparent surface needs to be part of a seperate gameobject.
Answer by Insurecti · Jun 28, 2019 at 05:15 AM
For those still struggling with this like me, Unity has a say in it: https://docs.unity3d.com/Manual/SL-CullAndDepth.html
Look under "Transparent shader with depth writes".
Like the people above said, the transparent Shaders ignore Z-Order. Just write a new Shader, using the code provided on the link. It will enable Z-Order and call the standard transparent Shader. Worked like a charm here.
Answer by cgarossi · Jun 12, 2017 at 03:31 PM
Have you tried changing the render queue? This happens when you have clashing materials with the same queue priority.
Hello, regarding the body of the car - thats one entire mesh. So this wouldn't make a difference right? I can understand if it's a collection of different meshes though (like my tyre).
Answer by JonPQ · Jun 13, 2017 at 01:13 AM
this is a classic computer rendering problem. transparent polygons are not sorted, they are rendered in arbitrary order. your model has a lot of internal geometry. When rendering solid... z-buffer sorting solves your issue. But not when transparent, as sorting is off.... several options.... none too simple. 1) Get a car model without so much internal geometry... it will still have the render problem, but not look as bad 2) Get a 2 pass shader... with Z-write enabled, that renders z-depth only first... then renders again the transparent polygons, will solve your issue as it will only render the closest geom, not internal geometry, but hard to find that shader perhaps. Try the unity shader wiki (I'd go with this option)
Answer by MatrixTai · Jun 13, 2017 at 10:21 AM
Maybe, just I guess, you should try to render the transparent part first. Open a new standard .shader, and then type
SubShader{
Tags {
"Queue" = "Geometry+1001"
}
Pass{...
The rendering procedural will be "Cutout -> Skybox -> Transparent -> Geometry" instead of "Geometry -> Cutout -> Skybox -> Transparent". Just my guess, I don't have material displayed like that for testing.
Answer by Helllllllo · Feb 03, 2018 at 08:04 AM
SubShader{
Pass
{
ZWrite On
ColorMask 0
}
...
it work for me
Your answer
Follow this Question
Related Questions
Transparency cutting opaque mesh 0 Answers
z-fighting problem with shaders 2 Answers
Material doesn't have a color property '_Color' 4 Answers
HDRP Lit Shader: How to disable Transparency "Blend preserve" through script? 0 Answers
How to change RGB base of material via scripting (Normal map + base RGB) ? 1 Answer