Seeing through opaque objects that are close together

I seem to have a problem where you can see through objects that are close together, even slightly overlapping. This model has 20M triangles and I can’t hide the interior because the user is going to be using the slider to show/hide layers. In some models, the “interior” is intentionally visible, so there is no case where I can detect and hide this, either. Performance issues aside, you can see the interior through the exterior, even though the layers abut. I have experimented with overlapping the layers and even using DoubleSide. But it does not solve the problem. Is there a setting that affects this?

This is sometimes called z-fighting, you may find ideas searching for that term.

If the surfaces are very close, but not fully in the same place, then tuning your depth buffer will help. Do this by increasing camera.near and decreasing camera.far until they’re similar to the nearest and farthest surfaces you need to render. Any unused space between those near/far planes is just wasting precision in the depth buffer.

If the surfaces are really in the same place, or co-planar, then this is harder. Splitting surfaces apart and disabling settings like material.depthWrite and material.depthTest may provide some options to help.

Adjusting near/far just causes important parts of the scene to disappear. At least this is true for far values. Near seems show no improvement for values between 0.001 and 10

The surfaces that are showing through (green) are not that close to the objects in front of them (yellow). There is a “solid wall” of yellow triangles in front of the green infill triangles.

What are the near/far values you’re using, and the general size of your scene? Are you using a logarithmic depth buffer? If you can share code or a demo that always makes debugging easier.

I’ll work up an example that you can easily import and run. Although you can see it in the app defaults when you run it for the first time, if you know what to look for. There is a live version hosted at https://grid.space/kiri and the open source repo is here https://github.com/GridSpace/grid-apps

The defaults are 0.1 near and 100000 far. But I’ve tested near from 0.01 to 100 and far from 1000 to 100000 and it makes no difference at all. Scene size is a few hundred cubed up to a few thousand cubed depending on the size of the machine workspace.

Anything particular I need to do to see the issue in the live version linked above? It looks OK to me in the default state.

Here is a workspace you can import (file → import) into 3.6 to reproduce. I wonder if it’s exacerbated by the resolution of retina displays. Possible?

Once imported, just press “p” to preview the print and mouse / rotate display to look at the cube like this. You should see the green showing through. I just tested / exported this. Pressing the “5” key after preview will hide half the layers so you can look inside. Or use the bottom slider.

^Link to the workspace is broken for me!

ooooops. edited. was missing a slash. here it is again.

honestly, I can’t wait for you to tell me I’m doing it all wrong and there’s a massively better way :slight_smile:

Sorry I haven’t been able to see the issue occur here so far… importing the KMZ I get something like this. Previously a shape did show up, but I couldn’t see z-fighting on its surface.

If you see that alert at the top of the page when changing versions, the browser cache is holding onto stale worker code. Shift + reload fixes it. Then you can import the .kmz file. Once the part shows up, you will need to Start -> Preview (left menu) or hit the “P” key to preview. That will slice the object and produce the effect.