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

Closed
opened 4 years ago by rocketman · 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.
Poster

Added subscriber: @rocketman

Added subscriber: @rocketman
matc commented 4 years ago

Added subscribers: @antoniov, @matc

Added subscribers: @antoniov, @matc
matc commented 4 years ago

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.
antoniov was assigned by brecht 4 years ago
Collaborator

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

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).
matc commented 4 years ago

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

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!
Collaborator

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

This issue was referenced by ccc7ebf7b1

This issue was referenced by ccc7ebf7b1bb5ba422efc8112d2c586a0b80af92
Collaborator

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
antoniov closed this issue 4 years ago
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/Collada
Interest/Compositing
Interest/Core
Interest/Cycles
Interest/Dependency Graph
Interest/Development Management
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/Modeling
Interest/Modifiers
Interest/Motion Tracking
Interest/Nodes & Physics
Interest/Overrides
Interest/Performance
Interest/Performance
Interest/Physics
Interest/Pipeline, Assets & I/O
Interest/Platforms, Builds, Tests & Devices
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
legacy module/Animation & Rigging
legacy module/Core
legacy module/Development Management
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/Triaging
legacy module/User Interface
legacy module/VFX & Video
legacy project/1.0.0-beta.2
legacy project/Asset Browser (Archived)
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Code Quest
legacy project/Datablocks and Libraries
legacy project/Eevee
legacy project/Game Animation
legacy project/Game Audio
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Logic
legacy project/Game Physics
legacy project/Game Python
legacy project/Game Rendering
legacy project/Game UI
legacy project/GPU / Viewport
legacy project/GSoC
legacy project/Infrastructure: Websites
legacy project/LibOverrides - Usability and UX
legacy project/Milestone 1: Basic, Local Asset Browser
legacy project/Nodes
legacy project/OpenGL Error
legacy project/Papercut
legacy project/Pose Library Basics
legacy project/Retrospective
legacy project/Tracker Curfew
legacy project/Wintab High Frequency
Meta/Good First Issue
Meta/Papercut
migration/requires-manual-verification
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 & Devices
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 Information 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#65408
Loading…
There is no content yet.