I’m trying to visualize polylines on top of a triangular mesh.
My problems are:
-“stitching” or “bleeding”
-antialiasing
The lines are drawn as quads. To avoid bleeding I’m using a shader to move the lines along the vertex-normals.
Is there a better way of coping with that?
The methods can be modified to draw arbitrary lines, it would be a bit trickier though. The lines you want to draw always lie in the same plane as your triangles/quads?
Yes, distances are computed in viewport space and anti-aliasing based on these distances in done per fragment.
If you want to draw antialiased, enable multisampling or use a multisampling-FBO. If you don’t want to spend so much resources on a few edges, extract the relevant code from here:
Enable alpha-blending mode, set line-width = 2 . Draw the lines as you usually would, but with the above shader.
With the above shader you can also antialias a quad’s edges in a second pass: draw the geometry in wireframe mode: glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
The line-antialiasing has a lot of requirements to be enabled, and sometimes is locked only to be used with Quadro/FireGL, afaik. It had always been of worse quality than the proposed shader or CSAA anyway.