GPv3: Vertex Paint Mode #125674

Merged
Falk David merged 51 commits from filedescriptor/blender:gpv3-vertex-paint-mode into main 2024-09-10 18:56:48 +02:00
Member

This adds the vertex paint mode from GPv2 to GPv3.

Implements the following tools:

  • Average
  • Blur
  • Draw
  • Replace
  • Smear
This adds the vertex paint mode from GPv2 to GPv3. Implements the following tools: * Average * Blur * Draw * Replace * Smear
Falk David added 2 commits 2024-07-30 18:15:27 +02:00
Falk David added this to the Grease Pencil project 2024-07-30 18:15:42 +02:00
Falk David changed title from WIP: GPv3: Vertex Paint mode to WIP: GPv3: Vertex Paint Mode 2024-07-30 18:15:47 +02:00
Falk David added 7 commits 2024-08-02 13:35:29 +02:00
Falk David added 1 commit 2024-08-02 14:09:40 +02:00
Falk David added 2 commits 2024-08-05 13:31:33 +02:00
Falk David added 4 commits 2024-08-06 11:34:44 +02:00
Falk David added 4 commits 2024-08-06 15:17:45 +02:00
Contributor

Are these still implemented as operators? Not as brushes in new asset shelf like mesh vertex paint mode?

Are these still implemented as operators? Not as brushes in new asset shelf like mesh vertex paint mode?
Author
Member

No they show up as brushes in the asset shelf.

No they show up as brushes in the asset shelf.
Falk David added 13 commits 2024-08-19 16:53:55 +02:00
Falk David added 2 commits 2024-08-23 12:10:05 +02:00
Falk David added 1 commit 2024-08-23 14:39:12 +02:00
Falk David added 1 commit 2024-08-23 14:50:08 +02:00
Falk David force-pushed gpv3-vertex-paint-mode from aad0b47738 to 93a62c7cfa 2024-08-23 14:52:54 +02:00 Compare
Falk David changed title from WIP: GPv3: Vertex Paint Mode to GPv3: Vertex Paint Mode 2024-08-23 14:53:29 +02:00
Falk David requested review from Lukas Tönne 2024-08-23 14:56:02 +02:00
Author
Member

@blender-bot build

@blender-bot build
Falk David added 1 commit 2024-08-23 18:06:22 +02:00
Add masking UI
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
be28471ced
Author
Member

@blender-bot build

@blender-bot build
Lukas Tönne approved these changes 2024-08-23 20:32:55 +02:00
Lukas Tönne left a comment
Member

Found just some minor formatting errors. Works nicely in my feeble programmer art attempts.

I'd suggest changing the grid initialization loops for the smear tool, but other optimizations can be done separately if and when needed. I expect most time in larger drawings will be spent in the common point mask constructors anyway.

Good work!

Found just some minor formatting errors. Works nicely in my feeble programmer art attempts. I'd suggest changing the grid initialization loops for the smear tool, but other optimizations can be done separately if and when needed. I expect most time in larger drawings will be spent in the common point mask constructors anyway. Good work!
@ -2372,0 +2406,4 @@
def draw(self, _context):
layout = self.layout
# layout.operator("gpencil.vertex_color_set", text="Set Color Attribute")
Member

Can be removed, or todo?

Can be removed, or todo?
Author
Member

I have a branch that implements the vertex paint operators. I can remove the commented code in this PR though.

I have a branch that implements the vertex paint operators. I can remove the commented code in this PR though.
filedescriptor marked this conversation as resolved
@ -793,1 +797,3 @@
mode = OB_MODE_VERTEX_GPENCIL_LEGACY;
/* Just toggle paintmode flag... */
gpd->flag ^= GP_DATA_STROKE_VERTEXMODE;
/* set mode */
Member

Comment formatting

