Monday, August 29, 2016

Grease Pencil - Reproject Strokes tool

Yesterday, inspired by Matias's blog post about storyboarding using Grease Pencil, I hacked together a little tool to fix up your Grease Pencil sketches when you find that you'd accidentally moved the 3D cursor around while drawing, causing all the strokes to be splayed out in weird places in 3D space.

Here's a video showing off how and when to use it (thanks to Matias for letting me use the file from the blog for testing :)

From the video description and commit log:
This operator helps fix up this mess by taking the selected strokes, projecting them to screenspace (i.e. "flattening" the strokes back on to the screen), and then putting them back out into 3D space again. As a result, it should be as if you had directly drawn the whole thing again, from the current viewpoint, but without losing the pressure/strength info.

Unfortunately, if there was originally some depth information present (i.e. you already started reshaping the sketch in 3D), then that will get lost during this process. But so far, my tests indicate that this seems to work well enough.

* Why don't we just have a way to lock the 3D cursor to prevent this problem in the first place?
I tried doing this a few months ago, but ultimately some of the other devs didn't like it, and the commit was reverted. If anyone is interested and can make their own builds, I recommend "cherry picking" this commit for use in your own builds. That's the beauty of open source - the code is there in the Blender repo (though removed), and you can hack stuff like this back in if you so desire :)

* What other alternatives are there for locking the 3D cursor?
Personally, I've been experimenting with a number of keymap changes to make Blender easier to use for Grease Pencil work. In particular, there are 3 things I'd recommend if you're doing a lot of GP work:
  1) Remap the 3D cursor keymap from "ActionMouse" to "P + ActionMouse"
  2) Add an extra keybinding for starting/stopping playback to Spacebar (instead of just Alt-A)
  3) Rebind Operator Search to "Ctrl-Spacebar"
  4) Disable or remap the "Ctrl-Spacebar" hotkey for doing stuff with manipulators. Since I never use those blasted things, I just deleted the keymap entry :)


  1. What I've always wished for is the ability to draw on an invisible 2D plane, represented by an Empty, which could then be moved around the scene.

    The Parent feature now in the 2.78 test build is nearly it, but we'd need a complimentary Stroke Placement option that would place the strokes on a "virtual," infinite 2D plane extending along the Parent object's XZ axes (with Y at by the object origin).

    1. Interesting idea... maybe we should revisit this when we start working on having the ability to have dedicated "Grease Pencil objects" in the scene. I think in that case this idea might work... or maybe it still won't work... hrm...

    2. Cool. Actually, a better way to put it might be "the ability to limit 'Surface' Stroke Placement to a designated Object."

      Right now drawing on a parented Plane object with Stroke Placement set to Surface works, but if the Plane is partially occluded by another Object the strokes stick to the occluding Object's surface as well. In this case, it would be great if we had a way to limit the Stroke Placement to only the relevant Plane, so we could "draw through" any occluding geometry. It would be OK if this also limited stroke placement to the extents of the Plane, to circumvent any potential issues "drawing across the edges" might cause, because scaling the Plane object in Edit Mode can resize the drawing surface without affecting existing strokes.

  2. Thank you for this idea!

    As I am not a build-blender-thing myself I will just wait for this operator to be implemented inside BlenderCode...

    Good news for GreasePencil users


  3. Thanks for this and your other contributions to Blender dev Aligorith.

    I had hoped that this would project onto non planar objects also to correct for any sunken or raised GP points that were drawn on said objects. After grabbing or smoothing strokes for instance.

    Would that be possible? Your thoughts on the proposal? Otherwise, is there a way to ensure strokes snap to surfaces while being sculpted? Snap to face / line / vertex didn't seem to work while sculpting them.

    Keep rockin'.