GSoC 2020: Editing Grease Pencil Strokes Using Curves - Feedback & Suggestions

Synopsis

Since the Blender 2.8 update, that introduced the Grease Pencil object type, there are a couple of primitives that can be added in the Grease Pencil draw mode. The user can draw a shape (e.g. a circle, arc, rectangle, etc.) using the respective tool, edit it and confirm the creation of the stroke. After this step, the shape can no longer be manipulated as a curve. I propose to add an interactive edit mode tool, that allows the user to manipulate any Grease Pencil stroke using curve handles.

Benefits

There are already multiple ways to shape a Grease Pencil stroke, including proportional editing and sculpt mode. But when it comes to, for example, inking a drawing, precise control over the curve of a stroke is essential. Moreover, users who are used to working with curves, as is common in most 2D illustration software, will be able to work in an environment that they are familiar with. This will make it possible for more people to join the Blender community. And finally, it will open up the possibility to build new tools on top of. One idea is to extend the curve primitive to be able to add more points similar to the “Polyline” tool.

Deliverables

The plan is for the user to have access to a new tool in Grease Pencil edit mode. There it can be selected as the active tool in the toolbar or called through an operator. By activating the tool, the user will be able to manipulate any selected stroke as a curve using handles.

Interface

In terms of workflow, the interface will be similar to the “Knife” and “Bisect” tools when editing meshes: the tool will stay active until confirmation. Upon activation, a curve including handles will be drawn over the selected stroke. Then the user can edit the curve and finally confirm the changes.


Mock up showing the different steps in the operator. 1) Select stroke to edit. 2) Activate tool/run operator; a curve is displayed over the stroke including handles. 3) Edit the curve with the handles 4) Exit operation; transformations are applied.

The user should be free to move the view around and also move the handles in the 3rd dimension. Furthermore there should be a way of adding/deleting a control point, e.g. Ctrl-clicking on a handle removes it and Ctrl-clicking on the curve adds a new handle.

I also would like to add options to the operator such as:

  • Re-sampling the stroke after confirmation to make it fit the curve better.
  • Allow the user to adjust how good the initial curve fitting is (number of initial control points)

There are a whole lot more possibilities, but this should be a good start.

Implementation

Because Grease Pencil strokes are a chain of line segments, we need to use a temporary curve data structure that we will convert to and from. This data structure will also be used to draw the curve to the screen.
For doing the curve fitting, I plan to use curve_fit_nd, which is already included in Blender.
Overall, I will try to adapt as much as possible from existing interactive operators such as the “Knife Tool”.

Bio

I am a 24 years old computer science student from Germany studying at the Technical University of Berlin. Currently, I am living in Vienna and finishing my bachelor thesis. Through my work and studies, I have over 5 years of experience programming in C/C++ and Python. I am also used to working in teams using Git and familiar with Phabricator. Blender became interesting to me in the 2.46 era (2008). I have been following the development and production of the open movies since then. The first time I contributed to the code was during the “Task Force” when the 2.8 Code Quest was happening. In the last couple of months I have been in contact with Antonio Vazquez (Grease Pencil coordinator), working on improving the fill tools for Grease Pencil.

Contact
You can talk to me directly on blender.chat.

15 Likes

Hi, I made a similar suggestion a long time ago on RightClickSelect. It is different because it is intended to modify sections of the stroke, and smooth the ends.
I put the link in case it contributed something, although perhaps between your proposal and if Smooth Points could work with Proportional Editing, it would no longer make sense.
Good luck with the project.

3 Likes

@LazyDodo is kind enough to provide windows build for my branch! You can download it here https://blender.community/c/graphicall/Rmbbbc/ :slight_smile:

2 Likes

Marcelo Gomez is doing some interesting work that is somewhat similar to what you are trying to achieve did you have a look or reach out to him?

2 Likes

I have seen the addon before :slight_smile: I think it’s really cool and useful, especially for animation I think. In terms of the implementation, this project is very different, since he is working with existing features and the Blender Python API. Obviously once my project becomes usable, feedback on the UI, tools, etc. are always welcome here in the thread!

1 Like

Will NURBS curves be supported as well or only bezier?

It’s not planned for the GSoC project. Maybe in the future although there needs to be a good argument for it.

Probably not worth the effort, I’m working on making a custom vector format importer.
For this project I’m currently converting NURBS curves to grease pencil objects, converting from splines only requires me to calculate the handle locations.

Hi!

I have been testing out the convert mesh to Grease Pencil on Blender 2.9 Alpha.

