Page MenuHome

Texture paint: 2D painting improvements
Needs RevisionPublic

Authored by Pablo Dobarro (pablodp606) on Thu, Sep 5, 5:57 PM.
Tags
None
Tokens
"Love" token, awarded by TheAngerSpecialist."Love" token, awarded by Ryu_Vector."Love" token, awarded by johnsyed."Love" token, awarded by xrg."Love" token, awarded by gobb_blend."Love" token, awarded by franMarz."Love" token, awarded by amonpaike."Love" token, awarded by dgsantana.

Details

Summary

This patch includes a set of features and fixes to improve the experience when using the 2D image editor for handpainted texture creation or drawing.

New brush parameters: I included a new set of parameters that are the standard in painting/drawing applications.

  • Flow: control how much paint is applied in each brush step
  • Hardness: This should be the default control of the falloff curve of the brush. In the future, this parameter can be also controlled by the brush pressure or tilt (which is not possible to do with the custom falloff curves). The custom falloff curve is multiplied on top of it, so setting the hardness to 1 and modifying the falloff curve replicates the old behavior.
  • Density: It controls how many pixels are active inside the brush radius. It can be used to add a little bit of texture and grain to the edges of the strokes
  • Wet/Dry: This controls how much paint is picked from the canvas during a stroke and how much paint from the new color is applied. This makes mixing colors a lot easier.
  • Tip X scale: enables turning the pen tip into an ellipse
  • Tip rotation: Rotation of the brush tip

(Also, strength is called opacity in most software, maybe we should rename it in paint tools to avoid confusion).

Brush radius smaller than one pixel: When the radius is smaller than one pixel due to pen pressure, the brush simulates it using the flow of the brush internally. This way you can get really thin lines without artifacts.

Before/After

Floating point precision: The stroke falloff is now calculated using the real floating point stroke position to the center of each pixel (I also added a little bit of padding to the brush buffer to avoid possible artifacts). This should fix jagged lines artifacts and give strokes a more "anti-aliased" look.

Fixed a bug in stroke spacing: The minimum spacing now is determined by the size of a pixel in screen space instead of 1.0, so now you can make thin strokes with the canvas zoomed out.

Notes:

  • This affects 2D painting only. The brush behavior is still far from perfect and I'm still experimenting with the stroke/paint code to get it right. I want to focus only on 2D painting first as it is easier to develop and prototype these kinds of things. Once we have this right, we can use it as a reference to replicate the same behavior in 3D projection painting without dealing with all that complexity now.
  • All new brush parameters can (and should) be controlled by pen pressure or tilt. I can add a flag for enabling this per property, but that won't be the ideal solution because each parameter needs a different mapping curve. We can wait to the functions branch to be merged to have full control of input->curve->output parameter mapping in the brush engine instead of adding a huge list of curves and menus to the UI (as most painting software does). For now I'm only focusing it making all parameters work as they should without creating any artifacts.

Diff Detail

Repository
rB Blender
Branch
paint-brush2d-params (branched from master)
Build Status
Buildable 4787
Build 4787: arc lint + arc unit

Event Timeline

What's the difference between Strength and Opacity, and why do we need both?

As for the UI, I think we should re-jigger some of these things to be more prominent in the main brush panel,

@William Reynish (billreynish) Strength and opacity are the same. The patch does not include opacity, but I think we should rename our current "strength" to "opacity" because with this patch both opacity and flow will control the "strength" of the brush in different ways.

Yes, I think it makes sense to rename Strength to Opacity in all the paint modes, but keep Strength in Sculpt mode.

Also, re. naming:

  • Tip X I don't find so clear. We could call it Roundness.
  • Tip Angle should probably just be Angle. The word 'tip' seems redundant I think.

@William Reynish (billreynish) Maybe we can rename tip_x to tip_scale_x. The tip does not need to be round. Most drawing programs have circular and square brush tips and I'm going to implement that next. In the future, the brush should also support tilt angle, so I think we should keep it like this.

Overall useful functionality,

  • Wet/dry: seem nice additions as-is.
  • Density: also useful as is, found name a bit confusing but not sure of a better name. Which other paint modes would this apply to?
  • Flow seems closely related to airbrush 'rate' (one is time between applying the stroke, another is the strength per update), in practice brush spacing is quite similar too. We could think of how to present these options so it doesn't feel like there are opacity options scattered around the interface.
  • Hardness: seems like it's duplicating the falloff curve, if this is added I think it could be shown next to other falloff options.
  • Tip-x/rotation: are useful but find the 'x' axis in this case not very meaningful. The gimp's "Aspect Ratio / Angle" options seem more straightforward. The brush cursor should show the aspect/angle too.

Suggest to split this into a multiple patches.

  • Tip aspect/rotation

    This should be supported for all paint modes with tablet support & cursor display.
  • Wet/dry mix.

    Support for 2D/3D paint (could support vertex colors as well).

    If added to weight-paint mode this would replace the average brush.
  • Density:

    Support for 2D/3D paint.
  • Hardness

    Support all paint modes, vertex/weight paint & sculpting.
  • Flow

    Support all paint modes, vertex/weight paint & sculpting.

    Run this by the UI team to ensure it's not confused with other options.
source/blender/editors/sculpt_paint/paint_image_2d.c
404

Should be sub_v2_v2, again for add below.

754

This seems arbitrary, why 8? (should include comment).

source/blender/makesdna/DNA_brush_types.h
333

Can be removed.

Campbell Barton (campbellbarton) requested changes to this revision.Fri, Sep 13, 3:20 PM
This revision now requires changes to proceed.Fri, Sep 13, 3:20 PM