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

Closed
opened 2019-06-02 00:49:08 +02:00 by Sam Brubaker · 10 comments

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

GP_weight_bug.blend

To Reproduce:

  • Open the attached file (or just create a GPencil stroke with vertex weight data)
  • Enter weight paint mode for the stroke

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.

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 [GP_weight_bug.blend](https://archive.blender.org/developer/F7083019/GP_weight_bug.blend) **To Reproduce:** - Open the attached file (or just create a GPencil stroke with vertex weight data) - Enter weight paint mode for the stroke # 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.
Author

Added subscriber: @rocketman

Added subscriber: @rocketman

Added subscribers: @antoniov, @matc

Added subscribers: @antoniov, @matc

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. @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.

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. @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.
Antonio Vazquez was assigned by Brecht Van Lommel 2019-06-02 11:39:01 +02:00

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.

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.

In you file you have a maximum target weight of 0.0

image.png

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).

In you file you have a maximum target weight of 0.0 ![image.png](https://archive.blender.org/developer/F7083256/image.png) 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:
falloff.mkv

Weight 0.0 Grease Pencil and Mesh:
weight.mkv

Falloff without falloff: [falloff.mkv](https://archive.blender.org/developer/F7084107/falloff.mkv) Weight 0.0 Grease Pencil and Mesh: [weight.mkv](https://archive.blender.org/developer/F7084108/weight.mkv)
Author

In #65408#693418, @antoniov wrote:
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!

> In #65408#693418, @antoniov wrote: > 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!

@rocketman I understand the bug now with your examples... I will take a look.

@rocketman I understand the bug now with your examples... I will take a look.

This issue was referenced by ccc7ebf7b1

This issue was referenced by ccc7ebf7b1bb5ba422efc8112d2c586a0b80af92

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
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
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#65408
No description provided.