Freestyle integration into Blender

October 25, 2011

Development updates on October 25

Filed under: Update — The dev team @ 12:47 AM

Since the last blog post, branch development mainly focused on stability improvements of the Freestyle renderer and new functionality for fine control of feature edge selection.

Stability improvements with the face smoothness option

Several branch users kindly reported that Freestyle failed when the Face Smoothness option was enabled and object materials were used to determine line colors.  When the Face Smoothness option is enabled, the view map computed from a given 3D scene is populated by not only sharp FEdges (i.e., edges in the original meshes) but also smooth FEdges (i.e., newly constructed edges across faces).  This situation often resulted in a failure of the getFEdge() method (defined in the Interface0D class and its subclasses) used to obtain the FEdge between two given 0D elements (such as SVertices and CurvePoints).  The instability of getFEdge() caused many related issues because the method is widely used in other predicates and functions that rely on it.  The most prominent example of related user-visible problems is a failure of the built-in MaterialF0D class that retrieves object materials of given 0D elements, as seen in the problem reports from branch users.

The persistent failure of getFEdge() was resulting from several bugs in the view map construction algorithm.  These bugs were fixed through careful code revisions and intensive testing.  Also, the built-in MaterialF0D turned out to be incapable of handling Curve objects (such as chains and strokes), so that a new CurveMaterialF0D class has been introduced to address the material retrieval in the case of Curve objects.

These changes have improved the stability of the renderer with the Face Smoothness enabled.  The dev team is very grateful to those branch users who provided the bug reports together with .blend files to reproduce the issues.  The .blend files were indeed indispensable test cases during the bug hunting.

Fine control of feature edge selection with mesh face and edge marks

With the aim of allowing for fine control of feature edge selection, new “face marks” and “edge marks” have been introduced in mesh data blocks.  In the edit mode of a mesh object, face marks can be put to selected faces by choosing Mesh > Faces > Mark Freestyle Face from the menu of a 3D View window or Ctrl-F > Mark Freestyle Face from the context menu.  Similarly, edge marks can be put to selected edges by Mesh > Edges > Mark Freestyle Edge or Ctrl-E > Mark Freestyle Edge.  These marks should work fine with the Subdivision Surface and Mirror modifiers.

Moreover, two new conditions for feature edge selection have been added to the Parameter Editor mode, as described below:

  1. The Selection by Edge Types option now includes the new Edge Mark type, which can be used to (de)select feature edges having edge marks.  This option can be used to add to (or remove from) the view map arbitrary edges of mesh objects.
  2. Selection by Face Marks option has been newly introduced, in which face marks are used for feature edge selection in two ways.  One option is called “One Face” which is to (de)select feature edges if one of faces on the left and right of each feature edge has a face mark.  The other option is “Both Faces” to (de)select feature edges if both faces on the left and right have a face mark.  Those feature edges that meet the conditions are selected if the Inclusive option is enabled; they are deselected if the Exclusive option is turned on.

The following screenshot shows the new GUI controls (highlighted in red) based on face and edge marks.

Edge marks are useful when you want to draw lines along particular mesh edges.  The following example images demonstrate the use of edge marks.

 

The image on the left shows a sphere mesh with edge marks (in the edit mode).  In a 3D View window, edge marks are displayed in light green.  The image on the right is a render without the Edge Mark type enabled in the Selection by Edge Types option (the black line shows the silhouette of the sphere).  The image below is a rendering result with the Edge Mark type enabled.  The blue lines indicate those resulting from mesh edges with edge marks.

Face marks are useful for removing lines from certain portions of mesh surfaces.  Suppose that two faces of the default cube have face marks as shown in the image on the left below.  Marked faces are displayed in light green.  The image on the right is a rendering result without using the Selection by Face Marks option.

 

The following images show how rendering results vary with four combinations of the Inclusive/Exclusive and One Face/Both Faces toggle options.  Notice that only the edge between the two marked faces is (de)selected when the Both Faces option is used, while all the edges touching the marked faces are (de)selected when the One Face option is enabled.

 

 

Renders from branch users

In the meantime, branch users have been sharing their renders made with Blender and Freestyle.  Here are some selected rendering results.

