I stumbled upon a problem that I'm unsure of how to fix or if a fix even exists. I need to apply a positive polygon offset to a filled mesh for rendering some line geometry on top of them. The lines are rendered as GL_LINES and thus cannot be offset themselves.
The mesh itself is watertight, but needs to render its backfaces as well. However, with the applied polygon offset the backfaces shine through at the edges of the mesh. This picture shows a reduced example, rendering a simple cube with front-facing fragments in white and back-facing ones in pink:

For visibility, I increased the polygon offset slope factor to 5, but this issue occurs with a factor of 1 as well, just with a thinner line. My suspicion is that due to the slope factor the depth values of two triangles sharing an edge no longer match.
I can think of a few workarounds, none of them are particularly appealing:
- Render the line geometry as polygons instead and apply the polygon offset to them (doable, but requires a lot of effort for the project this stems from)
- Don't use polygon offset at all and instead offset the vertices in the vertex shader (ugly and highly dependent on the view frustum I'd imagine)
- Don't use a sloped offset at all, only a constant one and hope that it's large enough to cover all cases (also ugly and may cause issues when multiple meshes run into each other)
Is there something I am missing about polygon offset or another solution?