GPv3: Fill tool #120693

Open
Lukas Tönne wants to merge 75 commits from LukasTonne/blender:gp3-fill-tool into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Implementation of the GPv2 Fill tool in Grease Pencil 3.

UI

  • Show relevant brush/tool settings in the View3D header that affect the outline stroke (radius, vertex color, etc.)

Algorithm

  • Support inversion (does this use the outer border?)
  • Construct strokes from filled area outline
  • Reproject using depth buffer (DrawingPlacement)

Features to add later (not in this PR)

  • "Precision" (pixel size) setting to change render resolution
  • Apply correct view plane transform to match visible bounds
  • TBD: reimplement or discard old approach of trying different view transforms (falls back to identity transform in 2nd pass)
  • Implement dot/square material rendering (ed::greasepencil::image_render::draw_dots)
  • Extension lines for closing gaps
  • End point circles for closing gaps
  • Special boundary strokes for closing gaps
  • Dilate/Erode after floodfill
  • Smooth & Simplify after boundary construction
  • Better leak detection filter? Cross-shaped filter function tends to leave undesirable gaps between strokes and the filled area.
Implementation of the GPv2 Fill tool in Grease Pencil 3. ### UI - [x] Show relevant brush/tool settings in the View3D header that affect the outline stroke (radius, vertex color, etc.) ### Algorithm - [x] Support inversion (does this use the outer border?) - [x] Construct strokes from filled area outline - [x] Reproject using depth buffer (`DrawingPlacement`) ## Features to add later (not in this PR) - "Precision" (pixel size) setting to change render resolution - Apply correct view plane transform to match visible bounds - TBD: reimplement or discard old approach of trying different view transforms (falls back to identity transform in 2nd pass) - Implement dot/square material rendering (`ed::greasepencil::image_render::draw_dots`) - Extension lines for closing gaps - End point circles for closing gaps - Special boundary strokes for closing gaps - Dilate/Erode after floodfill - Smooth & Simplify after boundary construction - Better leak detection filter? Cross-shaped filter function tends to leave undesirable gaps between strokes and the filled area.
Lukas Tönne added 23 commits 2024-04-16 12:05:07 +02:00
Lukas Tönne added this to the Grease Pencil project 2024-04-16 12:05:13 +02:00
Lukas Tönne added 1 commit 2024-04-16 17:18:01 +02:00
Lukas Tönne added 1 commit 2024-04-16 21:02:42 +02:00
Lukas Tönne added 1 commit 2024-04-17 10:02:03 +02:00
Lukas Tönne added 1 commit 2024-04-17 10:33:37 +02:00
Lukas Tönne added 1 commit 2024-04-17 11:21:15 +02:00
Lukas Tönne added 1 commit 2024-04-17 12:20:13 +02:00
Lukas Tönne added 1 commit 2024-04-17 12:32:19 +02:00
Lukas Tönne added 1 commit 2024-04-17 12:53:51 +02:00
Lukas Tönne added 1 commit 2024-04-17 14:36:30 +02:00
Lukas Tönne added 1 commit 2024-04-17 15:18:19 +02:00
Lukas Tönne added 1 commit 2024-04-17 15:26:48 +02:00
Lukas Tönne added 1 commit 2024-04-17 16:14:55 +02:00
Lukas Tönne added 1 commit 2024-04-17 16:34:12 +02:00
Lukas Tönne added 1 commit 2024-04-18 09:32:57 +02:00
Lukas Tönne added 1 commit 2024-04-18 10:19:01 +02:00
Lukas Tönne added 1 commit 2024-04-18 11:49:45 +02:00
Lukas Tönne added 1 commit 2024-04-18 16:24:05 +02:00
Lukas Tönne added 1 commit 2024-04-19 13:28:00 +02:00
Lukas Tönne added 1 commit 2024-04-19 14:33:56 +02:00
Member

As a clarification of the gap closure methods – there are three ways:

  1. Extend mode: extrapolating the outer segments of strokes.
  2. Radius mode: connecting the outer points of strokes.
  3. Boundary ('helper') lines, drawn with Alt-LMB.

GPv3 Fill tool gap closure methods.jpg

As a clarification of the gap closure methods – there are three ways: 1. Extend mode: extrapolating the outer segments of strokes. 2. Radius mode: connecting the outer points of strokes. 3. Boundary ('helper') lines, drawn with `Alt-LMB`. ![GPv3 Fill tool gap closure methods.jpg](/attachments/e513922b-0168-475e-8db1-842968174e3c)
Sietse Brouwer reviewed 2024-04-22 00:38:08 +02:00
Sietse Brouwer left a comment
Member

I know it's just WIP yet, but I wanted to mention that multi frame editing complicates things a bit.

GPv3 Fill tool with multi frame editing.png

In the example above, with multi frame editing enabled, the fill tool should be executed three times: for frame 1, 5 and 10. So the drawings should be retrieved grouped per frame number.

I mention it now, because it might influence how you organize your data. The boundary layers, for example, can differ per group. And the collisions of extend lines also need to be calculated per group.

I know it's just WIP yet, but I wanted to mention that multi frame editing complicates things a bit. ![GPv3 Fill tool with multi frame editing.png](/attachments/6ebe7dde-dd93-4554-b87e-9defea4c24d1) In the example above, with multi frame editing enabled, the fill tool should be executed three times: for frame 1, 5 and 10. So the drawings should be retrieved grouped per frame number. I mention it now, because it might influence how you organize your data. The boundary layers, for example, can differ per group. And the collisions of extend lines also need to be calculated per group.
@ -439,0 +640,4 @@
/* Drawings that form boundaries for the generated strokes. */
const Vector<DrawingInfo> src_drawings = ed::greasepencil::retrieve_visible_drawings(
scene, grease_pencil, false);
Member

