Summary
This article describes the creation of illustrations mixing elements with line art and "photorealistic" art in one image using Blender with the Cycles renderer and the options of the Freestyle line renderer. Here an example:
Background
This is a follow up to an earlier post of mine "Blender Tricks: Using Freestyle for Highlighting Objects Part 1 - Layer Options". In this article I explained how to use Blender with Cycles renderer to create illustrations with highlighted objects by assigning Freestyle line options per render layer and exploiting the "Alpha Over" render-layer node.This layered technique is - from my point of view - a good choice for scenes with non-overlapping/interfering object, but has some drawbacks concerning artifacts of the per layer rendering process if object intersect.
Just recently (in the process of creating the image above) I discovered a better approach exploiting the Freestyle options on Material level. Similar to my previous example I want to put green lines around the red cube (only) in the image below:
All my examples here are based on Blender 2.74. So - let's get going...
Step 1: Enable Freestyle
To activate Freestyle line art rendering in Blender/Cycles tick on the "Freestyle" option on the "Render" menu:
Now all Freestyle options are available and without any changes Blender puts black lines around both cubes:
Step 2: Freestyle Line Settings in Material
With Freestyle enabled, a new Freestyle options tab becomes available in the "Materials" tab. There one can influence the line color and the line transparency/alpha:
To hide Freestyle lines in the output, put the alpha value (marked by the red ovals in screenshot above) in the Freestyle options of the corresponding material to zero.
In my example I put the Freestyle line color of the red material to green and alpha to 1. The blue material is adjusted to color = black (default) and alpha = 0.
However - this is where I struggled for quite some time - it is not enough to adjust the Freestyle settings in the material. If you only change color/alpha here, nothing will change in the output.
Step 3: Switching Freestyle Control from Global to Material
To put control of the Freestyle color/alpha options into the hand of the material one has to add two modifiers on the
- "Render Layers" -> "Freestyle Line Style" -> "Color" options AND (!) the
- "Render Layers" -> "Freestyle Line Style" -> "Alpha" options:
for both option tabs add a "Material" modifier.
Now the Freestyle line color and visibility is controlled via the material. The result looks then like this - as desired:
Comparison to Layer-Approach
I presented two possible approaches to put differently colored lines around objects in Blender/Cycles. Which one is preferable now?
My opinion is the following: if you have scenes with separated objects casting not too many shadows onto each other, the layered approach is preferable. Furthermore it offers the possibility to control Freestyle for many objects/materials at once (= by layer). The drawback of the layer technique is that you have to have a scene with transparent background because object with lines have to be rendered in front of a transparent background. If you want more control over the lines, scenes where background transparency cannot be used and you want better results in your output the material based is the weapon of choice. Nevertheless material based is more time consuming as it requires adjusting Freestyle options for each of the materials in the scene individually.
This was it, I hope you liked this post and it helps you with your own project - keep on geekin'!
Cheers
WolfiG