How can I manage the ZDepth for a fade object- Shader Unity

Hi guys,

I try to cut a fade Object in my scene. This Fade object has a Standard Shader with “pragma alpha” to change his opacity value at runtime with C#.


The problem of the “alpha” property is the object has some artefacts on it
114614-bug3.png

So I use the ZWrite On option in a Pass to fixe it.


But now I have a problem with this ZBuffer because it hides me part of my object like :

114355-bug.png


Someone has an idea ? Maybe a Unity developer can help me because nobody speaking about that and I checking a solution since few days.


Thanks

In the first picture it looks like there are 2 meshes on top of each other, is that the case? Does the shader have multiple passes? Would you mind posting your shader?

You can always debug your ZBuffer by messing around with ZTest: Unity - Manual: ShaderLab: commands

Hi,

I use my shader to dynamically managing object’s opactiy at runtime and to cut my objects when they intersect a plane.
To do that, I’m discarding the pixel when his distance to the plane is < 0.

But I forgot to do the same in the Pass managing the ZDepth.

My error was here. Just need to add the same condition to discard pixel color in depth Pass.