Leaks between planes with different material

Is there a way to avoid those small leaks between different objects in level geometry? Even if planes are snapped perfectly together, I can see some pixels displaying skybox at the edges of them. Usually it happens with objects with different materials(texture atlases). What is causing this? Any ideas?

Also, keep in mind that objects that in theory should be snapped ‘perfectly’ together may in fact not match exactly at the seams. For example, if your planes are subject to arbitrary transforms, numerical error will likely result in ‘sparklies’ or other artifacts where the planes meet.

A reliable solution is to use a procedurally generated mesh (or multiple meshes), although that’s a little more involved than using individual transformed game objects.

In most cases it’s a problem with the depthbuffer resolution.

The resolution can be determined by dividing Camera.farClipPlane(1000) by Camera.nearClipPlane(0.3).

The endresult that is stored in the depthbuffer is mapped between 0…1 but the greater the viewingfrustum is the more inaccurate the depth value get. You could try to increase the near value and decrease the far value (to fit your needs).

Another way, which is not possible in a lot cases, would be to let the objects overlap a little bit. Something like 0.00001 should be enough.

Different materials shouldn’t be a problem since it depends only on the geometry.