By Antonio Vazquez
Spring 2016, I was playing around with Blender 2.77 grease pencil when I noticed a bug in the stroke filling, so I decided try to fix it and contribute to the Blender project. Since then, I have done more than 1,100 commits for grease pencil as a volunteer and I think it’s time to write my first blog entry.
Grease pencil has something very special, because you need to keep the feeling of a 2D animation inside a 3D environment, integrating these two worlds smoothly. But this challenge makes more exciting to work in an area that can change how 2D animation will work in the future.
Christmas is around the corner and the Hero open movie directed by Daniel M. Lara is on production for several weeks already, working in a daily basis with the Grease Pencil branch.
Working in a real production is the best way to fine tune a software and find the real artistic requirements as well as to polish workflows. Therefore the Hero open movie is a perfect way to improve grease pencil.
During these weeks the Hero team has requested a lot of new features and adjustments to adapt grease pencil to the production workflow. Sometimes the changes were simple modifications of default values but other times the changes were bigger like the multi frame editing falloff.
Let’s review some of these new features and changes we have been working on. Thanks to Daniel Lara and Matias Mendiola for providing the demonstration videos of this article.
Multi frame editing falloff
When you are doing a 2D animation, it’s very common to need to redraw or touch several frames in order to get a smooth animation. You usually use the onion skinning available (I added support for more onion skinning modes too). The problem with onion skinning is that you can only “see” the animation, but you cannot edit the drawings.
The Hero team requested a way to change multiple frames at the same time, so I developed a new multi frame edition mode that allows changing several frames at the same time. You can select the frames affected using the Dopesheet. This multi frame edition saves a lot of time to animators.
After thinking about the problem, Daniel came with the idea of a falloff effect. A few tests later, and I implemented a way to calculate a smooth transition for sculpted frames. Now, if you move the stroke some units in the current frame, the previous and next selected frames will also be affected, based on an interpolation curve.
With this approach you can get smooth transitions. And by adjusting the interpolation curve, a slow in/out effect can be now easily achieved.
Modifiers are something we use everyday in 3D, but it’s something totally new in grease pencil.
The first step to implement this for grease pencil was to determine how to reuse the current infrastructure, while customizing it to the 2D requirements. I did an initial design and after a lot of trial and error, I got something that worked, but after some review by other developers, the initial design required some changes to keep better aligned with the general Blender modifiers design. Finally, with the help of Joshua (Leung), we got a better design and implementation.
This is the current list of the new modifiers.
Grease pencil has some special requirements that could be handled with modifiers. In some cases, however, the modifier was not modifying the stroke properties, as all 3D meshes modifiers do, but changing their look only.
To solve this “look only” modifiers, I designed the VFX modifiers, that work in a similar way to the Eevee viewport effects, affecting the look of the image of the grease pencil object. This is done using a full screen shader that works as a filter for the image. The VFX modifiers can be different for each object, so we can activate VFX blur for one object while keeping other objects sharp.
Since I started to develop for grease pencil, one of my first idea was to add some type of lighting support.
Lighting is a complex topic, especially when you are working with 2D elements in a 3D world. In 2D, the concepts of normals, faces and so on changes a little, so you need to find a way to mimic all these things in a 2D environment.
As real lighting was out of scope at this moment (it would require more work on Eevee which has its own priorities at the moment), I decided to implement some way of 2D lighting using a special VFX shader.
VFX can be applied to a single object and get cool effects, but this lighting has no relation with other objects. In the future, a full Eevee integration of grease pencil could be implemented, but for now, something is better than nothing.
The main problem in the development was how to manage the light position and how to convert this to the 2D world. Finally, I got an algorithm to calculate the distance to an “invisible” plane represented by the strokes and after some debugging I got a good result.
Build modifier is something all animators want. Here Joshua comes with a great implementation.
The build modifier allows to animate the drawing of the strokes in a similar fashion of the Build modifier for 3D objects.
The simplify process was something you think is necessary from the first stages of the design, but it was one that shows how important it is to have real talented artists working in the development process.
The initial idea of this modifier was to use the same algorithm that I’ve used in my grease pencil add-on last year. I was investigating and the most used one was the Ramer–Douglas–Peucker algorithm. This algorithm takes a line and simplify it keeping as much as possible of the original shape.
The first implementation of the modifier worked using the RDP algorithm, but after several weeks, the Hero team requested a more simple way of “cleaning” the drawings, so I had to implement a simple way to remove a point for every 2 points. Finally, I added a parameter to apply recursively the fixed simplify logic to speed up cleaning.
This new simplify fixed mode was something that as developer I have never thought, but for artists, it shows up as a natural requirement for production workflow.
To be able to move some strokes of the same object in a free way was something that came to my mind thinking in how to move the eyebrows of a character without affecting other areas.
To solve tasks like this, the offset modifier is a great tool because you can filter by layer, pass index or vertex group, so you can apply any type of transformation to selected areas of the drawing or create cool effects as showed in the following video.
There were a lot of things that were modified during these past weeks that are not visible but have a lot of impact. Here, Joshua did a great job refactoring the code to use the new depsgraph and align some parts to be ready to merge with 2.8 branch. I know these are not fancy areas, but we must thanks Joshua for his excellent work again. It’s never too much to remind that he is the original developer of grease pencil in Blender, and none of this would be possible without his work.
All of you ask me when we are going to merge the grease pencil branch in 2.8. We want to merge it as soon as possible, but as 2.8 is changing every day and the resources are limited, we have not found the time to do it yet.
We have done more things, and are keeping doing, but I think for this first article is enough. We will keep you informed of new developments.
Grease Pencil Developers:
Antonio Vazquez (@antonioya_blend)
Joshua Leung (@aligorith)
Daniel M. Lara (@_pepeland_)
Matias Mendiola (@mmendio)