Line segments bleeding through surfaces

Hello :slight_smile:

I am drawing outlined boxes with line segments and have a problem where the lines (at certain camera angles and distance) bleed through the surface of another block.

For example:
image

Fiddle: https://jsfiddle.net/y86n21zm/61/

I thought it was a depth buffer precision problem at first, but changing the near/far clipping planes have not helped so far.

The lines are always rendered 1px wide so maybe it is a z-fighting issue but I don’t know how to go about it in this case.

Does anyone know how to avoid this? (without changing the relative scale of the blocks)
Is there a better way to draw the lines?

Thanks

You can try moving the top plane up by Number.MIN_VALUE (you won’t be able to see the difference, but rendering order just might.)

2 Likes

Good idea, but the problem remains :confused: even when moving it further