Page MenuHome

Sculpt: Mask extract operator
ClosedPublic

Authored by Pablo Dobarro (pablodp606) on Jul 31 2019, 9:44 PM.
Tags
None
Tokens
"100" token, awarded by Frozen_Death_Knight."Love" token, awarded by Dusty_Shoe."Love" token, awarded by Schamph."Love" token, awarded by marcog."Love" token, awarded by EitanSomething."Love" token, awarded by brilliant_ape."Love" token, awarded by erickblender."Love" token, awarded by xrg."Love" token, awarded by TheRedWaxPolice.

Details

Summary

This is a new implementation of the mask extract operator, different from the one in the sculpt branch.

It can extract the paint mask creating a boundary loop in the geometry, making it ready for adding a subdivision surface modifier. After experimenting with edit mode operators I found that this combination of boundary vertices and internal vertices smoothing works fine in most cases.

Diff Detail

Repository
rB Blender

Event Timeline

Pablo Dobarro (pablodp606) planned changes to this revision.Jul 31 2019, 9:44 PM
  • New implementation of mask extract as a mesh operator
Pablo Dobarro (pablodp606) retitled this revision from Mask extract operator to Sculpt: Mask extract operator.

Can't this use the redo panel rather than a modal popup? To me it seems tweaking these settings is better done with interactive feedback.

Adding modifiers feels a little hacky, especially the shrinkwrap one. Shouldn't it just apply them to the mesh immediately rather than keeping them as modifiers?

@Brecht Van Lommel (brecht) Is there a way to apply the shrinkwrap operation after each smooth iteration without using the modifier stack? That would be the ideal solution.
I'm not sure about how the redo panel works, but if it is going to start the whole extraction from scratch, we can't use it in high poly meshes. With the smooth iterations it is already quite slow, so with the modal popup you can disable those features on a high poly mesh. Smoothing and edge border with a high number of polygons does not make much of a difference in the result but the operation time goes from 11 seconds to 1 - 2 seconds.

Brecht Van Lommel (brecht) requested changes to this revision.Sep 6 2019, 4:38 PM

@Brecht Van Lommel (brecht) Is there a way to apply the shrinkwrap operation after each smooth iteration without using the modifier stack? That would be the ideal solution.

The shrinkwrap modifier calls shrinkwrapModifier_deform(). You can add another function to shrinkwrap.c that you can just add a Mesh and some parameters, and do whatever refactoring is needed to make that work.

Similar for solidify, that's currently a function in MOD_solidify.c, but with some refactoring it can moved to a new function that is used by both the modifier and this sculpt tool.

I'm not sure about how the redo panel works, but if it is going to start the whole extraction from scratch, we can't use it in high poly meshes. With the smooth iterations it is already quite slow, so with the modal popup you can disable those features on a high poly mesh. Smoothing and edge border with a high number of polygons does not make much of a difference in the result but the operation time goes from 11 seconds to 1 - 2 seconds.

It's a bit weak to use a different mechanism for that reason, but I don't think we have a better alternative for now so this is ok.

source/blender/editors/mesh/editmesh_mask_extract.c
256

Capitalize these and other property UI names like a title: Add Boundary Loop, Project to Sculpt, etc.

This revision now requires changes to proceed.Sep 6 2019, 4:38 PM
Pablo Dobarro (pablodp606) edited the summary of this revision. (Show Details)
  • Avoid using shirkwrap modifier
  • Add menu entry
  • Fix naming

I think we should keep the solidify as a modifier. We can't rely on the redo panel for this operator and it's common to adjust the thickness and creases after extracting.

Brecht Van Lommel (brecht) requested changes to this revision.Sep 9 2019, 7:48 PM

I think that it would be better to apply the solidify modifier as well, since it's not immediately obvious there is a modifier, when you for example want to join the meshes or sculpt the extracted mesh and get bad results.

Still it can also be useful to tweak the parameters, so I guess the way it is now works too.

source/blender/blenkernel/intern/shrinkwrap.c
1489–1492

Ensure ShrinkwrapModifierData and ModifierEvalContext do not contain uninitialized values.

Something like:

Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *sce = CTX_data_scene(C);
ShrinkwrapModifierData ssmd = {0};
ModifierEvalContext ctx = {depsgraph, ob_source, 0};
1499–1511

Can use BKE_mesh_vert_coords_alloc and BKE_mesh_vert_coords_apply for this.

This revision now requires changes to proceed.Sep 9 2019, 7:48 PM

The smoothing doesn't work that great in my tests. Just with the default Sculpting template, paint with the mask brush, the resulting extracted mesh has quite wrinkly boundary. Adding two more subdivision levels or using 20 smooth iterations still leaves it quite wrinkly.

Not necessarily to be solved before commit, but I think it's possible to do better here.

Pablo Dobarro (pablodp606) marked 2 inline comments as done.
  • Rebase
  • Review update
This revision is now accepted and ready to land.Sep 10 2019, 11:01 AM
This revision was automatically updated to reflect the committed changes.