GPv3: Smooth modifier #116975

Merged
YimingWu merged 26 commits from ChengduLittleA/blender:gp3-mod-smooth into main 2024-01-24 04:36:46 +01:00
Member

Smooth modifier ported to Grease Pencil 3.0

图片

Used the common stroke filtering functions and panel UI.

Exposed smooth_curve_attribute() from grease_pencil_edit.cc to achieve the smoothing effect. It will not be the exact same result as the old algorithm.

Smooth modifier ported to Grease Pencil 3.0 ![图片](/attachments/20c15cbb-277b-47ef-9eb4-e6f302c6629e) Used the common stroke filtering functions and panel UI. Exposed `smooth_curve_attribute()` from `grease_pencil_edit.cc` to achieve the smoothing effect. It will not be the exact same result as the old algorithm.
YimingWu added the
Interest
Grease Pencil
Module
Grease Pencil
labels 2024-01-10 10:10:36 +01:00
YimingWu added 3 commits 2024-01-10 10:10:45 +01:00
Iliya Katushenock added this to the Grease Pencil project 2024-01-10 11:45:12 +01:00
Iliya Katushenock removed the
Module
Grease Pencil
Interest
Grease Pencil
labels 2024-01-10 11:45:19 +01:00
Pratik Borhade reviewed 2024-01-10 13:25:18 +01:00
@ -0,0 +134,4 @@
}
IndexMaskMemory memory;
const IndexMask strokes = ed::greasepencil::retrieve_editable_and_selected_strokes(
Member

I might be wrong here but retrieve_editable_strokes looks more correct here.
Assuming modifier is expected to work on "each editable" curve and not only the "selected" curve.

I might be wrong here but `retrieve_editable_strokes` looks more correct here. Assuming modifier is expected to work on "each editable" curve and not only the "selected" curve.
Author
Member

Ah I guess so... I think @LukasTonne is working on some common functions in #116946 which includes get_drawings_for_write(). Which makes more sense. This one at the moment is mostly a placeholder for now.

Ah I guess so... I think @LukasTonne is working on [some common functions in #116946](https://projects.blender.org/blender/blender/pulls/116946/files#diff-d0b4378d8bc33d1406f044209c4b76db47d5861d) which includes `get_drawings_for_write()`. Which makes more sense. This one at the moment is mostly a placeholder for now.
ChengduLittleA marked this conversation as resolved
YimingWu added 3 commits 2024-01-16 02:51:59 +01:00
YimingWu added 3 commits 2024-01-17 06:41:32 +01:00
YimingWu added 1 commit 2024-01-17 06:42:43 +01:00
YimingWu changed title from WIP: GPv3: Smooth modifier to GPv3: Smooth modifier 2024-01-17 06:43:04 +01:00
YimingWu added 1 commit 2024-01-17 06:51:03 +01:00
b041afcf8e Removed a copy of radii smooth
was there for the UV but it's not implemented yet.
YimingWu added 1 commit 2024-01-17 09:00:40 +01:00

I tried the modifier and overall it seems to work fine, the only thing I found is that filtering by Layer doesn't work

I tried the modifier and overall it seems to work fine, the only thing I found is that filtering by Layer doesn't work
Author
Member

I tried the modifier and overall it seems to work fine, the only thing I found is that filtering by Layer doesn't work

Ah indeed. I just found out that get_filtered_stroke_mask only filters material, had to use get_filtered_layer_mask together. Will fix these.

> I tried the modifier and overall it seems to work fine, the only thing I found is that filtering by Layer doesn't work Ah indeed. I just found out that `get_filtered_stroke_mask` only filters material, had to use `get_filtered_layer_mask` together. Will fix these.
YimingWu added 1 commit 2024-01-17 13:16:30 +01:00
YimingWu added 1 commit 2024-01-17 13:21:34 +01:00
YimingWu added 2 commits 2024-01-18 07:10:14 +01:00
YimingWu added 1 commit 2024-01-18 08:50:39 +01:00
Falk David requested changes 2024-01-18 10:45:19 +01:00
Falk David left a comment
Member

Some more cleanup comments

Some more cleanup comments
@ -1129,12 +1129,12 @@ static int add_material_from_template(Main &bmain, Object &ob, const ColorTempla
return index;
}
static bke::CurvesGeometry create_drawing_data(const Span<float3> positions,
Member

This shouldn't be in this PR.

This shouldn't be in this PR.
filedescriptor marked this conversation as resolved
@ -0,0 +109,4 @@
const bool smooth_radius = (mmd.flag & MOD_GREASE_PENCIL_SMOOTH_MOD_THICKNESS);
const bool smooth_opacity = (mmd.flag & MOD_GREASE_PENCIL_SMOOTH_MOD_STRENGTH);
if (iterations <= 0 || influence <= 0) {
Member

influence <= 0.0f

`influence <= 0.0f`
ChengduLittleA marked this conversation as resolved
@ -0,0 +181,4 @@
}
if (changed) {
drawing.tag_positions_changed();
Member

This can just be put after positions.finish();. And you can remove the changed variable.

This can just be put after `positions.finish();`. And you can remove the `changed` variable.
ChengduLittleA marked this conversation as resolved
@ -0,0 +194,4 @@
if (!geometry_set->has_grease_pencil()) {
return;
}
GreasePencil *grease_pencil = geometry_set->get_grease_pencil_for_write();
Member

Use a reference here

Use a reference here
ChengduLittleA marked this conversation as resolved
YimingWu added 1 commit 2024-01-18 10:52:40 +01:00
Falk David requested changes 2024-01-18 11:07:10 +01:00
Falk David left a comment
Member

Some more comments

Some more comments
@ -7666,7 +7673,6 @@ static void rna_def_modifier_grease_pencil_opacity(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
Member

Add this line back

Add this line back
ChengduLittleA marked this conversation as resolved
@ -7683,3 +7689,3 @@
rna_def_modifier_grease_pencil_layer_filter(srna);
rna_def_modifier_grease_pencil_material_filter(
srna, "rna_GreasePencilOpacityModifier_material_filter_set");
srna, "rna_GreasePencilSmoothModifier_material_filter_set");
Member

This looks wrong, maybe a search/replace error?

This looks wrong, maybe a search/replace error?
Member

yes, name changed in wrong function

yes, name changed in wrong function
ChengduLittleA marked this conversation as resolved
@ -7686,2 +7691,3 @@
srna, "rna_GreasePencilSmoothModifier_material_filter_set");
rna_def_modifier_grease_pencil_vertex_group(
srna, "rna_GreasePencilOpacityModifier_vertex_group_name_set");
srna, "rna_GreasePencilSmoothModifier_vertex_group_name_set");
Member

Same as above

Same as above
ChengduLittleA marked this conversation as resolved
@ -17,6 +17,8 @@ set(INC
../render
../windowmanager
../../../intern/eigen
../gpencil_modifiers_legacy
Member

I think these two can be removed.

I think these two can be removed.
ChengduLittleA marked this conversation as resolved
@ -0,0 +163,4 @@
false,
opacities.span);
opacities.finish();
drawing.tag_positions_changed();
Member

No need to tag the positions, when we just changed the opacities.

No need to tag the positions, when we just changed the opacities.
ChengduLittleA marked this conversation as resolved
@ -0,0 +177,4 @@
false,
radii.span);
radii.finish();
drawing.tag_positions_changed();
Member

Same as above.

Same as above.
ChengduLittleA marked this conversation as resolved
@ -0,0 +256,4 @@
/*struct_size*/ sizeof(GreasePencilSmoothModifierData),
/*srna*/ &RNA_GreasePencilSmoothModifier,
/*type*/ ModifierTypeType::OnlyDeform,
/*flags*/ eModifierTypeFlag_AcceptsGreasePencil,
Member

This should be

static_cast<ModifierTypeFlag>(
        eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode |
        eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping)
This should be ``` static_cast<ModifierTypeFlag>( eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping) ```
ChengduLittleA marked this conversation as resolved
Member

It will not be the exact same result as the old algorithm

It might be beneficial to include a (brief) explanation of how this differs -- in preparation of users reporting this, so we can distinguish expected vs. unexpected differences

>It will not be the exact same result as the old algorithm It might be beneficial to include a (brief) explanation of **how** this differs -- in preparation of users reporting this, so we can distinguish expected vs. unexpected differences
Member

@lichtwerk We will have to test it to see if there are any differences. I don't expect it to be different actually. The algorithm should be the same.

@lichtwerk We will have to test it to see if there are any differences. I don't expect it to be different actually. The algorithm should be the same.
Member

Otherwise it should be documented in #114419

Otherwise it should be documented in https://projects.blender.org/blender/blender/issues/114419
YimingWu added 2 commits 2024-01-18 11:57:09 +01:00
YimingWu added 2 commits 2024-01-18 13:18:54 +01:00
buildbot/vexp-code-patch-lint 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-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
784bd70b90
Fix include "BKE_lib_query.hh"
Member

@blender-bot build

@blender-bot build
Pratik Borhade reviewed 2024-01-19 05:10:45 +01:00
Pratik Borhade left a comment
Member

Found one unused variable. Otherwise looks correct to me :)

