custom depth stencil write mask Sometimes it works but not always.

When you disable depth for stencil, the draw order of the meshes will determine which stencil value with end up being on top.