Enable sprite depth write.

I’m using the new Unity 2D sprite functionality, it seems that in doing so, none of the sprites write any values to the zbuffer. Is there a simple way to enable zwrite?

Additionally, is there any way to find the source for say the shader behind the Sprites-Default shader?

1 Answer

1

I figured this out by downloading the built-in shaders from http://download.unity3d.com/download_unity/builtin_shaders-4.3.0.zip making a duplicate of sprites-default.shader called sprites-zwrite. And within the shader changing the lines:

"RenderType"="Transparent"

and

ZWrite Off

to

"RenderType"="TransparentCutout"

and

ZWrite On

Then using that new shader in all of my sprites.

thanks guy!! it helped me!!

Hi! i am trying the same thing in Unity 5.1.3. Did exactly what you described, but the sprite is still not writing into z-buffer. I need it for DOF effect to work on my sprites in the scene... someone got such problems as well?