A line art cube

A line art cube #

At the end of this tutorial we will have made the following line art image:

A Line Drawing of a Cube
(Click here for an .svg version.)

Working through this tutorial takes 15 to 30 minutes.

Getting started with Blender #

We’ll start with a very quick introduction to Blender. If you have used it before, skip to the next section. If you haven’t used it before, I strongly recommend working through an hour or so of a more general introduction to blender, such as this one (which is newer but which I haven’t used) or this older one (which I have).

Download Blender from blender.org. After you open it, choose a theme, and select “General” from the New File options (or click elsewhere to make the splash screen go away) it will look like this. (I’m using the “White” theme, for visibility on the web, if you want it to look exactly like mine. This is version 3.2, on a Mac.)

Blender Default Scene
(Click on any screenshot for a larger version.)

The default scene has an object (a cube), a camera, and a light. Your view of the scene is independent of the camera’s view. The easiest way to move your view around the scene is the widget in the top right: clicking on the axes and the dragging will rotate, clicking on the magnifying glass and dragging will zoom, and clicking on the hand and dragging will pan.

Rotate, Zoom, Pan, Camera View

You can switch to the camera’s view by clicking the camera icon. Blender shows a frame indicating the camera’s field of view. If you move your (viewport) view you can set the camera to it by choosing “Align View:Align Active Camera to View” from the View menu.

Align to Camera

The camera’s perspective will be used to turn the 3d scene into 2d vector art. Another convenient way to control it is via its object settings. Click on “camera” from the list of objects in the scene (1) and then on the object properties tab (2). You can set the camera’s location and rotation by typing coordinates (3). You can also adjust these by clicking on the number and dragging; that is especially convenient for small adjustments. These adjustments point out a general principle of Blender: almost every attribute can be controlled precisely, by typing numbers in appropriate places, or approximately, using the gui.

Rotate to Camera

You can also adjust the field of view by switching to the camera tab (1) and adjusting the focal length (2); like with a real camera, higher numbers are more zoomed in, i.e., smaller fields of view. The default is 50mm.

Adjust Focal Length

The cube also has a position and rotation, accessed by clicking on it (in either the viewport or list of objects) and selecting the object info tab (1). Rotations can be specified in various ways; for example, set the rotation type from “XYZ Euler” to “Axis Angle” (2), the rotation vector to 0,0,1 (3), and the “Rotation W” to 15 (4) to rotate by 15 degrees around the z-axis.

Adjust Focal Length

The main way Blender is used to output pictures—but not the main way we will use it—is to “render” an image or animation of the scene, from the Render menu (1). The result is a somewhat dark image of a cube. Blender has two different backends for rendering, eevee (the default setting) and cycles, a much slower, much more accurate, physically realistic raytracer. You can choose between them in the scene settings (2,3). For most of the tutorials we will use neither of them.

Rendering

Creating line art #

Our goal is not to create a rendered image, but rather an svg line drawing. Blender has two ways to do this: an older system called Freestyle and a newer system called Grease Pencil. They now have similar capabilities, and Grease Pencil seems to be under more active development, so we will focus on it.

If you moved your camera somewhere weird in the first part of the tutorial, create a new file to start afresh. Rotate the cube if you want.

Start by switching to the camera’s view (1) and adding a new “Scene Line Art” object from the “Grease Pencil” submenu of the “Add” menu (2). You will see the cube outlined in orange, because the new Line Art object (3) is highlighted. If you click somewhere else, the cube will then be outlined in black.

Scene Line Art

If you rotate the camera enough, you will notice that the back of the cube is not outlined. The line art is detecting edges as viewed from the camera; occluded edges are not (currently) shown.

Missing Lines

Go back to the camera view. Click on the x-ray button to switch to x-ray view; the advantage will become clear in a moment.

X-ray View

Select the new Line Art object (1). Its settings are in the modifiers tab (2). Open the occlusion section (3).

