2.8 Weight Painting Bug #58762

Closed
opened 2018-12-05 04:07:08 +01:00 by Saib · 18 comments

System Information
Operating system: Windows 10
Graphics card: GTX 970

*2.8 Beta, baf599610a

The Bug: When weight painting an object that is currently rigged to an armature, the brushes affect the vertexes that would be under the brush if there were no armature instead of the vertexes that are actually there.

For example: Say you have a character model that was modeled in a T-Pose. The model is currently rigged to an armature that has the character holding his arms in front of his chest. If you were to enter weight painting with the character in pose, and you were to try to paint on the characters arms, Blender would instead paint on the characters chest, because the weight painting is affecting the vertexes that would be under the brush if the character had no armature modifier. To weight paint the character's arms, you would have to paint the empty area where the arms were before the pose.

Steps to recreate the bug:

Step 1) Open Blender 2.8. Add the subdivision surface modifier to the default cube, add several subdivision levels and then apply. (Just so you have enough detail to test armatures and weight painting with.)

Step 2) Add an armature to the scene. Enter Pose Mode and move the single bone a small distance away from the cube. Switch back to Object Mode.

Step 3) Reselect the cube and add an armature modifier. Set the cube's "object" setting to the armature.

Step 4) Enter Weight Paint mode on the cube. Paint a little bit and the section you're painting should snap to the bone.

Step 5) Turn your view so that the painted vertexes are not in front of the rest of the cube. Try to paint the vertex group back down to zero, and it won't work, because you're painting an area that only has vertexes when an armature is attached. Blender thinks you're painting onto nothing.

Step 6) Now try erasing the area where the vertexes originally were. This will work, the vertexes will snap back to their original position, even though you were drawing onto where they were, rather than where they are.

Step 7) Repaint those vertexes, and then position your view so that a non-painted area is behind the painted area. Try painting the painted area, and you'll find that the non-painted area is what's affected, instead of the painted area. This happens because Blender is painting what used to be there (the non-painted area) rather than what is actually there (the painted area).

**System Information** Operating system: Windows 10 Graphics card: GTX 970 **2.8 Beta, baf599610a4* The Bug: When weight painting an object that is currently rigged to an armature, the brushes affect the vertexes that would be under the brush if there were no armature instead of the vertexes that are actually there. For example: Say you have a character model that was modeled in a T-Pose. The model is currently rigged to an armature that has the character holding his arms in front of his chest. If you were to enter weight painting with the character in pose, and you were to try to paint on the characters arms, Blender would instead paint on the characters chest, because the weight painting is affecting the vertexes that would be under the brush if the character had no armature modifier. To weight paint the character's arms, you would have to paint the empty area where the arms were before the pose. Steps to recreate the bug: Step 1) Open Blender 2.8. Add the subdivision surface modifier to the default cube, add several subdivision levels and then apply. (Just so you have enough detail to test armatures and weight painting with.) Step 2) Add an armature to the scene. Enter Pose Mode and move the single bone a small distance away from the cube. Switch back to Object Mode. Step 3) Reselect the cube and add an armature modifier. Set the cube's "object" setting to the armature. Step 4) Enter Weight Paint mode on the cube. Paint a little bit and the section you're painting should snap to the bone. Step 5) Turn your view so that the painted vertexes are not in front of the rest of the cube. Try to paint the vertex group back down to zero, and it won't work, because you're painting an area that only has vertexes when an armature is attached. Blender thinks you're painting onto nothing. Step 6) Now try erasing the area where the vertexes originally were. This will work, the vertexes will snap back to their original position, even though you were drawing onto where they were, rather than where they are. Step 7) Repaint those vertexes, and then position your view so that a non-painted area is behind the painted area. Try painting the painted area, and you'll find that the non-painted area is what's affected, instead of the painted area. This happens because Blender is painting what used to be there (the non-painted area) rather than what is actually there (the painted area).
Author

Added subscriber: @saib

Added subscriber: @saib

Added subscriber: @ZedDB

Added subscriber: @ZedDB

I can reproduce this issue too.

I can reproduce this issue too.
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Could you provide a .blend file please. That would make it easier and less time consuming for us to reproduce the bug. Thank you :)

