Page MenuHome

Sculpt/Paint: Use different properties for alpha and sculpt strength
Needs ReviewPublic

Authored by Pablo Dobarro (pablodp606) on Jul 1 2020, 9:26 PM.



Currently, brushes only have an alpha property with a (0, 10) range
that was exposed in the UI as "Strength". This was causing multiple

  • The sculpt mode was using a property named alpha and BKE_brush_alpha functions to calculate the brush strength that scales the displacement of most brushes, which was confusing
  • When dealing with painting tools, the painting color could have an alpha of 10 when using BKE_brush_alpha_get, which needs to be handled as part of the color mixing code to avoid bugs.
  • As brushes that have displacement and color at the same time are planned (for sculpt vertex colors and future texture painting/normal editing painting modes) it makes sense to have the sculpt displacement strength and the alpha as separate properties

Diff Detail

rB Blender
sculpt-alpha-strength-properties (branched from master)
Build Status
Buildable 8812
Build 8812: arc lint + arc unit

Event Timeline

Pablo Dobarro (pablodp606) requested review of this revision.Jul 1 2020, 9:26 PM
Pablo Dobarro (pablodp606) created this revision.
Brecht Van Lommel (brecht) requested changes to this revision.Jul 2 2020, 12:45 PM
Brecht Van Lommel (brecht) added inline comments.

Put this behind if (!DNA_struct_elem_find(fd->filesdna, "Brush", "float", "sculpt_strength")) {, so brush strength is not always reset on startup.

This revision now requires changes to proceed.Jul 2 2020, 12:45 PM

Before committing to this particular solution we can consider this other option. The change is more intrusive, but maybe it will make things more organized:

  • Use rgba[4] instead of rgb[3] and alpha storing the color, this way is more clear than the alpha is always associated with the color. It should be accessed using BKE_brush_color_get() only when used for painting tools.
  • Rename the sculpt_strength of this patch to strength. This way the strength property can be used by displacement tools or by color tools that need strength but not alpha associated with a color (blur, smear...)

To change to RGBA instead to RGB could have impact in GPencil because the Alpha is not used and depends of other parameters. To keep GPencil running we would need to have in RNA a prop with 3 (RGB) to avoid the UI displays the Alpha channel selector. Also need some small adjustment in the paint code, but nothing big.

I'm talking of this prop:

I don't think RGBA would be convenient for palettes? Don't you usually want to keep alpha the same and only change RGB? To me it seems best to keep RGB and alpha separated, I think in general users will edit them separately.

Renaming sculpt_strength to strength is fine with me.