Page MenuHome

Normal Based Automasking Modes
ClosedPublic

Authored by Joseph Eagar (joeedh) on Jun 27 2022, 3:35 AM.

Details

Summary

This patch implements two new automasking modes based on vertex normals. Each mode has an associated angular limit and a falloff.

Brush Normal

Compares vertex normals with the initial normal at the beginning of the brush stroke.

View Normal

Compares vertex normals with the view normal. If "occlusion" is on then rays will be shot from each vertex to test if it is occluded by other geometry (note: this can be very slow). Only geometry inside the sculpt mesh is considered.

Diff Detail

Repository
rB Blender
Branch
temp-sculpt-normals-masking
Build Status
Buildable 23140
Build 23140: arc lint + arc unit

Event Timeline

Joseph Eagar (joeedh) requested review of this revision.Jun 27 2022, 3:35 AM
Joseph Eagar (joeedh) created this revision.

Fix compiler error.

Julien Kaspar (JulienKaspar) requested changes to this revision.EditedJun 27 2022, 11:32 AM

Some initial notes:

  • We should rename the auto-masking options to "Area Normals" and "View Normals" to follow current naming conventions and be more accurate about their functionality
  • If you try to use the filters Blender crashes
  • They don't work with any of the sculpting brushes. Only the paint brushes.
  • The automasking options are missing from the pie menu, and also the brush settings
  • A big functionality that is missing is actual occlusion masking. The View Normals auto-masking should get an additional setting to mask off any faces that are not visible.

The challenge here might then be to still allow a normal falloff past 90 degrees? We might need to discuss this further.

This revision now requires changes to proceed.Jun 27 2022, 11:32 AM

Update with latest master.

  • Changed name 'Occlusion' to 'View Normal'
  • Changed name 'Initial Normal' to 'Area Normal'
  • Added missing RNA for brush automasking.
  • Added normals automasking modes to brush advanced panel.

Automasking code now has access to original normals. This is necassary to avoid exploding mesh artifacts.

This works in a fairly clunky way that preserves the existing automasking API which gets the original
co/normals from the undo data stored per PBVHNode (except for PBVH_BMESH which is a vertex-level lookup).
An alternative is to rewrite the original co/normal API itself to always use vertex indices and not use the node undo data at all. That would be significantly simpler at a modest cost of extra memory use.

Merge with master

Joseph Eagar (joeedh) updated this revision to Diff 53738.EditedJul 17 2022, 12:10 AM

Support normal automasking modes in sculpt filters:

  • Sculpt filters now sample the area normal on first click.
  • Small cleanup: there is now a utility function for defining common filter operator properties, SCULPT_mesh_filter_properties.
  • Filters now update the last location (used for e.g. view centering).

Add occlusion mode

Revert pbvh leaf limit change.

Implement new automasking modes for factor cache mode.

Julien Kaspar (JulienKaspar) requested changes to this revision.EditedJul 28 2022, 2:33 PM

I was testing this patch a bit and we discussed this further in the module meeting.
Some notes on what we should do:

  • Expose "Area Normal" auto-masking option in the pie menu instead of "Occlusion"
  • Expose Occlusion auto-masking as a sub-setting of "View Normal" auto-masking. If occlusion is toggled it should override the behavior of view normal auto-masking then.
  • Occlusion auto-masking needs performance optimizations
  • Occlusion auto-masking needs settings to achieve a less harsh occlusion border
    • This could be achieved by adding an addition blurring propagation slider like with the cavity auto-masking patch
    • A more desirable solution would be to use the existing Limit and Falloff settings of the View Normal settings to shift the occlusion border and add a soft falloff.
This revision now requires changes to proceed.Jul 28 2022, 2:33 PM
  • Merge with master.
  • Make occlusion a suboption of view normal.
  • Fix bug in automasking factor mode.

Remove unwanted formatting changes.

Julien Kaspar (JulienKaspar) requested changes to this revision.EditedAug 17 2022, 2:24 PM

I marked some previous notes as done. Some new issues have been introduced:

  • Face Set Boundary auto-masking has disappeared from the options panel
  • Face Set Boundary auto-masking has been replaced in the pie menu by Area Normal auto-masking
  • The Occlusion sub-toggle is in Area Normal auto-masking of the brush settings instead of the View Normal auto-masking
This revision now requires changes to proceed.Aug 17 2022, 2:24 PM

I also suggest some changes and additions to the tooltips.

source/blender/makesrna/intern/rna_brush.c
3177

For consistency and clarity to the user we should change the tooltip to:
"Affect only vertices with a similar normal to where the stroke starts."

3185

This should also follow other tooltip phrasing:
"Affect only vertices with a normal that faces the viewer."

3190

We should make this tooltip more clear:
"Only affect vertices that are not occluded by other faces. (Slower performance)"

source/blender/makesrna/intern/rna_sculpt_paint.c
909

Here as well:
"Affect only vertices with a similar normal to where the stroke starts."

917

Here as well:
"Affect only vertices with a normal that faces the viewer."

922

Same here:
"Only affect vertices that are not occluded by other faces. (Slower performance)"

931

This could also use a simple tooltip:
"The range of angles that will be affected."

940

A tooltip here as well:
"Extend the range of angles with a falloff gradient."

949

Same here:
"The range of angles that will be affected."

958

Same here:
"Extend the range of angles with a falloff gradient."

Update with latest master.

Please change the description of this task See https://wiki.blender.org/wiki/Style_Guide/Commit_Messages#Commit_Types for more information what information to add.

Code looks fine by me. If there are big changes I would like to review it again.

source/blender/editors/sculpt_paint/sculpt_transform.c
70

Is this a future task or would it be part of this task and should still be implemented. Future enhancements can better be added as a ticket

Joseph Eagar (joeedh) edited the summary of this revision. (Show Details)Sep 27 2022, 7:23 PM
Joseph Eagar (joeedh) marked 11 inline comments as done.

Make requested changes.

This looks all good to me. Further tweaks and optimisations can be done once this is in master.

This revision is now accepted and ready to land.Sep 28 2022, 10:39 AM
This revision was automatically updated to reflect the committed changes.