Page MenuHome

GPencil fading based on distance to reference object in Opacity and Thickness modifiers
ClosedPublic

Authored by YimingWu (NicksBest) on Oct 2 2020, 1:34 PM.

Details

Summary

This patch allows you to dynamically control stroke's opacity and thickness using an object for distance reference in the modifier. Fading range is adjustable, and it is compatible with current curve/vertex group selection.

See GIF for example:

Diff Detail

Repository
rB Blender
Branch
temp-gpencil-fading-modifier
Build Status
Buildable 10964
Build 10964: arc lint + arc unit

Event Timeline

YimingWu (NicksBest) requested review of this revision.Oct 2 2020, 1:34 PM
YimingWu (NicksBest) created this revision.
Antonio Vazquez (antoniov) added inline comments.
source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
204

Why don't calculate only once the distance and reuse in Stroke and Fill? Also, this avoid duplicate code, no?

282

"use_fading" better than "fading"

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

"use_fading" better than "fading"

source/blender/makesrna/intern/rna_gpencil_modifier.c
895

"use_fading" better than "fading"

1416

"use_fading" better than "fading"

Antonio Vazquez (antoniov) requested changes to this revision.Oct 2 2020, 3:43 PM
This revision now requires changes to proceed.Oct 2 2020, 3:43 PM

What is the motivation for this feature? This sounds like the kind of thing that can be done with a driver. I can imagine hundreds of properties that would be useful to modify based on an object position, it's not clear to me why this needs built-in support rather than working through the generic driver system (which can be made more user friendly).

source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
150

Don't use loc, it does not contain the final position after constraints and parenting, use the translation from the object matrix instead.

YimingWu (NicksBest) marked 5 inline comments as done.Oct 2 2020, 4:01 PM
YimingWu (NicksBest) added inline comments.
source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
204

For stroke is every point, for filling it's the origin to the reference object.

YimingWu (NicksBest) marked an inline comment as done.

Fixed stuff pointed out in the comments

YimingWu (NicksBest) marked an inline comment as done.Oct 2 2020, 4:11 PM
YimingWu (NicksBest) added inline comments.
source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
150

Got it.

This is for computing fading based on distance from the reference object. Maybe a driver would be good, but that would be hard to set per-stroke. Doing it this way it's more convenient.

YimingWu (NicksBest) marked an inline comment as done.

Fixed location calculation.

Also walk() the IDs

YimingWu (NicksBest) edited the summary of this revision. (Show Details)

Updated for better handling of fading effects, can control both start and end factors.

I have tested with a simple driver and the Opacity modifier and I get something similar...not with so many options, but it works.

I don't know what is the opinion of @Matias Mendiola (mendio) and @Daniel Martinez Lara (pepeland) about this.

I have tested with a simple driver and the Opacity modifier and I get something similar...not with so many options, but it works.

This patch takes _per-vertex_ distance rather than object origin distance, drivers can't do that. This is more versatile as this could be used on a large drawing that comes from one GPencil object.

@YimingWu (NicksBest) I know, my point is to know if this feature by vertex worth a new modifier.. really I don't know, we need the opinion of artists.

@Antonio Vazquez (antoniov) It's not a separate modifier, it's just improvement on the existing one. Yes we should wait for the opinions from the artists as well.

@Antonio Vazquez (antoniov) It's not a separate modifier, it's just improvement on the existing one. Yes we should wait for the opinions from the artists as well.

You are right, I mean two set of parameters.

@YimingWu (NicksBest) I know, my point is to know if this feature by vertex worth a new modifier.. really I don't know, we need the opinion of artists.

I'm using the equivalent to this modifier in Freestyle (Distance to Object) a lot, and I think this is also necessary for LineArt/GP.

In general, LGTM.

Not sure if you need initializate the variables or not. If you need it, there is a change how is done now. You can find examples in other modifiers.

source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
98

You could here exit before and reduce if levels

if (((mmd->flag & GP_OPACITY_FADING) == 0) || ((mmd->object) == NULL)) {
return factor_depth;
}
YimingWu (NicksBest) marked an inline comment as done.
  • Merge remote-tracking branch 'origin/master' into temp-gpencil-fading-modifier
  • GPencil: simplify fading condition.
  • GPencil: Fading control UI updates.

I have tested and if you remove the Modifier, the reference object user count get negative. If you try to delete this empty, gets an assert.

ERROR (bke.lib_id): D:\MyBlender\BlenderDEV\blender\source\blender\blenkernel\intern\lib_id.c:292 id_us_min: ID user decrement error: OBEmpty (from '[Main]'): 0 <= 0

  • GPencil: Use IDWALK_CB_NOP for object references.
  • GPencil: Do not hide fading options when uncheked.

I have tested and now is working as expected.

I would like to have the UI review, especially, the parameter names and the tooltips, before commit the patch.

@Matias Mendiola (mendio) Any comment?

This revision is now accepted and ready to land.Oct 29 2020, 4:23 PM

@YimingWu (NicksBest) BTW, when you commit this change to master, be sure to update the Wiki page of the release notes (https://wiki.blender.org/wiki/Reference/Release_Notes/2.92/Grease_Pencil). Now, it's mandatory to include all changes in the release notes.

@Matias Mendiola (mendio) any problem with the UI or we can commit the patch?

@Matias Mendiola (mendio) any problem with the UI or we can commit the patch?

due that this modifier feature is tight related to the new Line Art module and also that Line Art is under review and still could suffer a lot of changes, I suggest waiting for a final Line Art design before commit

Antonio Vazquez (antoniov) requested changes to this revision.Mar 26 2021, 5:29 PM

We need to be sure this patch is working with last LineArt code.

This revision now requires changes to proceed.Mar 26 2021, 5:29 PM

Updated and working properly with latest line art code :D

I think this patch is ready for integrating into new version of blender?

@YimingWu (NicksBest) could you please update this patch, I had errors compiling it

Updated for fixing compiler warnings

Matias Mendiola (mendio) requested changes to this revision.Apr 26 2021, 1:16 AM

The new Modifier options work really nice but the Influence panel in all Grease Pencil modifiers is always the last one, please move it below the new Fading panel

This revision now requires changes to proceed.Apr 26 2021, 1:16 AM

Updated to put "influence" panel on the bottom.

This revision is now accepted and ready to land.Apr 28 2021, 4:43 PM