In the past week, the geometry nodes team, technical artists from the Blender Studio, as well as myself came together to come up with an initial design for the Grease Pencil integration into Geometry Nodes that would be ready for main
(behind the “Grease Pencil 3” experimental flag). In this post, I’d like to describe what we have agreed upon.
Principle
In the context of Geometry Nodes, Grease Pencil
is just a bunch of Curves
. All the nodes that work for Curves
should also work for Grease Pencil
.
The Grease Pencil Geometry Component
Grease Pencil
will be exposed as its own Geometry Component. First, let’s remind ourselves how Grease Pencil
data is structured.
The Grease Pencil
data contains a list of grease pencil layers**. Each layer has its own “timeline” where keyframes represent a drawing. We can think of a drawing as just Curves
geometry.
One powerful aspect of grease pencil is that each keyframe can have its own geometry. This enables the frame-by-frame workflow that 2D animators are used to.
In the context of modifiers and geometry nodes, each layer will “contain” one Curves
geometry - the one that is visible on the current frame.
Screenshot of the grease pencil dopesheet. The highlighted keyframes are the visible ones. Each of them refers to its own
Curves
geometry.
Layer Domain
Layers can have custom attributes. The Grease Pencil
component will have a Layer
domain:
Work-in-progress spreadsheet domains UI
Importantly, Grease Pencil
geometry does not have a curve or point domain. This is because each layer contains its own Curves
geometry, separate from all the other ones. Therefor each layer can have different attributes on their curve and point domain. This is similar to how Instances
work, with the difference that layers cannot be nested. There is just a flat list of them in the Grease Pencil
geometry.
**Technically the layers are structured in a tree where layer groups are nodes that can have zero or more layer nodes as children. This does not matter for geometry nodes though, because layer groups cannot have attributes and are meant for visual organization. In the context of geometry nodes, we treat layers as being in a flat list.
Field Evaluation Design
As described above, there is no curve/point domain on the Grease Pencil
geometry. This has the important consequence that we cannot adapt the layer domain to, say, the curve domain.
However, we can still evaluate fields on the curve/point domain by iterating over all layers and evaluating the field on each Curves
geometry separately.
This means that e.g. when using the Index
input for a node that works on the point domain it will evaluate this field individually across all layers rather than globally.
For example, if there are 2 layers, one with 10 points and one with 15 points, a node evaluating a field that uses the Index
input will evaluate for the first layer (index ranges from [0,9]
) and for the second (index ranges from [0,14]
), rather than evaluating across all layers with indices ranging from [0,24]
.
First Milestone
For the first milestone, the plan is to first add the layer domain and allow layers to have custom attributes. Then the idea is to not add any new nodes. Instead, we’ll make existing nodes work with Grease Pencil
geometry. Namely all the Curves
nodes.
So the first milestone should include:
- Attribute nodes
- E.g. storing/reading named attributes.
- Generic geometry nodes
- E.g. “Transform”, “Set Position”, etc.
- Curve nodes
- E.g. “Trim Curve”
- Material nodes
- E.g. “Set Material”
Example
Here we have an example of how Grease Pencil
would behave in Geometry Nodes.
The Grease Pencil
object has two layers. “Lines” and “GP_Layer”. The latter is hidden.
The two layers show up in the spreadsheet as two rows (0 and 1). Storing a named attribute on the layer domain shows up as a column as you would expect.
The “Set Position” node sets the position of the points of the Curves
geometry in each layer. Here we’re using a noise texture to add some noise to the drawing.
The “Trim Curve” node trims all the curves in all the layers. In this case we just trim all of them by a fixed value from the start and end.
Pull Request
Of course this is still WIP, but the PR with the current state can be found here: https://projects.blender.org/blender/blender/pulls/112535
Get Involved
If you’d like to contribute to the Grease Pencil 3 project, head on over to the chat. It’s always good to ask in there if there is anything to be worked on. We also have a workboard with todo tasks and community tasks for new contributors.