GPv3: Multiple Strokes Modifier #117796
No reviewers
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#117796
Loading…
Reference in New Issue
No description provided.
Delete Branch "ChengduLittleA/blender:gp3-mod-multiple-strokes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Multiple Strokes modifier now migrated to Grease Pencil v3.
All features seems to be working as intended.
Note:
@ -0,0 +112,4 @@
const int masked_handle = instances->add_reference(bke::InstanceReference{masked_geo});
const int unselected_handle = instances->add_reference(bke::InstanceReference{unselected_geo});
for (int i = 0; i < count; i++) {
[[maybe_unused]] const int i : IndexRange(count)
@ -0,0 +171,4 @@
threading::parallel_for(duplicated_strokes.points_range().take_front(points_num_pending),
1024,
[&](const IndexRange parallel_range) {
parallel_range
->range
(usually we use this name everywhere), same below@ -0,0 +189,4 @@
Span<float3> use_pos_r = pos_r.as_span().slice(this_stroke);
const float offset_fac = (mmd.duplications == 1) ? 0.5f :
(float(i) / float(mmd.duplications - 1));
const float thickness_factor = use_fading ? interpf(1.0f - fading_thickness,
bke::attribute_math::mix2<float>
(maybe withusing bke::attribute_math::mix2;
in top of loop to make it shorter)@ -0,0 +227,4 @@
GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write();
const int frame = grease_pencil.runtime->eval_frame;
IndexMaskMemory mask_memory;
maske_memory
->memory
Looks really good already! Need to test locally still. Only a few cleanup comments.
@ -0,0 +94,4 @@
const IndexMask curves_mask,
const IndexMask unselected_mask,
const int count,
int &original_point_count)
r_original_point_count
to indicate this is a return value@ -0,0 +149,4 @@
const float offset = math::length(math::to_scale(float4x4(ctx.object->object_to_world))) *
mmd.offset;
const float distance = mmd.distance;
bool use_fading = (mmd.flag & MOD_GREASE_PENCIL_MULTIPLY_ENABLE_FADING) != 0;
const bool
@ -0,0 +173,4 @@
1024,
[&](const IndexRange range) {
for (const int point : range) {
const float3 minter = math::cross(normals[point], tangents[point]) *
I think this should be named
miter
?More cleanup
@ -2767,0 +2774,4 @@
int flag;
/* ? */
int flags;
Right, this can be removed.
@ -8424,0 +8447,4 @@
RNA_define_lib_overridable(true);
prop = RNA_def_property(srna, "use_fade", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flags", MOD_GREASE_PENCIL_MULTIPLY_ENABLE_FADING);
Use
"flag"
Some more cleanup.
While testing it seemed like the "Fade" options don't do anything. (and the fade toggle is not in the header)
@ -0,0 +142,4 @@
const IndexMask unselected_mask = curves_mask.complement(curves.curves_range(), mask_memory);
int original_point_count;
src_point_count
@ -0,0 +164,4 @@
bke::SpanAttributeWriter<float> radii = attributes.lookup_or_add_for_write_span<float>(
"radii", bke::AttrDomain::Point);
const int points_num_pending = (mmd.duplications + 1) * original_point_count;
dst_point_count
@ -0,0 +182,4 @@
for (const int i : IndexRange(mmd.duplications)) {
using bke::attribute_math::mix2;
const IndexRange this_stroke = IndexRange(original_point_count * i, original_point_count);
this_stroke
->stroke
@ -0,0 +186,4 @@
MutableSpan<float3> instance_positions = positions.slice(this_stroke);
MutableSpan<float> instance_opacity = opacities.span.slice(this_stroke);
MutableSpan<float> instance_radii = radii.span.slice(this_stroke);
Span<float3> use_pos_l = pos_l.as_span().slice(this_stroke);
Maybe
stroke_pos_l
(andstroke_pos_r
below)@ -0,0 +194,4 @@
1.0f - fading_thickness,
1.0f) :
1.0f;
const float opacity_factor = use_fading ? interpf(1.0f - fading_opacity,
Use
mix2
here as well.The
uiLayoutPanelProp
doesn't support ui in header yet. Other modifiers have been like this too.Cleaned up the rest. For some reason my
instance_radii[point]
is always 0, I added a printf there, not sure where exactly is wrong...@ -0,0 +162,4 @@
bke::SpanAttributeWriter<float> opacities = attributes.lookup_or_add_for_write_span<float>(
"opacity", bke::AttrDomain::Point);
bke::SpanAttributeWriter<float> radii = attributes.lookup_or_add_for_write_span<float>(
"radii", bke::AttrDomain::Point);
"radius"
Also checked against legacy modifier to make sure the offsetting direction is the same for both.
While testing this again I noticed that some memory might be leaking:
Otherwise it seems to be working correctly.
@ -223,1 +223,4 @@
"Duplicate strokes like a mirror"},
{eModifierType_GreasePencilMultiply,
"GREASE_PENCIL_MULTIPLY",
ICON_MOD_CURVE,
I think this should be
GP_MULTIFRAME_EDITING
(should have it's own icon, but that's what GPv2 used)Had to use
curves = std::move(duplicated_strokes);
to avoid the unfreed reference, still not sure exactly how this works 😅Right that makes sense, you don't want to copy the curves at that point. The
operator=
when assigning oneCurvesGeometry
to another, creates a copy. Moving the curves does not make a copy.@blender-bot build
@ -0,0 +155,4 @@
const float fading_center = mmd.fading_center;
MutableSpan<float3> positions = duplicated_strokes.positions_for_write();
const Span<float3> normals = duplicated_strokes.evaluated_normals();
It may be much faster to get the normals from the original curves if possible, since there are many fewer points, and the normals might be cached already. I wouldn't spend time on that unless you have a good idea how to do it though.
Two potentially problematic things though:
I guess I'll add a check to ensure they only work on poly curves (maybe also change the name into
extend_polycurves
?)I'm thinking of adding an option for toggle between plane normal and per-vertex normal. The per-vertex was initially the intention but a bit more complicated when I was working on the old modifier. per-vertex would look nicer on 3d curves.
Let's keep it simple and use the plance normal.
@blender-bot build
d81f068672
to944cf022ca
@ -0,0 +154,4 @@
const float fading_center = mmd.fading_center;
MutableSpan<float3> positions = duplicated_strokes.positions_for_write();
const Span<float3> normals = duplicated_strokes.evaluated_normals();
This should be
const Span<float3> normals = drawing.curve_plane_normals();
I might have somehow
ctrl-z
'ed on that. It should have been changed to that already 😅 Sorry about the confusion.@blender-bot build