Page MenuHome

Fix for Grease Pencil Thickness modifier affecting strokes not in Vertex Groups
ClosedPublic

Authored by S J Bennett (quollism) on Aug 14 2019, 7:49 PM.

Details

Summary

Prior to this patch: If the Grease Pencil Thickness modifier is set to Normalize and a Vertex Group is selected, the thickness of all strokes are effected when changing the Thickness parameter. Points on strokes are only normalised (= pressure set to 1.0) if they are part of the Vertex Group; the strokes themselves may still change thickness.

With this patch: If Normalize is selected with a Vertex Group, Blender now pre-checks each stroke to determine whether it has vertices within or outside the Vertex Group. If all the points on the stroke belong to the Vertex Group, it normalises the whole stroke to a uniform thickness. If some or none of the points of the stroke belong to the Vertex Group, the stroke is now left as is.

Diff Detail

Repository
rB Blender

Event Timeline

Thanks for the code, this solves the problem, but I'm thinking that maybe would be better Normalize the points in the vertex group. I mean, if only part of the stroke is in the Vertex Group, then normalize only those points.

@Matias Mendiola (mendio) @Daniel Martinez Lara (pepeland) What do you think?

Good find @S J Bennett (quollism), thanks.

And yes @Antonio Vazquez (antoniov) , Vertex group, Material and Layer are filters that define where to apply the effect, so applying normalization only in the vertex group selected is the right way.

Note: Seems that materials pass filter has the same problem?

Thanks for the code, this solves the problem, but I'm thinking that maybe would be better Normalize the points in the vertex group. I mean, if only part of the stroke is in the Vertex Group, then normalize only those points.

Makes very good sense to get everything the same width, I agree!

So strokes have a thickness value, and a pressure value on each point changes that thickness to set the stroke width at that point. This normalisation function resets the thickness level for the stroke, then it resets the pressure value for all the points on the stroke to make the stroke even. This works until we want some points to normalise and some to stay the same - normalisation makes changes to the stroke *and* to the points along it though.

Since the thickness level on the stroke is now left unchanged unless the stroke is fully affected, we want to calculate a pressure value which takes the current stroke thickness into account. Lines 147-148 of the patch mention this.

I'll keep poking around the code to see if there's a reliable way to fake a "normalised" pressure value for points using the current thickness and target stroke thickness. I'm not super strong with maths but I'll do my best! :)

S J Bennett (quollism) updated this revision to Diff 17182.EditedAug 16 2019, 8:48 AM

Added purely pressure-based normalisation for points on partly normalised strokes, following the width calculation in editors/bf_editor_gpencil/drawgpencil.c::gp_draw_stroke_3d. Eyeball test looks OK.

Everything seems fine now, @antotoniov could you make a final check?

Antonio Vazquez (antoniov) accepted this revision.EditedAug 16 2019, 9:07 PM

For me it's ok, just replace the comments before commit the patch.

source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
151

Don't use // comments at the end of the line. Replace by /* */ above

Better start comments with Uppercase and ends with point (.)

This revision is now accepted and ready to land.Aug 16 2019, 9:07 PM

@S J Bennett (quollism) Do you have commit rights?

If not, I just need your mail to commit using your name and email.

Updated comments and removed same-line comment.

S J Bennett (quollism) marked an inline comment as done.Aug 17 2019, 5:43 AM

@S J Bennett (quollism) Do you have commit rights?
If not, I just need your mail to commit using your name and email.

I don't have commit rights. S J Bennett <quollism@ii.net> is fine. :)

Antonio Vazquez (antoniov) closed this revision.EditedAug 17 2019, 11:26 AM

@S J Bennett (quollism) You can close the revision. Thanks for your help fixing this bug.

EDIT: Sorry, I closed myself.