Freestyle integration into Blender

April 3, 2012

Development updates on April 2

Filed under: Update — The dev team @ 1:45 AM

The Blender Freestyle branch spent a few months of relatively less development activities due to limited time resources.  Here is a short summary of new features and bug fixes since the last blog update.

New features and changes in the Parameter Editor mode

The following two stroke geometry modifiers have been added.

  • 2D Offset: Adds two-dimensional offsets to stroke backbone geometry.
  • 2D Transform: Applies two-dimensional scaling and rotation to stroke backbone geometry.

The 2D Offset geometry modifier has four parameters: start, end, X and Y.  The first two parameters add offset values in the direction perpendicular to the stroke direction.  The offset values are linearly interpolated from the beginning to the end of a stroke.  The X and Y parameters add absolute horizontal and vertical offset values.  The following image illustrates the effects of these parameters.

The 2D Transform modifier transforms stroke geometry by X and Y scaling factors and a rotation angle.  The center (pivot) of these 2D transformations can be: the stroke center, the beginning and the end of the stroke, a point along the stroke (specified by a value between 0 and 1, called stroke pivot parameter), and absolute 2D point (specified by X and Y coordinate values).

Example renders below demonstrate the effects of 2D offset, scaling and rotation (from left to right), where three external contours were modified separately with different modifier parameters.


With a view to a better use of screen space, the locations of edge type options within the Selection by Edge Types have been rearranged as shown below.  Frequently used edge types come first, and less used ones come after.

The two edge types “Ridge” and “Valley” have been unified into “Ridge & Valley”, since the Valley edge type is merely an alias of Ridge in the present Freestyle implementation.

Sphere radius and Kr derivative epsilon were removed from the Parameter Editor mode.  Now sphere radius of 1.0 and Kr derivative epsilon of 0.0 are used by default.  The rationale of the removal is two-fold: little predictability and very minor artistic values.  The effects of these parameters are hard to estimate in advance, which likely leads to a frustration of users due to repeated trials and unpredicted results.  Therefore, the two parameters are considered to have quite limited artistic values.  Proper definitions of the two parameters more and less require the knowledge of differential geometry and would not make sense to most artists for which the Parameter Editor is intended.

Sphere radius and Kr derivative epsilon are still available in the Python Scripting mode, but now in an “advanced options” section that is disabled and hidden by default.  In this way new users are properly warned, while expert users with specific technical needs can enable these options if they want.  The same default values mentioned above are used when the two parameters are disabled in the Python Scripting mode.

Fix for degenerate triangles in imported mesh data

A line visibility issue was identified by means of a .blend file supplied by a branch user.  The issue was caused by so-called degenerate triangles that are triangular faces whose area is zero.  It is useful to distinguish two types of degenerate triangles as follows.  Let A, B and P denote the three vertices of a triangle.  The triangle is said a degenerate triangle if:

  1. A and B are in the same position in the 3D space; or
  2. the distance between point P and line segment AB is zero.

Note that the former condition is a special case of the latter.  Degenerate triangles in the first form can be (and have been) addressed in the same way as the standard Remove Doubles command in Blender.  Those in the second form, on the other hand, are more difficult to address and thus require special treatment.

For what concerns line visibility in Freestyle, degenerate triangles become harmless if they are transformed into non-zero area triangles.  Hence, a preprocessor of imported mesh data from Blender to Freestyle was implemented to resolve degenerate triangles in the second form, where two different approaches to the solution of the issue have been attempted.

One approach is to check if a degenerate triangle is part of a quad face.  This checking is easily done by testing if three of the four vertices are colinear (i.e., they are lying on a line).  If that is the case, then depending on how the quad is separated into two triangles, one of them can be a degenerate triangle.  Degenerate triangles of this form is addressed by rotating the diagonal edge of the quad face without affecting the visual outcome.

The other approach is to add a very small offset to P so that the resulting triangles have a non-zero area.  The visual side-effect of this solution is likely to occur at a sub-pixel level, and thus considered negligible.

Several other attempts were made to explore the best way to handle degenerate triangles, and the two solutions above are found the most effective.  The dev team still keeps close eyes to the line visibility issue due to degenerate triangles.  More fixes will follow if some other sources of degenerate triangles are identified.  Problem reports on this matter are very welcome.

Bug fixes and miscellaneous improvements

The following user-visible bugs were fixed, many of which were kindly reported by branch users.

  • Color management was not working properly with Freestyle.
  • Color ramps were not immediately updated during the manipulation of a color picker.
  • The Selection by Image Border was not working correctly.
  • A crash due to invalid pointers within a copied line set was fixed.  Now the line set buffer is cleared when a new .blend file is opened, so that a line set may not be copied and pasted between .blend files.
  • The Backbone Stretcher geometry modifier had a hard-coded limit that the effect was applied to stokes with 2D length longer than 50.  Now the geometry modifier can be applied to strokes of any length.
  • A crash with FSAA enabled and Freestyle disabled was fixed.
  • Line style names were not made unique after a new name was set.

The dev team is grateful to branch users for their active testing of the software and problem reports.

Freestyle artwork by branch users

An increasing number of Blender artists have been sharing their results with Freestyle, through the Freestyle thread, personal blogs, tweets and so on.  Here, two excellent pieces of artwork by RONIN (left) and s12a (right) are presented.


Many thanks for your contributions, RONIN and s12a!


Create a free website or blog at