The occlusion level controls which objects you see – 0 means you only see objects not blocked by the camera, 1 means you see objects that are blocked once, and so on. Change the occlusion level to 1 and 2 to see the effect. Then change it back to 1.

Occlusion

We want to see both the hidden lines and the non-hidden lines. You could accomplish that by setting “occlusion” to “range” and choosing the range, but we want them in different styles. So, we will use two different line art objects. Rename the one we have so far to “Hidden Lines” by double clicking on it (“Line Art”) in the list of objects and typing “Hidden Lines”.

Rename Object

Now add a second line art modifier by selecting the cube and adding “Object Line Art” from “Add:Grease Pencil”. Rename the new “Line Art” object to something sensible.

Object Line Art

We can cause Blender to dash-dot the hidden lines by adding a second modifier. Select the “Hidden Lines” object (1) and go to the modifiers tab (2).

Modifiers Tab

In the “Add Modifier” dropdown (1) select “Dot Dash” (2).

Add Dot Dash

This…did not have the desired effect. For me, one of the hidden edges disappeared and the other two were unchanged; your results might be slightly different. The reason is that each edge is made of a single segment, and what “dot dash” does is causes Blender to only show every other segment (roughly, I think). We can fix this by adding another modifier, “subdivide” to subdivide each segment into several…but doing that has no effect, either.

Subdivide

The problem now is that (a) modifiers don’t commute, and Blender is doing “dot dash” before subdivide, (b) we haven’t subdivided into enough segments. Also, though we can’t see the problem yet, (c) subdivide is using the “Catmull-Clark” method which introduces some smoothing; we want a “simple” subdivision.

So, scroll down to the bottom of the list of modifiers, so you see the dot-dash and subdivision modifiers. Grab the subdivision modifier using the dots to the right of the word “subdivision” and drag it above the dot-dash modifier.

Drag Subdivide

Better but not good. Change the number of subdivisions up to maybe 4 and change the method from Catmull-Clark to Simple. The result is an acceptable dashed hidden line.

Success with Dot-Dash

Now that we’ve done all that work, delete both the dot-dash and subdivide modifiers: while they look okay here, they usually don’t work well for more complicated objects. (The problem is that the frequency of dashes depends on the perspective and the curvature, whereas one expects it to just be a function of arc length in the planar projection.) To delete them, just click on the “X"s next to the modifier names.

Delete Dot-Dash

Instead, we’ll just change the line style to something distinctive, so we can easily change these to dashed lines in our .svg editor later. Click on the Materials tab (1) and change the base color (2) to something else, e.g., red (RGB 1,0,0). (Another option would be to just change the opacity, back in the modifiers tab.)

Change Color

Exporting and cleaning the result #

We’re done creating the picture, and are ready to export it and then clean it up in a vector graphics program. To export it, select “File:Export:Grease Pencil as SVG”. (Be sure to choose the right option – there are several similar ones.)

Export

In the resulting dialog box, select “Visible” under Scene Options. Then choose a place to save it and a filename.

Export Visible

We’re now done with Blender; the rest is cleanup in a (hopefully) familiar vector graphics program. For this picture, I will shade the edges of the cube and dash the hidden lines. Here’s a walkthrough of that in Illustrator.

  1. Select one of hidden lines. Ungroup it twice (Blender nests things annoyingly deeply). Select one of the hidden lines after ungrouping. Select:Same:Stroke Color. (This is actually unnecessary for this simple image.)
  2. Change the stroke color back to black, the stroke to dashed, and the dashes to 24 points (say).
  3. Select the non-hidden lines. Copy and paste in place. Object:Live Paint:Make.
  4. Use the paint bucket to fill the three different sides with three slightly different grays (to suggest three different amounts of lighting).
  5. Turn down the opacity of the Live Paint object to 75% or whatever looks good.
  6. Adjust the artboard to frame the object more tightly.
  7. Save the result as a PDF (and probably a copy as a .ai file for later tweaking).

Clean-up In Illustrator Clean-up In Illustrator Clean-up In Illustrator

After you’re done, export the result as a PDF and include it in your paper.