Page MenuHome

Fix T80862: Small stroke opacity modulation is best done in the fragment shader
ClosedPublic

Authored by Jamell Moore (JamellMoore) on Feb 16 2021, 4:59 PM.

Details

Summary

To avoid anti-aliasing artifacts on GPencil strokes that have a size smaller than 1 the thickness
is clamped and the opacity reduced. This was done in vertex shader but this had the side effect
of causing strokes that go from large to small to fade across their lengths.

Solution

The opacity modulation has now been moved to the fragment shader as advised by Clément Foucault.

The strokeThickness that was passed to the shader was clamped to prevent it from being too small so an additional
unclamped thickness has been passed to the fragment to calculate the opacity modulation. Alternatively I could have chosen
strokeThickness and clampedThickness but I decided against renaming the variables in the current code.

Demo

I've tested this against simple stokes and compared it to the current opacity modulation. Here's a comparison. Flickering as mentioned in T85619 is slightly more noticeable but that is to be expected.

Diff Detail

Repository
rB Blender
Branch
Fix-T80862-GPencil-opacity-mod-on-small-strokes (branched from master)
Build Status
Buildable 12927
Build 12927: arc lint + arc unit

Event Timeline

Jamell Moore (JamellMoore) requested review of this revision.Feb 16 2021, 4:59 PM
Jamell Moore (JamellMoore) created this revision.

Correction: Intuitively we should smooth step with unclampedThickness * 2 because strokeThickness
is the radius but it has the correct result with out the 2.

I will upload a before an after video to demo.

Seems pretty straightforward. I wanted to suggest to avoid another varying but I realized that may not give accurate result.

Nothing much to add. Good job!

source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl
350

typo: and the should be and

This revision is now accepted and ready to land.Feb 17 2021, 12:15 PM

Seems pretty straightforward. I wanted to suggest to avoid another varying but I realized that may not give accurate result.

Nothing much to add. Good job!

Yes I did try to avoid the other varying but couldn't see a way round it. Thanks.

I'm assuming @Antonio Vazquez (antoniov) will commit as I don't have commit access?