diff options
author | Jamell Moore <JamellMoore> | 2021-02-17 15:24:00 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-02-17 15:40:38 +0300 |
commit | 09f7c93858297ab8beafc9cf9bfa06f7d8e68ea6 (patch) | |
tree | e2291419899445b5df6c76f756f5a81b3c5d089a /source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl | |
parent | 55a69d5707ffef12a0f423ba4fa646f45af82375 (diff) |
Fix T80862: Small stroke opacity modulation is best done in the fragment shader
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.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D10438
Diffstat (limited to 'source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl index 31e6df80d23..87365c2844d 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl @@ -89,6 +89,9 @@ void main() fragColor *= stroke_round_cap_mask( strokePt1, strokePt2, strokeAspect, strokeThickness, strokeHardeness); + /* To avoid aliasing artifacts, we reduce the opacity of small strokes. */ + fragColor *= smoothstep(0.0, 1.0, unclampedThickness); + /* Holdout materials. */ if (GP_FLAG_TEST(matFlag, GP_STROKE_HOLDOUT | GP_FILL_HOLDOUT)) { revealColor = fragColor.aaaa; |