Toon rendering of Sintel by jikz (the model is base on Sintel Lite 2.57b by BenDansie):

 

Architectural line drawing by flokkievids:

Many thanks to jikz and flokkievids for the excellent contributions!

About these ads

20 Comments »

  1. Wow, another awesome update, T.K.!

    So, if you mark a set of edges and make them inclusive, it looks like all unmarked edges will not be detected. Does this mean that you will have to create another line set for detecting the unmarked edges? Also, what happens if an edge is then detected in more that one line set? Will 2 lines be drawn on top of each other for that edge? I guess you could make the marked edges exclusive for the second line set.

    Comment by Rudiger — October 25, 2011 @ 6:51 AM

    • For the render of a sphere with blue lines, I defined two line sets, one for black silhouette and the other for the blue lines. This is just meant to highlight the latter lines resulting from edge marks. In a line set, you can choose whatever edge types you want (e.g., to select all silhouette, crease, border and edge mark lines). Feature edges can be of two or more edge types at the same time. Edge marks are just one of many possible edge types. When an edge is selected by more than one line set, multiple lines are drawn along the edge, one line on top of another. Line sets are processed from bottom to top in the list, so that the order of line sets and the final stack of drawn lines will match.

      Comment by The dev team — October 25, 2011 @ 5:12 PM

      • Thanks for clarifying. I had forgotten how line sets worked.

        I just had one more query. With this approach, is it possible to make some edges never visible at the same time as making other edges always visible, or would that require the ability to set the edge type to include or exclude when the edge is marked?

        Comment by Rudiger — October 26, 2011 @ 12:14 AM

      • Oh, I see how it could work now. You could use marked edges to force certain edges to be detected and marked faces to force other edges to not be detected. That’s awesome!

        Comment by Rudiger — October 27, 2011 @ 4:26 AM

  2. The work to stabilize and MATURE the features of FreeStyle in Blender are impressive. Your hard work to bring FreeStyle to a state deserving of a trunk-merge are to be commended! Thank you for all your hard work to shape the Blender/FreeStyle branch into a fully-developed NPR rendering solution.

    Comment by 3D uaun (@3duaun) — October 26, 2011 @ 11:07 PM

  3. Excellent news the improvement of stability.
    Just one question. From months ago this project looked stable and “ready to merge in blender”. We’ve seen a lot of versions compiled in graphicsall,… but this project isn’t mentioned in the short term roadmap of trunk merge of Blender. What’s the reason? Is there anything that we can help with?

    Comment by Marcos — October 30, 2011 @ 8:34 PM

    • The main reason why the Freestyle branch is not in the short-term road map is a time contraint. At the moment I (T.K.) is only the dev team member who constantly works on the branch. There are unfinished components that need to be done before the merge is asked, while spare time of mine is limited. As you see, the development has been in progress since a while, but it is still difficult to estimate when the merge can be finally asked.

      Comment by The dev team — November 1, 2011 @ 4:45 PM

  4. awesome updates!

    Comment by ikeahloe — November 4, 2011 @ 12:26 AM

  5. The more I use the Freestyle render module, the more I like it, especially in the Parameter Editing Mode. However, I am finding one difficulty when using the Line Sets. Perhaps I don’t understand exactly how to use the software, but as it stands I see no way to save and reuse the individual Line Set and Line Style settings. This means that if, for example, I wish to have a slight variation of an existing Line Set to apply to a group or such, then I need to create a new Line Set and then proceed to key in all the separate settings (color, opacity, edge types and so on) for that new Line Set. Ouch! This is a lot of work.

    Is there a way to instantly copy and reapply all the settings of a Line Set? If so, please explain… or… if this doesn’t yet exist I really do think that a save/copy mechanism for the Line Set /Line Style settings should be added into the code. ;-)

    Comment by Ignatz — November 4, 2011 @ 8:33 AM

    • Ignatz,

      Thanks for the comment. Indeed there was no way to copy/paste between line sets and to make a copy of a line style. The latest revision 42025 has both functionalities implemented. For line sets, you will find a new pull-down menu on the right of the list of line sets. The menu allows you to copy the settings of the active line set and paste them to another line set (possibly in different scenes and render layers). For line styles, you can duplicate the active line style by enabling the fake user (through the ‘F’ button on the right of the line style name) and making a single-user copy (through the ‘2’ button that appears after enabling the fake user). It is recalled that line styles are data blocks (like meshes and materials). This means that you can create multiple line sets that use the same line style. This way the same line style settings can be easily applied to different line sets.

      Hope this helps,
      T.K.

      Comment by The dev team — November 21, 2011 @ 12:00 AM

      • T.K., Thank you so much for adding this feature into the Freestyle code. I’ll give this a try as soon as I can get my hands on an updated build.

        Comment by Ignatz — November 21, 2011 @ 8:07 AM

      • T.K., I’ve only had a little bit of time to play with the new ‘Copy/Paste’ functionality you added into the Freestyle module. It works well, but I already found a ‘bug’. This is as follows:

        a) Make a first Line Set. This Line Set will have the name “LineSet” and its associated Line Style will have the name “LineStyle”. Now apply various parameters as desired (visibility selection, color, line thickness, etc.)
        b) Now make a Copy the the data from that Line Set
        c) Make a new Line Set. Note that the new Line Set will have the default name of “LineSet.001” and its Line Style will have the name “LineStyle.001”.
        d) Now Paste the previously copied date from the first Line Set into the new Line Set.
        e) The parameters of visibility are pasted in as expected, but I see that the Paste function incorrectly causes “LineSet.001” to reference “LineStyle” instead of pasting the data into LineStyle.001. This means that both LineSet and LineSet.001 are referencing the same Line Style. This defeats the purpose of separate line sets.

        What I really expected was that the parameters from “LineStyle” should be copied into “LineStyle.001” so that each Line Set has a separate Line Style so as to allow the user to make changes to color, line thickness, etc. without messing up the settings of the other Line Set.

        I will try to find more time to experiment with the Copy and Paste.

        PS I can envision situations where it would be very much to the user’s advantage to be able to change ‘Edge Detection Options’ (crease angle, etc.) for different line sets.

        Comment by Ignatz — November 23, 2011 @ 11:29 PM

      • Ignatz,

        Thank you for testing the Copy/Paste functionality. You have made a good point concerning the references of line styles.

        As you observed, the present behavior is the following. Suppose a line set A is linked to a line style X and another line set B is linked to a line style Y. By copying A and pasting into B, the line set B will be linked to X (instead of pasting the settings of X into Y). This behavior is what I have intended to implement and not considered a bug.

        The rationale of the present behavior is that line styles are distinct data blocks and a line set has just a link to a line style. It is recalled that data blocks are shared by multiple referrers.

        For instance, a material is a data block. This means that the material can be shared by multiple objects. By the same token, a line style is a data block, so that it can be shared by multiple line sets. This is the reason why the present Paste operation does not change the settings of a referenced line style but just changes the references.

        What happens if the Paste operation also puts the settings of X into Y (instead of changing references) in the above example? Let us further suppose that there is yet another line set C that is linked to Y. By copying A and pasting into B, the settings of line style X are also copied into Y. Since Y was shared by B and C, C remains linked to Y whose settings are identical with those of X. I don’t think this is an acceptable behavior, because data blocks can be not only shared within the same scene but also referenced from different scenes, possibly of external .blend files. If the Paste operation affects the contents of the linked line style, you have to be extremely careful about the sharing of line styles. This is clearly too much.

        In short, the present behavior of the Paste operation is safer. Considering the above example again, you can easily make B linked back to Y after pasting the settings of A into B, by just selecting Y from the pull-down list of line styles. This is nothing when compared to having to take care of all the shared line styles. I hope this will clarify the present design decision.

        Comment by The dev team — November 24, 2011 @ 1:55 AM

      • T.K.,

        While I follow your reasoning, I must politely disagree… most especially since you have failed to address the requirement to actually make a copy of the Line Style Data.

        What I envisioned as a user was that I might make an interesting line set with a particular line style (color, thickness, line modifiers, etc.). Then, by creating a new line set and pasting the data from the first set into the second set I would have a jumping off point to subtly change the parameters of that second line set for artistic purposes (different color, different thickness, altered modifiers, etc.). That is the whole idea behind copy and paste, isn’t it?

        When both line sets are linked up (by default) to the same line style, changing anything in that line style instantly changes it for the two lines sets… which is something I definitely did not want.

        What is worse is that I still have no way to duplicate my Line Style data. I cannot do a Paste operation since your current routine simply relinks to the original Line Style name of the copied data. So once again, I am left in the situation where I have to manually recreate all the settings of the Line Style for myself. (:-(

        With regard to your concern for ‘safety’, I must also point out that in the situation I presented to you, the new line set I created ( “LineSet.001” ) had absolutely no data in it and so any paste operation would have been completely safe. Had I any fears about same, I could have simply changed the Line Style reference for myself (or created a new data block) before any Paste operation.

        Regarding the Line Style, I should also point out that when creating a new one (via the “+” symbol to the right of the line style name field) it always creates that new line style devoid of an user alterations. This is in contrast to creating a new material via the same operation.

        In the case of duplicating a material, a new material data block is created, but it ‘wakes up’ with all of the settings of the original material from which it was created. This is, in effect, a copy operation. At that point, the user is free to change any of the settings in that new material block without having these changes ripple back into the original material block which was duplicated.

        So, how to address this? In my opinion, if one decides to COPY a line set, then one wants a complete, correct copy of all the data into that new line set, but NOT in any way linked back to the original so that changes to one will affect the other. That is safer for me, the operator.

        Better still, although more complicated, would be a method to write out copied data into preset files (like storing curve data in Photoshop or Gimp) and then reopen them later as required. Of course, that is probably quite a bit more work at this point in time.

        Comment by Ignatz — November 24, 2011 @ 8:05 AM

      • Ignatz,

        Please note that a copy of an existing line style can be made by enabling the fake user (click the ‘F’ button to the right of the line style name) and then making a single-user copy (click the ‘2’ button that appears when the fake user is enabled) as I mentioned in the first reply to your comments.

        You have made a good point concerning the creation of a new line style. I agree that the present behavior of creating a new line style with the default settings is inconsistent with the behavior of creating a copied material by clicking the ‘+’ button. I am going to fix this issue.

        Thank you,
        T.K.

        Comment by The dev team — November 25, 2011 @ 12:52 AM

      • T.K.,
        Thanks for the note of emphasis concerning the ‘fake user’ button and the ability to make a copy via pressing on the button which indicates the number of times the fake-used content occurs. I was note aware of this. Speaking of this very thing, perhaps at some time you could present some information that would make it clear what effect the settings for ” Sphere Radius ” and ” Kr Derivitive Epsilon ” have on the visual results one obtains with Freestyle.

        Comment by Ignatz — November 25, 2011 @ 6:51 AM

  6. This has made a massive difference. A needed update

    Comment by Construction Materials — November 17, 2011 @ 6:40 PM

  7. Thanks for being so actively responsive to the community, especially when you have no financial interest in it! I was reading through the FAQ and noticed you plugged the Blender Fund in response to donation questions, you have no idea how much respect I have for you having done this. :)

    I was unable to find anything in the FAQ regarding what effect BMesh or the new render API have on the development.of Freestyle. If you have the time, would you mind elaborating?

    Comment by Nicholas Rishel — December 17, 2011 @ 1:22 AM

    • Thanks for the comment. Basically Freestyle receives a bunch of triangles from Blender and works on them. For this reason, BMesh won’t have a major impact on the Freestyle renderer. Freestyle has been quite tightly integrated into Blender’s internal render pipeline, in order to enable a proper support for render layers and full-sample anti-aliasing. In other words, Freestyle is part of Blender and not an external renderer. The new render API is intended to be an interface for external renderers. That is, Freestyle has nothing to do with the render API.

      Comment by The dev team — December 20, 2011 @ 12:42 AM

      • Interesting. Thank you for increasing my understanding of how this is working under the hood. :)

        Comment by Nicholas Rishel — December 20, 2011 @ 7:35 AM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The WordPress Classic Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 60 other followers

%d bloggers like this: