Specifically, the problem occurs when two objects that both have the outline shader are very close to each other, as depending on the camera angle (I think), one of the two object’s outlines is visible even though it should be hidden behind the object in front of the surface.
Note that the objects have no outline thickness, so it’s just the silhouette that shows up if the object is behind another object that does not have an outline shader.
I don’t know much about shaders, but maybe there is a simple fix for this kind of behavior? From my very limited knowledge of shader coding I think it might have something to do with Z-testing/-writing or culling. Still, it’s weird that this only occurs if the two objects are very close to each other.
1: The two objects next to each other, both are the same size and height
2: How it should always work; The red cube is in front of the yellow one and nothing shows through.
3: the red cube is a little behind the yellow one and overlaps it. Here, the yellow cube’s silhouette shows through even though it should be hidden.
4: Here, the red cube is a little bit nearer to the camera, and suddenly it’s the red cube’s silhouette that is showing through