Depth Masking of sprites.

Does this tech work for sprites?

Implemented, but no matter which render queue value I set for masking rectangle it masks all sprites. Is DepthMasking suitable for sprites any how?

Try setting the sorting layer of the renderer you’re using to render the depth only geometry, in the same way that you’d use it to control which sprites render on to of each other. The catch is that unity doesn’t currently expose this in the inspector, so you need to use a custom editor class or explicit code to set the value you want in Start for example.

Also note that you ought to be able to use a SpriteRenderer for this if you change the material to use a depth-only shader, and this might be more comfortable.

hey i have the problem that my DepthMask doesn’t work can anyone give me please a example?

EDIT: get it by myself

Shader "Sprites/SubstractClipping"{
	    _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}

	    Tags{"Queue" = "Transparent"}

	        ZWrite on
	        Offset -1, -1
	        ColorMask 0
	        Blend SrcAlpha OneMinusSrcAlpha

this works fine

I’m working on a game mixing sprite characters with 3D backgrounds. I’ve succesfully used the depth mask shader to punch window “holes” etc. to the wall behind the characters. But is it possible for the sprite characters to pass through these kinds of “holes” (for example if I wanted to make a door in a side wall)? I hadn’t got that working. Works fine with mesh objects though. Is this because sprite renderer does not write to the depth buffer at all?