GPv3: Thickness modifier #117631

Merged
YimingWu merged 9 commits from ChengduLittleA/blender:gp3-mod-thickness into main 2024-01-30 13:04:42 +01:00
Member

Thickness modifier ported to Grease Pencil v3.

Note: Uniform thickness range and UI step changed to better match new thickness of blender unit.

image

Thickness modifier ported to Grease Pencil v3. Note: Uniform thickness range and UI step changed to better match new thickness of blender unit. ![image](/attachments/2e9c9bfa-d869-4bec-a529-c3833390a201)
YimingWu added 2 commits 2024-01-29 15:18:44 +01:00
YimingWu requested review from Falk David 2024-01-29 15:19:03 +01:00
YimingWu added the
Module
Grease Pencil
Interest
Grease Pencil
labels 2024-01-29 15:19:10 +01:00
YimingWu added this to the Grease Pencil project 2024-01-29 15:19:15 +01:00
YimingWu added 1 commit 2024-01-29 15:23:11 +01:00
YimingWu added 1 commit 2024-01-29 15:25:31 +01:00
Falk David requested changes 2024-01-29 15:34:48 +01:00
Falk David left a comment
Member

Some cleanup comments

Some cleanup comments
@ -8132,0 +8174,4 @@
RNA_def_property_ui_text(prop, "Weighted", "Use weight to modulate effect");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_normalized_thickness", PROP_BOOLEAN, PROP_NONE);
Member

Should be named use_uniform_thickness.

Should be named `use_uniform_thickness`.
ChengduLittleA marked this conversation as resolved
@ -0,0 +110,4 @@
const VArray<float> vgroup_weights =
attributes
.lookup_or_default<float>(mmd.influence.vertex_group_name, bke::AttrDomain::Point, 1.0f)
.varray;
Member

Instead of using .varray you can do = *attributes.lookup_or_default<float>(...);

Instead of using `.varray` you can do ` = *attributes.lookup_or_default<float>(...);`
ChengduLittleA marked this conversation as resolved
@ -0,0 +111,4 @@
attributes
.lookup_or_default<float>(mmd.influence.vertex_group_name, bke::AttrDomain::Point, 1.0f)
.varray;
const bool is_normalized = (mmd.flag & MOD_GREASE_PENCIL_THICK_NORMALIZE);
Member

Use (...) != 0;

Use ` (...) != 0;`
ChengduLittleA marked this conversation as resolved
@ -0,0 +112,4 @@
.lookup_or_default<float>(mmd.influence.vertex_group_name, bke::AttrDomain::Point, 1.0f)
.varray;
const bool is_normalized = (mmd.flag & MOD_GREASE_PENCIL_THICK_NORMALIZE);
bool is_inverted = ((mmd.flag & MOD_GREASE_PENCIL_THICK_WEIGHT_FACTOR) == 0) &&
Member

Use const

