Skip to content
  • Ken Martin's avatar
    New method to render surface with edges · add5aeff
    Ken Martin authored
    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.
    
    Additoinal 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 antialized 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.
    
    Issues with overlapping convex polygons required removing
    edges from the cutter tests. Basically when triangulating
    convex polygons the renderer just uses a simple algorithm
    which results in overlap which can overlap the edges.
    add5aeff