Maniphest T96708

Migrate Texture To Texture mask for existing brushes
Confirmed, NormalTO DO

Assigned To
None
Authored By
Jeroen Bakker (jbakker)
Mar 22 2022, 3:15 PM
Tags
  • Sculpt, Paint & Texture
Subscribers
Jeroen Bakker (jbakker)

Description

Texture painting brush uses two textures:

  • Texture that overrides the color of the brush (brush.mtex)
  • Texture Mask that acts as a masking reducing the effect of the brush. (brush.mask_mtex)

Sculpt/Vertex painting only supports a single mask.

  • Texture that acts as a masking to reduce the effect of the brush. (brush.mtex)

This is confusing when we combine the texture painting and vertex painting in the same mode.

Cleanups to be done:

  • BKE_brush_sample_tex_3d currently only uses mtex, perhaps a reason why sculpt is using mtex as mask_tex. masktex only has a 2d variant.

Approach

After doing some prototypes and detecting the different viewpoints about mtex by different developers, I was researching a solution that could sanitize this issue. Sanitation is required due to:

  • Sculpt mode uses mtex for masking. Newly created brushes that could benefit from color masks are hard to implement in a maintainable fashion.
  • Sculpt mode uses a concept of primary and secondairy mask texture.

Main idea is that all functions that access mtex/mask_mtex would access it via a wrapper.

struct MTexAccessor {
  MTex *color;
  MTex *mask;
};

Different tools/modes would then be responsible to create and fill this struct.
Specific implementations would only access the mask via the wrapper that is suitable for the functionality.
For example SCULPT_brush_strength_factor should pass MTextAccessor::mask to the BKE_brush_sample_tex_3d.

After this is done we could migrate per mode/tool to the actual brush mtex attribute that is designed for it.

Event Timeline

Jeroen Bakker (jbakker) changed the task status from Needs Triage to Confirmed.Mar 22 2022, 3:15 PM
Jeroen Bakker (jbakker) created this task.
Jeroen Bakker (jbakker) mentioned this in T96225: PBVH image texture painting implementation.
Julien Kaspar (JulienKaspar) moved this task from Backlog to Community & Sub-Tasks on the Sculpt, Paint & Texture board.Apr 6 2022, 2:31 PM
Brecht Van Lommel (brecht) moved this task from Community & Sub-Tasks to To Do on the Sculpt, Paint & Texture board.Apr 6 2022, 7:00 PM
Jeroen Bakker (jbakker) updated the task description.Sep 19 2022, 4:05 PM
Jeroen Bakker (jbakker) updated the task description.Sep 20 2022, 9:02 AM
Jeroen Bakker (jbakker) updated the task description.Sep 20 2022, 9:22 AM
Jeroen Bakker (jbakker) updated the task description.Oct 11 2022, 4:23 PM
Julien Kaspar (JulienKaspar) moved this task from To Do to In Progress on the Sculpt, Paint & Texture board.Dec 20 2022, 12:23 PM