Could you provide a .blend file please. That would make it easier and less time consuming for us to reproduce the bug. Thank you :)
[weight_prob.blend](https://archive.blender.org/developer/F5832969/weight_prob.blend) @JacquesLucke here you go.
Member

weight paint bug triangle.blend

weight paint on deformed.gif

What's interesting is that it works when instead of the Armature modifier, a Displace modifier is used to deform the geometry.

[weight paint bug triangle.blend](https://archive.blender.org/developer/F5833287/weight_paint_bug_triangle.blend) ![weight paint on deformed.gif](https://archive.blender.org/developer/F5833237/weight_paint_on_deformed.gif) What's interesting is that it works when instead of the Armature modifier, a Displace modifier is used to deform the geometry.

I've found the commit that breaks this: 4dc639ac99

It seems like the new bbone code is to blame.

I've found the commit that breaks this: https://git.blender.org/gitweb/gitweb.cgi/blender.git/commit/4dc639ac9965f3d0e8b2304363c62d888cdd1dc9 It seems like the new bbone code is to blame.
Sergey Sharybin was assigned by Brecht Van Lommel 2018-12-05 13:33:36 +01:00

Added subscriber: @brecht

Added subscriber: @brecht

Doesn't seem to be related on bbones, but more like on what object to use to calculate matricies. Think this is to be calculated for an evaluated object, which has all animation and drivers evaluated, together with all other runtime data which is needed for modifiers.

Wouldn't mind having a second thought here, @brecht? :)

P860: (An Untitled Masterwork)

diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 354cc4926f1..8062ac7a965 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -50,6 +50,8 @@
 #include "BKE_editmesh.h"
 #include "BKE_library.h"
 
+#include "DEG_depsgraph_query.h"
+
 BLI_INLINE void tan_calc_quat_v3(
         float r_quat[4],
         const float co_1- [x], const float co_2- [x], const float co_3[3])
@@ -313,17 +315,18 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
 
 int BKE_sculpt_get_first_deform_matrices(
         struct Depsgraph *depsgraph, Scene *scene,
-        Object *ob, float (**deformmats)- [x]- [x], float (**deformcos)[3])
+        Object *object, float (**deformmats)- [x]- [x], float (**deformcos)[3])
 {
 	ModifierData *md;
 	Mesh *me_eval;
 	int a, numVerts = 0;
 	float (*defmats)- [x]- [x] = NULL, (*deformedVerts)- [x] = NULL;
-	MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
-	const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
 	int numleft = 0;
 	VirtualModifierData virtualModifierData;
-	const ModifierEvalContext mectx = {depsgraph, ob, 0};
+	Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+	MultiresModifierData *mmd = get_multires_modifier(scene, object_eval, 0);
+	const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
+	const ModifierEvalContext mectx = {depsgraph, object_eval, 0};
 
 	if (has_multires) {
 		*deformmats = NULL;
@@ -332,7 +335,7 @@ int BKE_sculpt_get_first_deform_matrices(
 	}
 
 	me_eval = NULL;
-	md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+	md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData);
 
 	for (; md; md = md->next) {
 		const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -341,7 +344,7 @@ int BKE_sculpt_get_first_deform_matrices(
 
 		if (mti->type == eModifierTypeType_OnlyDeform) {
 			if (!defmats) {
-				Mesh *me = ob->data;
+				Mesh *me = object_eval->data;
 				me_eval = BKE_mesh_copy_for_eval(me, true);
 				deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
 				defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");

Doesn't seem to be related on bbones, but more like on what object to use to calculate matricies. Think this is to be calculated for an evaluated object, which has all animation and drivers evaluated, together with all other runtime data which is needed for modifiers. Wouldn't mind having a second thought here, @brecht? :) [P860: (An Untitled Masterwork)](https://archive.blender.org/developer/P860.txt) ``` diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c index 354cc4926f1..8062ac7a965 100644 --- a/source/blender/blenkernel/intern/crazyspace.c +++ b/source/blender/blenkernel/intern/crazyspace.c @@ -50,6 +50,8 @@ #include "BKE_editmesh.h" #include "BKE_library.h" +#include "DEG_depsgraph_query.h" + BLI_INLINE void tan_calc_quat_v3( float r_quat[4], const float co_1- [x], const float co_2- [x], const float co_3[3]) @@ -313,17 +315,18 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh( int BKE_sculpt_get_first_deform_matrices( struct Depsgraph *depsgraph, Scene *scene, - Object *ob, float (**deformmats)- [x]- [x], float (**deformcos)[3]) + Object *object, float (**deformmats)- [x]- [x], float (**deformcos)[3]) { ModifierData *md; Mesh *me_eval; int a, numVerts = 0; float (*defmats)- [x]- [x] = NULL, (*deformedVerts)- [x] = NULL; - MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); - const bool has_multires = mmd != NULL && mmd->sculptlvl > 0; int numleft = 0; VirtualModifierData virtualModifierData; - const ModifierEvalContext mectx = {depsgraph, ob, 0}; + Object *object_eval = DEG_get_evaluated_object(depsgraph, object); + MultiresModifierData *mmd = get_multires_modifier(scene, object_eval, 0); + const bool has_multires = mmd != NULL && mmd->sculptlvl > 0; + const ModifierEvalContext mectx = {depsgraph, object_eval, 0}; if (has_multires) { *deformmats = NULL; @@ -332,7 +335,7 @@ int BKE_sculpt_get_first_deform_matrices( } me_eval = NULL; - md = modifiers_getVirtualModifierList(ob, &virtualModifierData); + md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData); for (; md; md = md->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -341,7 +344,7 @@ int BKE_sculpt_get_first_deform_matrices( if (mti->type == eModifierTypeType_OnlyDeform) { if (!defmats) { - Mesh *me = ob->data; + Mesh *me = object_eval->data; me_eval = BKE_mesh_copy_for_eval(me, true); deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts); defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats"); ```

This comment was removed by @ZedDB

*This comment was removed by @ZedDB*

@Sergey that patch doesn't seem to solve the issue for me.

I still can't paint on the deformed verts.
I deleted my previous message too quickly. I did a quick and dirty fix by forcefully updating the bbone cache if it is missing test.patch
But this is not the way to go I suspect. It's better to figure out why the cache is missing in the first place I think.

However, if I debug the depsgraph, the cache should have been created as it reports that the armature object has run BKE_pose_eval_done. So I'm not sure why it is missing later...

@Sergey that patch doesn't seem to solve the issue for me. I still can't paint on the deformed verts. I deleted my previous message too quickly. I did a quick and dirty fix by forcefully updating the bbone cache if it is missing [test.patch](https://archive.blender.org/developer/F5834364/test.patch) But this is not the way to go I suspect. It's better to figure out why the cache is missing in the first place I think. However, if I debug the depsgraph, the cache should have been created as it reports that the armature object has run BKE_pose_eval_done. So I'm not sure why it is missing later...

Well, that's simple, one line changed :)

P861: (An Untitled Masterwork)

diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 354cc4926f1..a2c0d95e9b4 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -50,6 +50,8 @@
 #include "BKE_editmesh.h"
 #include "BKE_library.h"
 
+#include "DEG_depsgraph_query.h"
+
 BLI_INLINE void tan_calc_quat_v3(
         float r_quat[4],
         const float co_1- [x], const float co_2- [x], const float co_3[3])
@@ -313,17 +315,18 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
 
 int BKE_sculpt_get_first_deform_matrices(
         struct Depsgraph *depsgraph, Scene *scene,
-        Object *ob, float (**deformmats)- [x]- [x], float (**deformcos)[3])
+        Object *object, float (**deformmats)- [x]- [x], float (**deformcos)[3])
 {
 	ModifierData *md;
 	Mesh *me_eval;
 	int a, numVerts = 0;
 	float (*defmats)- [x]- [x] = NULL, (*deformedVerts)- [x] = NULL;
-	MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
-	const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
 	int numleft = 0;
 	VirtualModifierData virtualModifierData;
-	const ModifierEvalContext mectx = {depsgraph, ob, 0};
+	Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+	MultiresModifierData *mmd = get_multires_modifier(scene, object_eval, 0);
+	const bool has_multires = mmd != NULL && mmd->sculptlvl > 0;
+	const ModifierEvalContext mectx = {depsgraph, object_eval, 0};
 
 	if (has_multires) {
 		*deformmats = NULL;
@@ -332,7 +335,7 @@ int BKE_sculpt_get_first_deform_matrices(
 	}
 
 	me_eval = NULL;
-	md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
+	md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData);
 
 	for (; md; md = md->next) {
 		const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -341,7 +344,8 @@ int BKE_sculpt_get_first_deform_matrices(
 
 		if (mti->type == eModifierTypeType_OnlyDeform) {
 			if (!defmats) {
-				Mesh *me = ob->data;
+				/* NOTE: Need to start with original undeformed mesh. */
+				Mesh *me = object->data;
 				me_eval = BKE_mesh_copy_for_eval(me, true);
 				deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts);
 				defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats");

Well, that's simple, one line changed :) [P861: (An Untitled Masterwork)](https://archive.blender.org/developer/P861.txt) ``` diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c index 354cc4926f1..a2c0d95e9b4 100644 --- a/source/blender/blenkernel/intern/crazyspace.c +++ b/source/blender/blenkernel/intern/crazyspace.c @@ -50,6 +50,8 @@ #include "BKE_editmesh.h" #include "BKE_library.h" +#include "DEG_depsgraph_query.h" + BLI_INLINE void tan_calc_quat_v3( float r_quat[4], const float co_1- [x], const float co_2- [x], const float co_3[3]) @@ -313,17 +315,18 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh( int BKE_sculpt_get_first_deform_matrices( struct Depsgraph *depsgraph, Scene *scene, - Object *ob, float (**deformmats)- [x]- [x], float (**deformcos)[3]) + Object *object, float (**deformmats)- [x]- [x], float (**deformcos)[3]) { ModifierData *md; Mesh *me_eval; int a, numVerts = 0; float (*defmats)- [x]- [x] = NULL, (*deformedVerts)- [x] = NULL; - MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); - const bool has_multires = mmd != NULL && mmd->sculptlvl > 0; int numleft = 0; VirtualModifierData virtualModifierData; - const ModifierEvalContext mectx = {depsgraph, ob, 0}; + Object *object_eval = DEG_get_evaluated_object(depsgraph, object); + MultiresModifierData *mmd = get_multires_modifier(scene, object_eval, 0); + const bool has_multires = mmd != NULL && mmd->sculptlvl > 0; + const ModifierEvalContext mectx = {depsgraph, object_eval, 0}; if (has_multires) { *deformmats = NULL; @@ -332,7 +335,7 @@ int BKE_sculpt_get_first_deform_matrices( } me_eval = NULL; - md = modifiers_getVirtualModifierList(ob, &virtualModifierData); + md = modifiers_getVirtualModifierList(object_eval, &virtualModifierData); for (; md; md = md->next) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -341,7 +344,8 @@ int BKE_sculpt_get_first_deform_matrices( if (mti->type == eModifierTypeType_OnlyDeform) { if (!defmats) { - Mesh *me = ob->data; + /* NOTE: Need to start with original undeformed mesh. */ + Mesh *me = object->data; me_eval = BKE_mesh_copy_for_eval(me, true); deformedVerts = BKE_mesh_vertexCos_get(me, &numVerts); defmats = MEM_callocN(sizeof(*defmats) * numVerts, "defmats"); ```

That solves the problem for me, thanks for the update.

That solves the problem for me, thanks for the update.

It seems ok but incomplete, the code in BKE_crazyspace_build_sculpt() probably needs similar changes?

It seems ok but incomplete, the code in `BKE_crazyspace_build_sculpt()` probably needs similar changes?

This issue was referenced by 309d4bfbbc

This issue was referenced by 309d4bfbbc4114d314aa174fee96e716bc4fe5df

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

Just downloaded the newest patch and weight painting works again. Thank you all so much!

Just downloaded the newest patch and weight painting works again. Thank you all so much!
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
6 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#58762
No description provided.