Issue with Z-Fighting on highlight material on mesh with logarithmicDepthBuffer flag on

I want to select a mesh and then draw a highlight on top of it. Everything works but when i turn on LogarithmicDepthBuffer, there is z-fighting.

I have added the LogDepthBuf_pars_vertex / fragment etc to the highlight material shader.

I can see the highlight material but there is Z-fighting. It’s weird it only happens on some meshes, not others.

const highlightMaterial= new THREE.ShaderMaterial({
uniforms: {
},

vertexShader,
fragmentShader,

transparent: true,

depthWrite: false,

polygonOffsetFactor:-4,

polygonOffsetUnits: 1,

});

Using the polygonOffsetFactor doesn’t work, I’ve tried all manner of combinations but looks the same with z-fighting. When I turn off logarithmicDepthBuffer i can see the mesh highlight and it does not z-fight, but I need logarithmicDepthBuffer for other stuff.

Are you using Windows? Can you please verify if this issue happens on other devices, too?

1 Like

The same problem occurs in both Windows and OSX. Verified. Same exact issue

Do you mind demonstrating the issue with a live example?

Besides, do you really need logarithmic depth buffer? What is the scale of your scene?