Page MenuHome

Weight Paint: use coordinates from normal evaluated mesh if same topology.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Jul 20 2022, 2:26 PM.

Details

Summary

Weight and Vertex paint don't change coordinates and thus don't need
crazyspace data, which allows using coordinates from normal evaluated
meshes.

Since painting uses original topology, the deform only mesh is used,
but if the fully evaluated mesh has the same topology, it is preferred.
This is useful because not only Geometry Nodes, but even simple weight
computation modifiers are excluded from the deform only mesh evaluation.

Diff Detail

Repository
rB Blender
Branch
temp-angavrilov-wpaint-eval-coords (branched from master)
Build Status
Buildable 23078
Build 23078: arc lint + arc unit

Event Timeline

Alexander Gavrilov (angavrilov) requested review of this revision.Jul 20 2022, 2:26 PM
Alexander Gavrilov (angavrilov) created this revision.

What does this mean for artists? What practical problem is being solved by this change?

source/blender/blenkernel/intern/paint.c
1619

Passing object, depsgraph, and evaluated object seems redundant here. Whats' the reason for this?

What does this mean for artists? What practical problem is being solved by this change?

Being able to use geometry nodes or weight mix modifiers to enforce complex custom weight layering during weight painting (in my case, enforcing a helper bone being painted to take exactly 50/50 split of weight from its two master bones). The way it is currently is nasty and confusing, because the viewport draws the fully evaluated mesh, but painting uses pure deform that completely excludes all weight manipulation.

Edit: the root issue is that the whole concept of 'deform only' is naive and obsolete, because it fails to take account of the existence of non-deform (e.g. weight mix) or generic (geometry nodes can have any effect depending on the nodes) modifiers.

source/blender/blenkernel/intern/paint.c
1619

Well, me_eval is also redundant by that argument. Maybe the right solution is passing in ob_eval instead of me_eval, because all callers just get it from BKE_object_get_evaluated_mesh(ob_eval) .

What does this mean for artists? What practical problem is being solved by this change?

Potentially a cleaner solution is to change BKE_crazyspace_build_sculpt to evaluate non-deforming modifiers, and speculatively evaluate Geometry Nodes (i.e. evaluate, then discard the result if it changed topology), but it's obviously complicated. This simply special cases the situation when the whole modifier stack doesn't change the topology and full crazyspace data isn't needed.

Sergey Sharybin (sergey) accepted this revision.EditedAug 8 2022, 2:25 PM

TL;DR: If it is tested and works correct then it is fine short-term solution.

To my knowledge the paint/texturing projects are looking into some deeper changes in PBVH, so eventually this code might not be necessary anymore.
The patch kinda stretches a system a bit: as per initial thoughts behind PBVH the idea was to use final mesh for drawing (The "use pbvh draw" code paths). This allows to show constructive modifiers while sculpting, for example. Going this route might be a bit more challenging and the performance will not be as fast as it could be.

Avoiding crazyspace and other evaluations is always good for the painting performance.

This revision is now accepted and ready to land.Aug 8 2022, 2:25 PM