I found a problem with this. It is awesome but it’s still very buggy. I noticed how, when converting to Grease Pencil, it draws all these extra strokes all over that you cant delete (once in grease pencil). I modeled a basic kitchen island that looked like a letter T and noticed that it also draws the edge loops created during extrusions. To remedy that, I dissolved faces so it wouldn’t draw the extra unwanted lines. It worked but then it drew wings on the T by creating faces from the tip of the T to the bottom of the T. Looked like a squirrel suit that base jumpers wear.

It would be nice if the developers at Blender Foundation would actually give us the option to mark and unmark Grease Pencil strokes like with Freestyle lines and UV mark seams when exporting the mesh to GP.

Don’t quite know how to bring that to their attention.

Has anyone else encountered this problem?

Curious.

Great tool. Very useful but needs just a little more work. I am amazed at the stuff Blender is coming up with. I know it will change the industry!!! So excited!!!

1 Like

This thread is about the GSoC project. If you have issues with the convert to mesh tool, I suggest to ask in https://blender.chat/channel/grease-pencil-module for help.

1 Like

Great work so far! I was having a look at build 2020-08-13 ( blender-2.91.0-git.c6650146eb1c-windows64.7z ). I have a few observations on the conversion of polylines to curves (also applies to conversion of sharp corners in shapes).

As shown in the image the simplest and most accurate solution would be to have 7 nodes which would produce 0 error. However the curve editing equation produces 13 nodes with threshold 0.1 and 6 nodes with threshold 1.0. Is there any plan to add “corner nodes” into the curve solution equation?

One more suggestion, it would be great if when you dissolved a point the curve was maintained i.e. the “handles” of notes either side of the dissolved point would be adjusted to estimate the previous shape.

Thanks for the hard work!

1 Like

Thank you for the great feedback!
To awnser the question about corners: Yes. There were plans to implement something that takes corners into account. Unfortunately I only have a couple of weeks left until GSoC is over and we decided to stabalize the features that we already have and write good documentation for them (which can take a lot of time!). But here is what I had planned, that I may be able to add in the future:

  • Automatic corner detection: With a new parameter in the Curve Editing panel called “Angle threshold” we could pass that to the fitting algorithm which detects the sharp angles and then makes them vector types.
  • Manual corner setting: This would basically work like the “Mark sharp” operator with meshes. You can select one or more vertex/verticies and then mark them as corners. Then the fitting algorithm will always place a vector control point at the corresponding location.

I thought about making the curve handles adjust, when you disslove a point. I think it would have to be an option in the operator though, so when its not possible, you can turn it off. Same as before: not enough time.

In general there are many more things I would like to add (I have a long list of notes hehe)! And suggestions are always welcome!

2 Likes

Hi, is here where I should report a bug in the google summer grease pencil curves project?

You can, yes. Are you using the build from graphicall or are you building the branch yourself? If the latter is the case it would be great to know the build hash (or date).

Hello, I have used the graphicall version, I am not a programmer, I do not know how to compile. I downloaded it today. First of all thank you very much for your work, I’ve been waiting for this since grease pencil came out. I have a laptop with a uhd 620 graphics card. I use windows 10. The problem is the following. I open a new 2d animation project. I draw a normal line, I go to edit mode. I select the option to edit with curves and check only points. I select the tweak tool. If I move the center points of the controllers everything is fine in principle, but if I use the external handles blender crash.
Sometimes the first, sometimes the second, but I can never move them more than twice. I understand a bit of programming, if you think it is necessary that I build it maybe I could do it but not much else (unless you told me the steps). I am from Spain, sorry for my English and again thank you very much for your work. A greeting.

I have continued testing and have occasionally managed to move the external handles up to four times before blender crashes, for what it’s worth. The centrals, as I said, seem to work well (with centrals and external ones, I mean the three points that make up each handle, not those at the end of the curve and those inside the curve).

Thank you for the report. I believe the issue you are having is not actually related to curve editing itself, but to the viewport shading (I think I encountered this bug before, maybe on linux it just happens a lot less often). The build on graphicall is outdated and maybe the fix is already in master. I will reach out to LayzDodo and ask him to update it. Then you can try again.

Perfect, Thanks for your attention.
I will comment here, if it works for me when I try it. A greeting.

Branch was updated! You can try again now.

1 Like

Hello, I have already tried it, unfortunately it still happens the same. I can select without problem the central and external handles as many times as I want, and also move without problems from the central ones. Blender crash only when I drag with an external handle selected. It does the same if I first select, release the button and then drag as if I press to select it and drag it without lifting it previously. If I can do something to help (a video or a compilation) just tell me, I will try to help as much as I can. Thanks for letting me know that the update was already available. A greeting.