- Home /
Clear depth buffer after each mesh
Is it possible to clear the depth buffer after each draw call? I want each mesh to have access to a depth buffer, but don't want it to have any effect on other meshes.
The reason I want to do this is because I have meshes clipping against each other, and I'd rather sacrifice some realism to avoid it. I don't want to do it with colliders, either, because each object is independently controlled and there are a lot of them (dozens). They're not supposed to interact; they just look bad when they clip each other.
I realize this could be simulated by using multiple cameras and setting each to clear depth, but each extra camera has huge overhead, and I also lose automatic mesh sorting.
I've tried: Using ZWrite Off or ZTest Always - These both work, but they draw artifacts in the individual meshes that look awful (because each INDIVIDUAL mesh needs a depth buffer, but they don't need to be compared to EACH OTHER).
It would be nice to have something like OnPostRender, but have it work for each object rather than the camera's full scene. That way I could call GL.Clear after each.
Is there something I'm not thinking of?