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

**URL:** <https://discourse.threejs.org/t/issue-with-z-fighting-on-highlight-material-on-mesh-with-logarithmicdepthbuffer-flag-on/31670>\
**Category:** Questions\
**Tags:** z-fighting\
**Created:** [November 11, 2021, 12:00am UTC](https://discourse.threejs.org/t/issue-with-z-fighting-on-highlight-material-on-mesh-with-logarithmicdepthbuffer-flag-on/31670 "2021-11-11T00:00:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OSource](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/osource/32/21864_2.png) [@OSource](https://discourse.threejs.org/u/OSource)\
**Post date:** [November 11, 2021, 12:00am UTC](https://discourse.threejs.org/t/issue-with-z-fighting-on-highlight-material-on-mesh-with-logarithmicdepthbuffer-flag-on/31670/1 "2021-11-11T00:00:21Z")

</div>

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.

 ![highlight mesh zfight issue logarithmic dep](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/8/3/839936a1d9eb4e2ff12b61c63248fb89571a9f1c.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [November 11, 2021, 9:44am UTC](https://discourse.threejs.org/t/issue-with-z-fighting-on-highlight-material-on-mesh-with-logarithmicdepthbuffer-flag-on/31670/2 "2021-11-11T09:44:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![OSource](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/osource/32/21864_2.png) [@OSource](https://discourse.threejs.org/u/OSource)\
**Post date:** [November 11, 2021, 10:16am UTC](https://discourse.threejs.org/t/issue-with-z-fighting-on-highlight-material-on-mesh-with-logarithmicdepthbuffer-flag-on/31670/4 "2021-11-11T10:16:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [November 11, 2021, 10:23am UTC](https://discourse.threejs.org/t/issue-with-z-fighting-on-highlight-material-on-mesh-with-logarithmicdepthbuffer-flag-on/31670/5 "2021-11-11T10:23:39Z")

</div>

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?
