Page MenuHome

Paint: 2D paint line improvements
ClosedPublic

Authored by Pablo Dobarro (pablodp606) on Sep 17 2019, 11:03 PM.
Tags
None
Tokens
"100" token, awarded by Frozen_Death_Knight."Love" token, awarded by Brandon777."Love" token, awarded by ghfujianbin."Love" token, awarded by gobb_blend.

Details

Summary

This patch includes the line fixes and improvements described in D5697

Before/After

The extra pixels added to the brush buffer fix these kind of artifacts

Diff Detail

Repository
rB Blender
Branch
paint-line-fixes (branched from master)
Build Status
Buildable 5002
Build 5002: arc lint + arc unit

Event Timeline

Pablo Dobarro (pablodp606) updated this revision to Diff 18823.EditedOct 6 2019, 3:33 PM
Pablo Dobarro (pablodp606) edited the summary of this revision. (Show Details)
  • 2D Paint: Stroke Antialiasing

  • Remove radius factor

It should not be needed with antialiasing

Brecht Van Lommel (brecht) requested changes to this revision.Oct 7 2019, 4:44 PM

We can consider this a bugfix for 2.81.

source/blender/editors/sculpt_paint/paint_image_2d.c
391–392

use CLAMP, avoid unnecessary (int) cast.

402–404

Use (for int y = ; and similar, define variables where they are first initialized.

404–416

float total_samples = 0;

407–410

bpos[0] and bpos[1] can include offset + aa_offset, so more is computed in advance.

411

Computing sin and cos for every AA sample is slow. Compute them once in advance since rotation is fixed.

412–413

These two lines are equivalent to just doing len_v2(xy_rot).

415

Division by zero because hardness=1.

423

The 65535.0f / (float)(aa_samples * aa_samples)) normalization factor could be computed once in advance then multiplied.

745–748

Explain that the padding is needed for anti-aliasing, it's not so much fixing artifacts as just providing the proper space for it.

805

I don't see a good reason to remove this, caching the curve mask seems like an optimization we should keep.

This revision now requires changes to proceed.Oct 7 2019, 4:44 PM
Pablo Dobarro (pablodp606) marked 10 inline comments as done.
  • Review update
source/blender/editors/sculpt_paint/paint_image_2d.c
805

Any comment on this?

source/blender/editors/sculpt_paint/paint_image_2d.c
805

With antialiasing and radius < 1 the mask needs to be recalculated for every new step position, we can't rely on the previous mask diameter.

source/blender/editors/sculpt_paint/paint_image_2d.c
409–410

Rather than having a final_offset, you can do:

bpos[0] = pos[0] - floorf(pos[0]) - offset - aa_offset;
bpos[1] = pos[1] - floorf(pos[1]) - offset - aa_offset;
805

This is probably going to have a measurable performance impact for painting with big brushes. Do you think it would make sense to only do the subpixel positioning for small brushes, so we can cache the mask for big brushes?

source/blender/editors/sculpt_paint/paint_image_2d.c
805

If you are using a sharp falloff the antialiasing is quite noticeable. I personally prefer antialiasing to sightly better performance.
Also, we we add the rest of the brush parameters in D5697, the mask will need to be recalculated for almost any feature that is enabled. We should probably try to optimize this by doing something else instead of caching the mask.

2D painting performance is probably not a major issue, we'll see if it shows up in profiles.

This revision is now accepted and ready to land.Oct 7 2019, 7:10 PM