Page MenuHome

In Grease Pencil Weight Paint, strength and falloff are ignored when painting a lesser vertex weight
Closed, ResolvedPublic

Description

version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-05-31 22:45, hash: cc600de6695a, type: Release
build date: 2019-05-31, 23:13:30
platform: Linux

To Reproduce:

  1. Open the attached file (or just create a GPencil stroke with vertex weight data)
  2. Enter weight paint mode for the stroke
  3. Using a very low-strength brush, try "gently" reducing the vertex weight.

When increasing the weight of the vertices, the weight painting behavior works as expected, but if the weight value of the brush is LESS than the vertex being painted, the effect is instantaneous, regardless of brush falloff or low strength.

Event Timeline

I had a look at the code. It looks like the brush weight is only used as limit. Every calculated weight that exceeds that limit would be set to that limit.

This should roughly fix this problem.

diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 9777a8190c1..49359d27a0d 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -921,19 +921,17 @@ static bool gp_brush_weight_apply(
   /* get current weight */
   MDeformWeight *dw = defvert_verify_index(dvert, gso->vrgroup);
   float curweight = dw ? dw->weight : 0.0f;
+  float deltaweight = gso->gp_brush->weight - curweight;
 
   if (gp_brush_invert_check(gso)) {
     /* reduce weight */
-    curweight -= inf;
+    curweight -= inf * deltaweight;
   }
   else {
     /* increase weight */
-    curweight += inf;
+    curweight += inf * deltaweight;
   }
 
-  /* verify target weight */
-  CLAMP_MAX(curweight, gso->gp_brush->weight);
-
   CLAMP(curweight, 0.0f, 1.0f);
   if (dw) {
     dw->weight = curweight;

There is a problem with this solution when the brush is inverted. Weights will be pushed towards 0 and 1 depending on whether they are lower or higher than the brush weight. And they will be pushed faster the closer they are to 0 or 1. This could be fixed. But I'm not sure what the expected behaviour is in this case. @Antonio Vazquez (antoniov) Can you have a look at this?

Another thing I noticed is that there is some falloff even if falloff is set to off.

matc (matc) lowered the priority of this task from 90 to 50.Jun 2 2019, 3:18 AM

I don't see a falloff is applied when is disabled. Really all calculation is in gp_brush_influence_calc() and it's in this function where we need get the right value (if the current one were wrong). The fallof variable that you see at the end of the function is the multiframe falloff, and always is 1.0

I'm not sure we have a problem here, because the calculation is using the same influence calculation used for all brushes (sculpt and weight paint mode), but I will try to reproduce it. Maybe the key here is the word "gently"... now all is linear, and maybe we need in the extremes some type smoothing to avoid abrut changes.

Antonio Vazquez (antoniov) lowered the priority of this task from 50 to 30.EditedJun 2 2019, 12:34 PM

In you file you have a maximum target weight of 0.0

If you set this value to 0.0, as soon you paint any vertex, the value will be set to 0,0, and this is how is deigned. If you wants to have a maximum value of 0 in the vertex and you manipulate the vertex, the program check your current value and clamp it to the valid range, in this case from 0 to 0, so it's 0.

If you increase your target weight, you can get a gently reduction of the weight (the target value is the maximum weight you can assign, by default the minimum is always 0 by vertex logic limititation range from 0.0 to 1.0).

Falloff without falloff:

Weight 0.0 Grease Pencil and Mesh:

In you file you have a maximum target weight of 0.0

If you set this value to 0.0, as soon you paint any vertex, the value will be set to 0,0, and this is how is deigned. If you wants to have a maximum value of 0 in the vertex and you manipulate the vertex, the program check your current value and clamp it to the valid range, in this case from 0 to 0, so it's 0.

The target weight of may be 0.0, but the STRENGTH of the brush is 0.001. At that strength, the effect of the brush on the vertices should hardly be noticeable at all.
Where do these words "maximum", "clamp", and "range" come from? I don't want or expect to clamp anything with a regular brush; I simply want to bring the weight values toward the target weight, but gradually, according to brush strength.

If you increase your target weight, you can get a gently reduction of the weight (the target value is the maximum weight you can assign, by default the minimum is always 0 by vertex logic limititation range from 0.0 to 1.0).

I don't understand. If for instance the weight of the vertices is 1.0, and the target weight of the brush is 0.9, the bug persists, and any vertex weight touched by the brush instantly falls to 0.9 regardless of brush strength. The user still doesn't get any intermediate values between 1.0 and 0.9. You do when you go up from 0.8 to 0.9 though. This is frustrating and inconsistent.

Compare this to established weight painting on a mesh object: If you paint a target weight of 0.0 with a weak brush, the weight of the vertices will reduce gradually, not instantly. The "weight" does not represent a range or a hard maximum, it represents the target weight. The vertex weights are pulled toward this value either quickly or slowly, depending on the strength of the brush. There are of course other blend modes which define other arithmetic operations, but these haven't been implemented for grease pencil.

When weight painting on a grease pencil stroke, however, it is as if painting with a hard brush that is always set to strength = 1.0, but only when values go down, not up. Imagine if other kinds of painting worked this way. This is absolutely a bug!

Antonio Vazquez (antoniov) raised the priority of this task from 30 to 50.Jun 3 2019, 8:11 AM

@Sam Brubaker (rocketman) I understand the bug now with your examples... I will take a look.