Skip to content

New surface with edges

Ken Martin requested to merge ken-martin/vtk:new_surface_with_edges into master

Render surface with edges by drawing the edges while drawing the surface. This solves issues related to the depth buffer. Previously we would draw edges with lines but because lines are rasterized different than triangles the zbuffer values could be significantly different resulting in situations where the lines were dashed or poking through. By drawing the edges as part of the surface this issue goes away.

Additional benefits. Since we are drawing the edges as part of the surface, the boundary between the edge and the interior of the surface can be antialiased in the fragment shader almost for free. Resulting in very clean interior edges.

Downsides. Where the surface ends the line will not be the full width as it has only one side of the edge to draw on. We expand the triangle a bit to help with this but it will not fully solve the problem.

Additional downside is that when drawing quads or higher order polygons opengl requires we submit as triangles. That means interior edges have to not be drawn. We handle that, but it can result in render artifacts where an interior edge of a quad covers fragments of where a thick edge should be from another triangle.

In usage surface with edges will look best with widths between 2 and 5. To be fair the old approach also had artifacts with really large lines due to how it handled corners but it was not quite as bad.

Edited by Ken Martin

Merge request reports