Use `const`
ChengduLittleA marked this conversation as resolved
@ -0,0 +115,4 @@
bool is_inverted = ((mmd.flag & MOD_GREASE_PENCIL_THICK_WEIGHT_FACTOR) == 0) &&
((mmd.influence.flag & GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP) != 0);
for (const int curve : curves.curves_range()) {
Member

We're only writing to the radii, so this should be a threading::parallel_for loop over the curves range.

We're only writing to the radii, so this should be a `threading::parallel_for` loop over the curves range.
ChengduLittleA marked this conversation as resolved
@ -0,0 +118,4 @@
for (const int curve : curves.curves_range()) {
for (const int local_point : points_by_curve[curve].index_range()) {
const int point = local_point + points_by_curve[curve].first();
float weight = vgroup_weights[point];
Member

Use const

Use `const`
ChengduLittleA marked this conversation as resolved
@ -0,0 +125,4 @@
if ((!is_normalized) && (mmd.flag & MOD_GREASE_PENCIL_THICK_WEIGHT_FACTOR)) {
radii[point] *= (is_inverted ? 1.0f - weight : weight);
if (radii[point] < 0.0f) {
Member

Use math::clamp instead of the if here

Use `math::clamp` instead of the if here
ChengduLittleA marked this conversation as resolved
@ -0,0 +131,4 @@
continue;
}
float curvef = 1.0f;
Member

You can use a lambda here to make this variable const. Maybe a better name would be influence too.

const float influence = [&]() {
   if (mmd.influence.flag & GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE &&
          (mmd.influence.custom_curve))
   {
      /* Normalize value to evaluate curve. */
      const float value = float(local_point) / (points_by_curve[curve].size() - 1);
      return BKE_curvemapping_evaluateF(mmd.influence.custom_curve, 0, value);
   }
   return 1.0f;
}();
You can use a lambda here to make this variable `const`. Maybe a better name would be `influence` too. ``` const float influence = [&]() { if (mmd.influence.flag & GREASE_PENCIL_INFLUENCE_USE_CUSTOM_CURVE && (mmd.influence.custom_curve)) { /* Normalize value to evaluate curve. */ const float value = float(local_point) / (points_by_curve[curve].size() - 1); return BKE_curvemapping_evaluateF(mmd.influence.custom_curve, 0, value); } return 1.0f; }(); ```
ChengduLittleA marked this conversation as resolved
@ -0,0 +140,4 @@
curvef = BKE_curvemapping_evaluateF(mmd.influence.custom_curve, 0, value);
}
float target;
Member

Same as above

const float target = [&]() {
   if (is_normalized) {
      return mmd.thickness * influence;
   }
   weight *= curvef; // why is this needed?
   return radii[point] * mmd.thickness_fac;
}();
Same as above ``` const float target = [&]() { if (is_normalized) { return mmd.thickness * influence; } weight *= curvef; // why is this needed? return radii[point] * mmd.thickness_fac; }(); ```
ChengduLittleA marked this conversation as resolved
@ -0,0 +150,4 @@
weight *= curvef;
}
float radius = math::interpolate(radii[point], target, weight * curvef);
Member

Use const

Use `const`
ChengduLittleA marked this conversation as resolved
@ -0,0 +151,4 @@
}
float radius = math::interpolate(radii[point], target, weight * curvef);
if (radius < 0.0f) {
Member

Use math::clamp instead of the if here

Use `math::clamp` instead of the if here
ChengduLittleA marked this conversation as resolved
YimingWu added 3 commits 2024-01-30 04:21:45 +01:00
Pratik Borhade reviewed 2024-01-30 09:51:11 +01:00
@ -8230,0 +8244,4 @@
rna_def_modifier_grease_pencil_layer_filter(srna);
rna_def_modifier_grease_pencil_material_filter(
srna, "rna_GreasePencilSmoothModifier_material_filter_set");
Member

rna_GreasePencilThickModifier_material_filter_set and also need to include the macro for expansion: RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET

`rna_GreasePencilThickModifier_material_filter_set` and also need to include the macro for expansion: `RNA_MOD_GREASE_PENCIL_MATERIAL_FILTER_SET`
ChengduLittleA marked this conversation as resolved
@ -8230,0 +8246,4 @@
rna_def_modifier_grease_pencil_material_filter(
srna, "rna_GreasePencilSmoothModifier_material_filter_set");
rna_def_modifier_grease_pencil_vertex_group(
srna, "rna_GreasePencilSmoothModifier_vertex_group_name_set");
Member

same as above :)

same as above :)
ChengduLittleA marked this conversation as resolved
Falk David requested changes 2024-01-30 10:34:18 +01:00
Falk David left a comment
Member

Some cleanup comments

Some cleanup comments
@ -0,0 +114,4 @@
((mmd.influence.flag & GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP) !=
0);
threading::parallel_for(curves.curves_range(), 512, [&](const IndexRange curves_range) {
Member

curves_range -> range

`curves_range` -> `range`
ChengduLittleA marked this conversation as resolved
@ -0,0 +116,4 @@
threading::parallel_for(curves.curves_range(), 512, [&](const IndexRange curves_range) {
for (const int curve : curves_range) {
for (const int local_point : points_by_curve[curve].index_range()) {
Member

Since you're looking up the points_by_curve[curve] multiple times, better put it in a variable above the inner loop.

const OffsetIndices<int> points = points_by_curve[curve];
Since you're looking up the `points_by_curve[curve]` multiple times, better put it in a variable above the inner loop. ``` const OffsetIndices<int> points = points_by_curve[curve]; ```
ChengduLittleA marked this conversation as resolved
YimingWu added 1 commit 2024-01-30 11:10:03 +01:00
buildbot/vexp-code-patch-darwin-x86_64 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
51140d5243
Cleanups
Member

@blender-bot build

@blender-bot build
Falk David approved these changes 2024-01-30 12:10:39 +01:00
YimingWu added 1 commit 2024-01-30 12:49:19 +01:00
YimingWu merged commit 4722c801c5 into main 2024-01-30 13:04:42 +01:00
YimingWu referenced this issue from a commit 2024-01-30 13:04:43 +01:00
YimingWu deleted branch gp3-mod-thickness 2024-01-30 13:05:04 +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
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#117631
No description provided.