May 12, 2015

Fixing undesired gaps in Freestyle lines

Filed under: Blender, Freestyle — blenderyard @ 4:08 AM

Freestyle line drawing may contain undesired gaps that show discontinuity in otherwise consistent outlines.  Undesired gaps are often observed in silhouette lines.  The problem is that silhouette lines can be partly occluded by the faces that define the silhouettes.  The first remedy of the issue is to enable the Face Smoothness option found as part of the Freestyle edge detection options.  When this option is disabled, silhouette edges are foreseen to be jaggy (as described in a separate post in the Freestyle Integration into Blender blog) and hence more prone to undesired gaps.  With the Face Smoothness option enabled, resulting silhouette lines will be much smoother and better suited for line visibility tests.

Turning the Face Smoothness option on may still fail to fix some of the line gaps.  This is a technical limitation of the current smooth silhouette line detection algorithm implemented in Freestyle.  Interested readers are addressed to an academic research paper by Bénard et al. (2014), “Computing smooth surface contours with accurate topology”, in which smooth silhouette lines computed by Freestyle are referred to as interpolated contours.  As the word “interpolation” suggests, Freestyle silhouette lines are somehow “guessed” from other existing mesh edges, so that some degree of computational inaccuracy is expected.

Inaccurate silhouette lines mostly come from coarse mesh faces.  Smooth silhouettes are computed from existing mesh edges, so that the coarser the mesh faces are, the less accurate the interpolated silhouette lines are.

Undesired gaps in smooth silhouette lines can be addressed to some extent by manually subdividing mesh faces locally around the places where the gaps are observed.  It is noted that artists usually have their own preferred polygon counts for given mesh models, so subdividing mesh faces of the entire models is unlikely a practical solution.

Below a case study on fixing undesired gaps by manual mesh face subdivision is presented.  In the following test render, a small gap (highlighted in red and enlarged) is observed in a silhouette line of the white shirt.  This is a typical example of line gaps due to inaccurate guesses of smooth silhouettes.


As shown below in the screen capture of the mesh data in Blender, the faces around the line gap (smoothed by a level 2 Subdivision Surface modifier) are indeed quite coarse (especially so when compared to a mesh resolution that would be required to represent the quick curve of the outline).  Thick orange lines in the image indicate Freestyle feature edges (so-called view map as a whole) visualized as a curve object by a custom style module (, see the post #2894 of the BA Freestyle thread).  This way the gap in the silhouette line can be seen not only from the camera view but also from an arbitrary viewing angle (as in the right and left 3D viewport, respectively), making it straightforward to identify on which mesh face the silhouette line having the gap resides.


Now the quad face causing the gap in the smooth silhouette line is manually divided into two triangles as illustrated below.


The following rendering result shows that the gap has been successfully fixed by the mesh tweak.


Obviously the applicability of the documented manual solution is limited.  Locally subdividing mesh faces may cause other visual artifacts instead of line gaps.  Model and camera movements might also make it difficult to apply manual mesh tweaks.

The upside is that the manual method gives a guideline for artists to tune input mesh data in a manner favorable to Freestyle.  The present case study illustrates how to locate the spots that need optimizing.  It is always the case that tuning mesh data while keeping Freestyle in mind gives a better line rendering result.

Create a free website or blog at