Comment formatting
filedescriptor marked this conversation as resolved
@ -802,1 +818,3 @@
mode = ob->restore_mode;
if (ob->type == OB_GPENCIL_LEGACY) {
bGPdata *gpd = static_cast<bGPdata *>(ob->data);
/* try to back previous mode */
Member

formatting

formatting
filedescriptor marked this conversation as resolved
@ -371,3 +388,3 @@
static void GREASE_PENCIL_OT_sculpt_paint(wmOperatorType *ot)
{
ot->name = "Grease Pencil Draw";
ot->name = "Grease Pencil Sculpt";
Member

Unrelated fix?

Unrelated fix?
filedescriptor marked this conversation as resolved
@ -0,0 +105,4 @@
/* Compute the colors in the grid by averaging the vertex colors of the points that
* intersect each cell. */
Array<int> points_per_cell(grid_array_length, 0);
for (const int y : IndexRange(color_grid_.size)) {
Member

Hmm, doing a single loop over the point selection should be faster and simpler here, especially if it's single-threaded. I know i suggested doing this per grid cell in the first place, sorry 😁My thinking was that grid cells could be filled in parallel that way, but it's actually not necessary if the point selection mask construction is the slowest part (which it probably is). I would expect a lot more points than grid cells, so avoiding multiple loops over points is probably best.

If necessary i think this can be optimized with a parallel_reduce or EnumableThreadSpecific:

  • Local color grid per thread.
  • Threaded loop over points:
    • Find grid cell index
    • Add point to local grid
  • Accumulate grids
Hmm, doing a single loop over the point selection should be faster and simpler here, especially if it's single-threaded. I know i suggested doing this per grid cell in the first place, sorry 😁My thinking was that grid cells could be filled in parallel that way, but it's actually not necessary if the point selection mask construction is the slowest part (which it probably is). I would expect a lot more points than grid cells, so avoiding multiple loops over points is probably best. If necessary i think this can be optimized with a `parallel_reduce` or `EnumableThreadSpecific`: - Local color grid per thread. - Threaded loop over points: * Find grid cell index * Add point to local grid - Accumulate grids
filedescriptor marked this conversation as resolved
Iliya Katushenock reviewed 2024-08-24 09:09:53 +02:00
@ -918,0 +969,4 @@
/* The stroke is editable if the material is editable. If the material is not editable,
* then the stroke is only editable if the layer disables the locked material option. */
return (editable_material_indices.contains(material_index) ||
layer.use_locked_material()) &&

Move this condition outside of the predicate and just switch between 2 indexmask constructor calls.

Move this condition outside of the predicate and just switch between 2 indexmask constructor calls.
Author
Member

Opened a separate PR to handle this #127423. Will update this function to use this option.

Opened a separate PR to handle this https://projects.blender.org/blender/blender/pulls/127423. Will update this function to use this option.
Falk David added 5 commits 2024-09-09 11:29:17 +02:00
Falk David added 5 commits 2024-09-10 15:14:33 +02:00
Falk David requested review from Lukas Tönne 2024-09-10 15:16:25 +02:00
Lukas Tönne approved these changes 2024-09-10 17:37:48 +02:00
Lukas Tönne left a comment
Member

There may still be some bias in the smear brush calculations, but it's difficult to be sure without extensive testing. Should be fine for now.

There may still be some bias in the smear brush calculations, but it's difficult to be sure without extensive testing. Should be fine for now.
@ -0,0 +36,4 @@
int2 coords_to_pos(const float2 coord, const float2 center) const
{
const int2 pos = int2(math::floor((coord - center) / float(this->cell_size_px)));
return pos + this->size / 2;
Member

Should this be ceil(size/2) (or (size + 1)/2)? I think this could discard points on the fringes if the grid size is odd.

Example (just one axis):

  • Cell size 1.0 for simplicity
  • Grid size 5
  • coordinate -2.1 -> position -3
  • Relative to corner: -3 + int(5/2) = -1
    Now the point is considered outside the grid. The corner position relative to the center should be rounded up, so the relative position becomes -3 + int((5+1)/2) = 0
Should this be `ceil(size/2)` (or `(size + 1)/2`)? I think this could discard points on the fringes if the grid size is odd. Example (just one axis): - Cell size `1.0` for simplicity - Grid size `5` - coordinate `-2.1` -> position `-3` - Relative to corner: `-3 + int(5/2) = -1` Now the point is considered outside the grid. The corner position relative to the center should be rounded up, so the relative position becomes `-3 + int((5+1)/2) = 0`
filedescriptor marked this conversation as resolved
Falk David added 1 commit 2024-09-10 18:04:32 +02:00
Fix "coords_to_pos"
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
767e5662a2
Author
Member

@blender-bot build

@blender-bot build
Falk David merged commit 942499382d into main 2024-09-10 18:56:48 +02:00
Falk David referenced this issue from a commit 2024-09-10 18:56:49 +02:00
Falk David deleted branch gpv3-vertex-paint-mode 2024-09-10 18:56:52 +02:00
Falk David referenced this issue from a commit 2024-09-12 11:33:55 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 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#125674
No description provided.