- Home /
Disabled ZWrite - Managing ZDepth Shader Unity
Hi everyone,
I have an object, a part of it can be unvisible and the other part is visible. But with the depth managing in the shader, when a pixel is Clip(), it's always here, transparent, but always here. :(
Why I'm using ZDepth ? Because I would like manging the object's opacity. So I need a Fade Shader. But without the ZDepth the fade shader is unperfect.
I find a solution, it's to change Zwrite set-up to Off. But I can't change it dynamically with C# or in the Shader. (I don't found the way to do that).
Here it what I see from a point of view (unvisible part of the object hide me the other part)
Here it's the visible part of the object.(no unvisible part hide me the object)
I would like find a solution like : this pixel is clip so ZWrite Off too.
Any idea ?
Thanks !
I don't quite understand your problem. If you use "clip" in a shader the fragment is discarded. Nothing will be written to any buffer (neither the color nor the depth buffer). If you don't talk about actually clipping a fragment in a shader you should be more clear what you actually mean by clipping. If you use custom shaders, post links to them or include them in your question.
Your answer
![](https://koobas.hobune.stream/wayback/20220612160205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Wrong Depth texture being passed into the shader. 0 Answers
Increasing the level of detail with a depth render 0 Answers
Shader based camera compositing. 2 Answers
Distance from pixel to camera in shader 0 Answers
UI shader write to depth buffer 2 Answers