I needed a reliable way to render wireframes and came across freestyle rendering. I realized that freestyle was a lot of fun and had multiple uses. Everything from cartoons, to blueprints and wireframe rendering, can be made with freestyle.
A walkthrough of FreeStyle in Blender 3D to get non-photorealistic line drawing renders from Blender 3D scenes. »Log of the integration process, its challenges and (hopefully) its solutions.
What is freestyle rendering and How to use it in Blender? Freestyle rendering is an NPR(non-photo-realistic) render engine that adds a layer of lines above your render based on the geometry in your scene. In the render settings, check the checkbox on the freestyle section to enable it. In the view layer tab, you will find all the related settings to customize freestyle to your needs.
In the rest of this article, we will dive deeper into freestyle and how we can use it to do some common rendering effects like wire frame rendering and cartoon styles.
What is freestyle rendering?
Freestyle rendering is a Non-Photorealistic-Render(NPR) engine that was added to Blender in version 2.67. With it, we can create a line layer above our render based on the geometry we created.
What this means is that we can create a lot of different kinds of art that would not be possible without it. For instance, it can be used to make cartoons in different styles. We can also do more technical renders like blueprint renders and wire frame renders if we want to showcase how our original 3D renders were modeled.
If you want to create cartoon style renders but find freestyle to be a bit too complex, I would recommend to check out toonkit. It is an add-on that adds some shader nodes to Cycles as well as lamp, and world settings. Much easier to set up and work with. It also renders almost real time.
You can find it here:
Blendermarket Toonkit for Cycles
How does freestyle rendering work?
Freestyle rendering is enabled in the render settings of either Eevee or Cycles. Both renderers are supported but they differ slightly in features.
Freestyle is enabled for the entire scene. But it can then be controlled on a view layer level. The scenes 'global settings' for freestyle are in the render settings, then we have some freestyle settings that are related to a view layer.
When freestyle is enabled, each view layer has two additional layers of settings. After the 'global settings' that are in effect for the entire view layer, there is the 'Freestyle Line set' settings and the 'Freestyle line styles'.
Let's start with line sets. We can have multiple line sets. The basic idea is that they will determine where a set of lines will be drawn. For example, we can have one line set that is selecting the silhouette of our objects. Another line set could be the internal lines of objects and the third set of lines could be any object that is behind one or more other objects.
There is also an option to mark any edge to be detected by freestyle manually if we want full and ultimate control.
The next layer is the line style. The line style will determine how a freestyle edge will be drawn, or how a line will look. Each line set can have a line style attached.
So if you can see the pattern, we first had some global settings. Then we had one or more line sets that will actually be a kind of selection of edges. Then the line style will give us the power to tell Blender what that line should look like.
How can we set up freestyle rendering?
We established three levels of settings for freestyle. What I like to call the 'global settings' followed by line sets and line styles. Now let's dive into a more practical example.
Here is a low poly scene that I made to test this. We have some basic geometry. Then there are some reshaped cubes, water with quite a bit of movement and waves as well as some cloth made with a cloth simulator. We also have some flat planes for the vegetation.
Related content: More than 30 Blender modeling tools explained
The scene is rendered in Eevee with some post-processing effects like bloom and depth of field.
Related content: 5 cool camera tricks in Blender
Let's get exploring. In the properties panel and under the render tab, check freestyle. We have two settings here. Generally, I never touch these.
Line thickness mode will use the line thickness setting when set to absolute. When set to relative, the line thickness is dependent on the resolution of the image. 480 pixels in height will correspond to 1pixel line thickness. Double that to 960pixels and the line thickness will be 2pixels.
The line thickness can be adjusted on the line style level instead.
Go to the view layer tab and you will find three sections related to freestyle.
- Freestyle
- Freestyle Line Set
- Freestyle Line Style
The freestyle section has some overarching settings. I seldom touch these settings. But we will talk briefly about them. The control mode is a switch between using the parameters set here in the interface or to use a python script file to make the freestyle settings. We will stick to parameter editor.
Let's jump down to the edge detection options. The Crease angle determines the degree at which a crease is considered a crease. This becomes important when we dive into edge types. Edge types are a big deal when it comes to selecting edges with a line set.
If face smoothness is ticked the faces that belong to the same smoothing group will not get a line even if the crease angle says that it would.
Culling will ignore any edge that can't be seen from the camera, even if it is within the frame.
Ticking the advanced options and using these settings can help if we don't get smooth lines on curved surfaces.
Freestyle Line sets
So far we mostly covered concepts and some lesser used settings. But this is where we start to set up freestyle for real.
We can have multiple line sets, each 'selecting' a different set of edges. We then apply a single line style to each line set.
We have 5 different selection modes, we can have 1 or more of them enabled at once and it is the combination that creates the final selection. When multiple selection modes are used, the most restricted will apply.
- Visibility
- Edge Types
- Face Marks
- Collection
- Image border
Image border is really only a performance setting and will mostly be on. So in reality we only have 4.
Visibility
Visibility determines what edges will be rendered as freestyle by visibility. Set this to visible and freestyle will use the edges that we can see from the camera.
Hidden will use the lines that are not visible from the camera, but is hidden behind some other object or geometry.
QI Range lets us set a range from how many layers of geometry should be between the camera and the first object that gets rendered and how many layers after the first rendered lines that will be considered for freestyle drawing.
Edge types
Edge types is where we do 90% of our line set settings. It allows us to more dynamically select edges based on some criteria.
Before we look at the different types we have inclusive and exclusive, this just dictates if the freestyle lines should be drawn on the marked edges or on everything else.
The 'logical or/logical and' can be a bit hard to understand at first, so I will try to explain it simply. With 'logical or' we say that the edge need to be at least one of the selected criteria below to be marked. For instance, it has to be 'Silhouette OR Border OR Contour'. With 'logical and' we say that the edge has to be 'Silhouette AND Border AND Contour'. This means that 'logical and' will remove any edges from the selection that does not comply to all the edge types that we select.
These are the edge types:
- Silhouette
- Border
- Contour
- Suggestive contour
- Ridges & Valleys
- Crease
- External Contour
- Edge mark
- Material Boundary
You have probably noticed that there is both a checkbox and an 'X' for each of them. The checkbox tells Blender that it should be 'included in the calculation' if you will. The 'X' gives the edge type a 'NOT' in the calculation. This is confusing, yes I know. Let me try to explain.
We are dealing with Boolean operations here, and it gets a bit confusing to know what edge is actually being drawn. We will look at two example.
Let's say that we are set to inclusive and 'logical or'. We also have Silhouette, Crease and border selected. That would give us this formula:
An edge will be marked if an edge is:
Let's now say that we press the 'X' on Border. Then it looks like this:
This formula will still draw an edge if 'it is not' a border. Pressing the 'X' may then actually still add more lines to the line set. It just means that lines that 'are not' borders will be selected.
If you use 'logical and' it may look like this if border is set to 'X':
We can't have both 'OR' and 'AND' in our Boolean math. We need to go to python scripting for that.
Let's leave the math for now and look a bit more at what the different edge types actually mark.
To help you see this a bit better I made an info graphic showing how each setting looks on our test image. You will notice how edge mark and Material Boundary is left out. I want to cover these separately.
Other than the edge type settings I use the default settings to show how these different edge types work.
Click on the image to open in new window and click it again to enlarge.
With edge mark we can mark an edge to be drawn as freestyle. This is very handy when we want ultimate control over what edges gets drawn. To mark an edge follow these steps:
- Go to edit mode
- Select the edges you want to mark
- hit 'ctrl+e' and chose 'Mark Freestyle edge'
- In the freestyle line set options, make sure that 'Edge mark' is selected in the edge style settings.
Edge marking can be very useful for wire frame renders, where we need to show how our geometry was built. For instance, I use this when I sell stock 3D models to show that the wire frame is of good quality.
Edge marks is not useful when we want to draw the silhouette of an object that does not have an edge. This is most prominent on round objects where we may not have an edge right at the silhouette line.
Left for last is the material boundary setting. It is simple, it draws the freestyle line where there are two different materials of either side of the edge. I was just not smart enough to include an object with more than one material in the render I did for the info graphic.
Face marks
Facemark is something that I never use, and I imagine few others do as well thanks to where it is in the interface. It is similar to edge mark, but instead of marking an edge we mark a face and the edges holding up that face are being marked.
To mark a face do the following:
- Go to edit mode
- Select one or more faces
- press 'ctrl+f', at the bottom you will find 'face data' and 'Mark freestyle face' at the bottom.
In the freestyle line set options we can choose to include or exclude the marked faces. If we exclude it, the unmarked faces will be drawn.
We also have the 'one face' and 'both faces' option. This determines if both faces on either side of an edge need to be marked in order for the edge to be drawn, or if it is enough if one face is marked.
Collection
Collections are interesting. It allows us to select a group of objects that will be rendered with the given freestyle line set, or be excluded. To use it, select it in the line set options and the interface will expand. Select the collection that you want to include or exclude.
As an example, let's say that we have a background that we don't want to render freestyle lines for, then we can exclude it by placing it in its own collection and using these settings.
We can also do the opposite and only include the foreground in a collection and use that.
Freestyle line styles
Let’s now take a look at what we can do when we combine line sets and line styles. Since Line styles really can be tweaked into the extreme with a huge range of possibilities we will walk through a few examples instead of going over the settings.
These are the examples we will go through.
- A cartoon style
- A wire frame showcase setup
Cartoon style
We will start with the cartoon style. I made a short animation of how it turned out that you can watch here.
A little background. I altered the scene that I showed earlier and that I also used in the info graphic above. I used Eevee as the render engine with the toonshader by Paul Caggegi.
The crosshatches on the ground is not freestyle rendering. It is a combination of the toon shader and a cross-hatch texture that I got from this link.
Freestyle line thickness is set to “absolute” and 2 pixels. The line set is set to “visibility” and “edge type”. The edge types then use “Inclusive” and “Logical OR” and these are the edge types used:
- Silhouette
- Contour
- Crease
Now for the line style. I started with the default settings and tweaked only the thickness settings. For the base thickness I set 2. Then I added two modifiers. One “distance from camera” and “along stroke” below that and started setting up the 'distance from camera' modifier.
By looking at the grid floor in my scene I estimated the furthest distance on the island from the camera. Not taking the ocean into account I came up with 40 meters for the max range. Then I changed the 'min value' to 0.5.
I left all other settings as their default. However, I realized that the value max and value min that determines the thickness based on the distance actually makes the furthest lines thicker and closer lines thinner by default. I meant to have it reversed but did not realize this until it was too late. However, I think it turned out alright anyway since the cross-hatched lines would not be affected anyway it now just looks like there is some variation in the line thickness. Something to keep in mind though.
If you want a more dynamic flow between the lines' appearance based on camera distance, you can change the modifier from linear to curve and you will be able to adjust the thickness however you like.
Next, I set up the “along stroke” modifier. This modifier allows us to set a dynamic line thickness based on a curve. Change the modifier from linear to curve. The curve can then be used to set the thickness from one end to the other.
For me I set both ends to 0 and the middle, close to 1. This set up makes every line taper of and the lines gets a more sketchy look.
These two thickness modifiers combined is a very common setup for cartoon styles and I think it demonstrates some basics of how to get started with a cartoon look in Eevee together with a toon shader that is simple to work with.
Wireframe render
We will now move over and take a look at wire frame renders. For this I have switched to cycles and setup a material override with a clay like material. This is because material override is not currently available in Eevee.
To set up wire frame rendering I have used a thinner line width of 0.5px in the freestyle render settings.
For the line set. I am now only using “Visibility” and “edge types” with “edge types” only set to “Edge Mark”. Then I have gone into edit mode and marked all edges except for the ground, ocean and the plants' particle system.
In line style I set the thickness to 1 and change the base color to white in the color settings.
You can see that on the cloth, not all edges are drawn. This is because of “visibility” turned on. Freestyle does not detect all those edges as visible.
If I remove “Visibility” however we get a result that looks like this.
A quite messy net of spaghetti if you ask me. However, this could be further tweaked by using the “distance from camera” in the thickness section as well as in the alpha section. But this has already been covered in the cartoon style above, so I opted not to go further on this route.
If you are interested in more specific settings and what they do, as well as more descriptions of each modifier in each of the different sections of the line styles, I recommend to check out the blender manual.
Freestyle is not limited to these kind of simple lines, we can dive much deeper into more sketchy and painterly looks. We have not touched on the geometry or texture sections in this brief overview, but you may now be a little bit more hungry to explore those sections on your own.
How to reuse line styles?
To reuse a line style we append it from one file to another. Go to file->Append and browse for your .blend file that contains the line style.
Click the blend file to open it and find the 'FreestyleLineStyle' folder. Inside it you will see the names of your line styles available in the file. Click 'Append from library'.
Go to your line style settings in the properties panel and view layer tab. Find the freestyle line style section and press the pen icon to open the list of line styles. Select your linestyle by name.
How to use freestyle in the compositor with Cycles and Eevee
In many cases when working with freestyle we need to combine it with other tools to create a full effect. This can be toon shaders, compositing nodes and dabbling with multiple scenes and view layers.
Update: In Blender 2.83 there is now a pass for freestyle. This means that we can go to the view layer tab and find the 'freestyle' section. In there, there is a checkbox labeled 'as render pass'. Check this to have Blender render freestyle on a separate pass that we can control in the compositor instead of combining it with the combined pass.
Related content: How view layers can help you render large scenes with less memory in Blender
To use freestyle with the compositor it is essential to get the freestyle lines rendered on its own layer with an alpha background. This is currently only supported in cycles. We will look at how this is done. We will also be going over a workaround that enables us to use freestyle lines in Eevee as well.
If our scene is made in Eevee, and we want to render a pass of freestyle lines above it with an alpha background that we can use in the compositor. We can do so by using multiple scenes. It is not as complicated as it first sounds.
Start by turning off freestyle rendering under the render tab in the properties panel. In the top right corner of the interface we have two dropdowns. One for scenes and one for render layers.
Press the icon next to the right of the scene drop-down and select “linked copy”. This will create a linked copy of our scene. However, the render settings are not linked between the two scenes. This enables us to set the linked copy to render with cycles.
In your new scene. Find the render tab in the properties panel again and switch the render engine to cycles. Then go to the “film section” and check “transparency”. Also enable “freestyle”.
Next we will need to set up filters in order to render the freestyle lines without the geometry or background. Go to the view layer tab and find the “filter” section. Deselect all except freestyle.
If you have not yet setup your freestyle line sets and line styles, do so now.
Then render the scene. You should get a transparent image with only the freestyle lines visible.
Next switch back to the Eevee scene. Make sure that you disabled freestyle in the render settings so that you don’t get freestyle lines burned into the image. We will use the Cycles freestyle layer to composite on top of our Eevee render.
When the render is done, go to the compositing workspace and tick the “use nodes” checkbox in the header. A render layer node and composite node should appear. If not use “shift+a” and add them in.
- Select the render layer node and duplicate it with “shift+d”
- Select your cycles scene in the duplicated render layer node.
- Hit “shift+a” and add an “alpha over” node.
- Connect the cycles scenes alpha to the fac of the alpha over node.
- Connect the Eevee scene to the first color slot.
- Connect the alpha over node to the composite node.
- You can also add a viewer node and connect the alpha over to that as well to view the backdrop.
- If the backdrop does not appear, click the backdrop button in the top right corner of the compositing editor.
- Adjust the bottom color of the alpha over node to change the line color of the freestyle lines.
This is one of the simples possible combinations of a freestyle line render and an Eeevee scene. From here we can use any tool available in the compositor to manipulatea each layer by itself or the combination.
If we want the same kind of setup, but we have a Cycles scene that we want a separate render layer with the freestyle lines above we can use a similar method. In this case though, we don’t need a separate scene. Instead, we use a separate render layer.
- Instead of adding a new scene, add a new render layer.
- Select the new render layer and find the render layer tab in the properties panel.
- Find the filter section and deselect all except freestyle.
- Setup your freestyle line set and line styles.
- In the render tab, find the film section and check “transparent”.
- Also, make sure that freestyle is enabled.
In the compositor you select the correct render layer instead of the scene in the render layer node and that is the only difference.
If you want to learn more about how you can organize your scene, this article can help you to understand the outliner and collections.
Related content: How to work with collections(layers) in Blenders outliner
How can we export freestyle lines as SVG?
Blender Freestyle Alpha
Freestyle can be converted to SVG and exported to be used in another application. It can also be imported into Blender again to work at it as a grease pencil object.
To export we need to enable the 'Freestyle SVG Exporter' add-on. It comes with Blender by default.
- Go to Edit->Preferences and click 'add-ons'.
- In the top right search box, type 'freestyle' and the list will filter.
- Check 'Freestyle SVG Exporter' to enable it.
- The add-on is now available in the properties panel under the render tab. The section is labeled 'Freestyle SVG Export'
You can select if you want to export from a full animation or just a frame. There are also some other output settings that can be useful, like how corners are treated and if we want to fill with the material color.
The SVG files will be exported to the output folder after the frame has been rendered. The output folder can be set in the output tab under the output section. This is the general output folder for animations and sometimes baked data in Blender.
Related questions
What other alternatives are there to freestyle?
Through google summer of code there is an ongoing project called LANPR that will most likely replace freestyle in the future. It is basically freestyle as a real time render engine.
- LANPR website
- Blenderartists.org - thread for LANPR