I’m noticing that, generally, mesh renderings look worse after updating my program to VTK 9.2.6 than they looked using 8.1. It’s somewhat subtle, but the lines somehow don’t look as sharp, particularly when zoomed out. I’ll try to attach some example before-and-after screenshots below.
I don’t think I’m doing anything too fancy with the mapper and actor, and I didn’t change anything in my code when moving to the new VTK. I’m guessing some rendering defaults changed between the versions - does anyone have any advice?
There have been quite a few changes w.r.t surface with edges, coincident topology resolution, wide lines, etc. since v8.1. In particular, the surface with edges are done in a geometry shader where edges are “filled in” triangle strips while drawing the surface. You might want to increase the line width a little bit to show more of the lines.
You could also play with the coincident topology resolution on the mappers to make the lines always appear above. This requires that you use a separate actor for the lines
For what it’s worth, I’ve found that I get near identical results between VTK 9.2.6 and VTK 8.1 if I set the polygon and line offset parameters back to the old values prior to this commit, i.e.:
// the following two lines were consistent between VTK 8.1 and 9.2.6
vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetFaces(0);
// the following two lines I've needed with VTK 9.2.6 to match rendering with 8.1:
vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(2, 2);
vtkMapper::SetResolveCoincidentTopologyLineOffsetParameters(1, 1);
Even though the commit seems to suggest that the ‘factor’ parameter is no longer used, I’ve found that indeed it does still make a difference.
I use the factor throughout my code. Currently, I use the master branch (two weeks old, I guess). You can either use this or layers to force things to be on top, but I really that you can set multiple values, which gives a lot of flexibility.
Ideally, VTK should handle the coincident topology better. Sometimes, no value of factor and offsets works perfectly. It gives artifacts where the polygon almost edge-on to the camera is shifted above the lines. And, while the rest looks okay, you end up getting an X-ray effect where a few lines that are supposed to be under a face show on top. These artifacts were speculated by Ken in the commit message which @macadata linked to.
I do not know a solution yet, just wanted to mention the pitfalls of the current approach when applied to complex 3D meshes.
I hacked the mapper to use fixed function glPolygonOffset(1,1) and it gave cripser 1 pixel lines on top of the mesh. That means the shader is not exactly equivalent to the fixed function code. It is missing some secret sauce.