Found one unused variable. Otherwise looks correct to me :)
@ -0,0 +117,4 @@
return;
}
bool changed = false;
Member

this is unused :)

this is unused :)
ChengduLittleA marked this conversation as resolved
Member

Buildbot found some formatting problem. make format will fix them: https://builder.blender.org/admin/#/builders/210/builds/346

Buildbot found some formatting problem. `make format` will fix them: https://builder.blender.org/admin/#/builders/210/builds/346
YimingWu added 1 commit 2024-01-19 06:10:45 +01:00
buildbot/vexp-code-patch-lint 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-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
bc602e8e0f
Formatting and cleanups.
Author
Member

Cleaned up like what it's shown in #117281.

Cleaned up like what it's shown in #117281.
Member

@blender-bot build

@blender-bot build
Falk David approved these changes 2024-01-19 10:48:56 +01:00
Falk David left a comment
Member

Looks good to me!

Looks good to me!
YimingWu added 2 commits 2024-01-24 04:35:40 +01:00
YimingWu added 1 commit 2024-01-24 04:35:50 +01:00
YimingWu merged commit f54348edc9 into main 2024-01-24 04:36:46 +01:00
YimingWu referenced this issue from a commit 2024-01-24 04:36:47 +01:00
YimingWu deleted branch gp3-mod-smooth 2024-01-24 04:36:48 +01:00
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
5 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#116975
No description provided.