To handle multi frame editing, the drawings must be retrieved grouped by frame number.

To handle multi frame editing, the drawings must be retrieved _grouped by frame number_.
Author
Member

I don't think there is a good utility function for this specific case yet (and it's so special that i don't think adding one is justified). I'll do this locally for the operator:

For each frame in the multi-frame-edit range:
   Get the editable drawing (if any) in the _active layer_ (this is where the new strokes go)
   Get all visible drawings, from any layer (these form the fill borders)

retrieve_editable_drawings_grouped_per_frame is close, but i only want the drawing from the active layer, otherwise the same boundary strokes would get added to all the layers.
retrieve_visible_drawings does not group drawings by frame which is probably desirable, otherwise the result would again be the same in every frame.

I don't think there is a good utility function for this specific case yet (and it's so special that i don't think adding one is justified). I'll do this locally for the operator: ``` For each frame in the multi-frame-edit range: Get the editable drawing (if any) in the _active layer_ (this is where the new strokes go) Get all visible drawings, from any layer (these form the fill borders) ``` `retrieve_editable_drawings_grouped_per_frame` is close, but i only want the drawing from the active layer, otherwise the same boundary strokes would get added to all the layers. `retrieve_visible_drawings` does not group drawings by frame which is probably desirable, otherwise the result would again be the same in every frame.
LukasTonne marked this conversation as resolved
Lukas Tönne added 1 commit 2024-04-22 09:34:28 +02:00
Author
Member

Thank you @SietseB for the explanation!

I'll try to structure the code in such a way that the different stages of the tool are more clearly separated. The GPv2 tool is using the same tGPDfill struct for every single function, which makes it hard to tell which data is relevant for which part of the process.

  1. Find all the target drawings (including multi-frame edits)
  2. Find relevant source drawings for each target, i.e. the drawings with regular boundary strokes.
  3. Render source strokes together with extension lines into the boundary buffer.
  4. Flood fill the seeded area, or all non-seeded areas if inverted.
  5. Find outlines and convert them to strokes.
  6. Post-processing for simplification/smoothing/etc.
  7. Join new strokes with existing geometry.
Thank you @SietseB for the explanation! I'll try to structure the code in such a way that the different stages of the tool are more clearly separated. The GPv2 tool is using the same `tGPDfill` struct for every single function, which makes it hard to tell which data is relevant for which part of the process. 1. Find all the _target_ drawings (including multi-frame edits) 2. Find relevant _source_ drawings for each target, i.e. the drawings with regular boundary strokes. 3. Render source strokes together with extension lines into the boundary buffer. 4. Flood fill the seeded area, or all non-seeded areas if inverted. 5. Find outlines and convert them to strokes. 6. Post-processing for simplification/smoothing/etc. 7. Join new strokes with existing geometry.
Lukas Tönne added 1 commit 2024-04-22 10:52:14 +02:00
Lukas Tönne added 1 commit 2024-04-22 12:14:56 +02:00
Lukas Tönne added 1 commit 2024-04-22 15:39:14 +02:00
Lukas Tönne added 2 commits 2024-04-22 17:09:12 +02:00
Lukas Tönne added 1 commit 2024-04-22 17:13:48 +02:00
Lukas Tönne added 1 commit 2024-04-22 21:42:33 +02:00
Lukas Tönne added 1 commit 2024-04-23 09:48:05 +02:00
Lukas Tönne added 1 commit 2024-04-23 10:19:32 +02:00
Lukas Tönne added 1 commit 2024-04-23 12:53:33 +02:00
Lukas Tönne added 1 commit 2024-04-23 14:10:57 +02:00
Lukas Tönne force-pushed gp3-fill-tool from 283cc6e221 to 0c92c70c99 2024-04-23 14:27:49 +02:00 Compare
Lukas Tönne added 1 commit 2024-04-23 15:39:49 +02:00
Lukas Tönne added 1 commit 2024-04-23 16:18:59 +02:00
Lukas Tönne changed title from WIP: GPv3: Fill tool to GPv3: Fill tool 2024-04-23 16:40:24 +02:00
Lukas Tönne added 1 commit 2024-04-24 19:00:18 +02:00
Lukas Tönne added 1 commit 2024-04-24 20:11:21 +02:00
Lukas Tönne added 1 commit 2024-04-25 09:38:12 +02:00
Lukas Tönne added 1 commit 2024-04-25 11:23:03 +02:00
Lukas Tönne added 1 commit 2024-04-25 12:53:25 +02:00
Lukas Tönne added 1 commit 2024-04-25 13:58:08 +02:00
Lukas Tönne added 1 commit 2024-04-25 14:12:54 +02:00
Lukas Tönne force-pushed gp3-fill-tool from 40c4b1400a to 5a89d4226c 2024-04-25 14:13:41 +02:00 Compare
Lukas Tönne added 1 commit 2024-04-25 17:16:06 +02:00
Lukas Tönne added 1 commit 2024-05-02 13:35:32 +02:00
Lukas Tönne added 2 commits 2024-05-02 16:37:20 +02:00
Lukas Tönne added 2 commits 2024-05-02 17:30:38 +02:00
Lukas Tönne added 1 commit 2024-05-03 15:02:54 +02:00
Lukas Tönne added 4 commits 2024-05-03 16:05:53 +02:00
Lukas Tönne requested review from Falk David 2024-05-03 16:06:16 +02:00
Lukas Tönne added 1 commit 2024-05-03 16:45:43 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
78712d8078
Include color buttons for the fill tool.
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR120693) when ready.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u gp3-fill-tool:LukasTonne-gp3-fill-tool
git checkout LukasTonne-gp3-fill-tool
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#120693
No description provided.