Grease pencil. Artefacts at beginning of strokes #87984

Open
opened 2021-05-02 11:25:43 +02:00 by Tomasz Kaye · 13 comments

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce RTX 2060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.30

Blender Version
Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-04-23 20:25, hash: 17fca62fff

Short description of error
Grease pencil strokes drawn with a stylus have unwanted artefacts at their beginning. Especially noticeable at high radius settings. Related to this, the start of a stroke is often narrower than the artist's intention.

image.png

Exact steps for others to reproduce the error

  • Open new document, 2d animation
  • Set brush strength to 1 (not using pressure)
  • Set brush radius to 200 (using pressure)
  • draw several lines with a stylus
  • zoom in to inspect the start of the lines. There are artefacts, a 'lumpy' line close to the beginning of the stoke (see screenshot)

Notes
When you draw with deformable physical natural media (e.g. a paint brush, felt-tip) adding pressure increases the size of the mark, even when the tip is not moving over the paper. Other drawing programs also work this way. Currently blender doesn't work this way.

I looked at the source code (gpencil_paint.c). Here's what i think is going wrong with the grease pencil strokes:

When the pressure difference between two close adjacent vertices is large this can cause ugly 'lumps' in the line.

Currently, stylus pressure can be very different between the first and second vertex recorded in a grease pencil stroke. This is because there can be a large time difference between the recording of the two points; The first vertex stores a record of the pressure only at the moment the stylus first touches the tablet, subsequent changes of pressure before the stylus begins to move across the tablet are not recorded in the stroke. Only after the stylus starts moving is the second point recorded with the current pressure.

Proposed solution
Any time the stationary stylus tip is touching the tablet, the drawing routine polls the changing tablet pressure continuously. When the detected pressure is higher than the pressure of the last recorded point, the pressure of the last recorded point is overwritten by the newly detected (higher) pressure. This way, the pressure of the first and second points in a stroke is much more likely to be similar, the width of the start of the line will more closely match the artists intention, and the likelihood of artefacts is reduced.

**System Information** Operating system: Windows-10-10.0.18362-SP0 64 Bits Graphics card: GeForce RTX 2060/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.30 **Blender Version** Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-04-23 20:25, hash: `17fca62fff` **Short description of error** Grease pencil strokes drawn with a stylus have unwanted artefacts at their beginning. Especially noticeable at high radius settings. Related to this, the start of a stroke is often narrower than the artist's intention. ![image.png](https://archive.blender.org/developer/F10049657/image.png) **Exact steps for others to reproduce the error** * Open new document, 2d animation * Set brush strength to 1 (not using pressure) * Set brush radius to 200 (using pressure) * draw several lines with a stylus * zoom in to inspect the start of the lines. There are artefacts, a 'lumpy' line close to the beginning of the stoke (see screenshot) **Notes** When you draw with deformable physical natural media (e.g. a paint brush, felt-tip) adding pressure increases the size of the mark, even when the tip is not moving over the paper. Other drawing programs also work this way. Currently blender doesn't work this way. I looked at the source code (gpencil_paint.c). Here's what i think is going wrong with the grease pencil strokes: When the pressure difference between two close adjacent vertices is large this can cause ugly 'lumps' in the line. Currently, stylus pressure can be very different between the first and second vertex recorded in a grease pencil stroke. This is because there can be a large time difference between the recording of the two points; The first vertex stores a record of the pressure only at the moment the stylus first touches the tablet, subsequent changes of pressure before the stylus begins to move across the tablet are not recorded in the stroke. Only after the stylus starts moving is the second point recorded with the current pressure. **Proposed solution** Any time the stationary stylus tip is touching the tablet, the drawing routine polls the changing tablet pressure continuously. When the detected pressure is higher than the pressure of the last recorded point, the pressure of the last recorded point is overwritten by the newly detected (higher) pressure. This way, the pressure of the first and second points in a stroke is much more likely to be similar, the width of the start of the line will more closely match the artists intention, and the likelihood of artefacts is reduced.
Author

Added subscriber: @info-27

Added subscriber: @info-27
Member

Added subscriber: @filedescriptor

Added subscriber: @filedescriptor
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

@info-27 Are you using Wintab or Windows Ink? Could you try both of them and see if they give different results?

Mentioning #87499 here as this task could be related.

@info-27 Are you using Wintab or Windows Ink? Could you try both of them and see if they give different results? Mentioning #87499 here as this task could be related.
Author

whether using wintab or windows ink i get unwanted artefacts.
image.png
(today the artefacts seem less severe, maybe the problem is made worse when cpu is taxed with other processes)

whether using wintab or windows ink i get unwanted artefacts. ![image.png](https://archive.blender.org/developer/F10051031/image.png) (today the artefacts seem less severe, maybe the problem is made worse when cpu is taxed with other processes)

Added subscriber: @PrototypeNM1

Added subscriber: @PrototypeNM1

I think the analysis in Notes is mostly accurate; this looks more like a grease pencil issue than Wintab/WinInk.

Similar artifacts occur if you keep changing pressure without changing position mid-stroke.

I think the analysis in **Notes** is mostly accurate; this looks more like a grease pencil issue than Wintab/WinInk. Similar artifacts occur if you keep changing pressure without changing position mid-stroke.
Member

Changed status from 'Needs User Info' to: 'Confirmed'

Changed status from 'Needs User Info' to: 'Confirmed'
Member

After taking another look at the painting code, I think you guys are right. Working on a potential fix.

After taking another look at the painting code, I think you guys are right. Working on a potential fix.
Member

So there are two things happening here:

  • We do not trigger a drawing event when just the pressure changed.
  • We do not add points if they have the same position as the last point.

Now the question is, why is it done this way. I hacked together a patch that ignores the two points above (always add a point if the pressure changes).
Here is what this would look like (move the pen, stop, change pressure, move again):
image.png
As you can see, that does not look very good. Basically, when we get points that are directly on top/very close to each other, the grease pencil engine does not handle it very well. And I guess that makes sense because a lot of it has to do with the segments between the points. If those have a length of zero then you get problems (as shown in the image).

But I think we can do better. My idea would be: Instead of creating new points when the pressure changes but the position is the same, change the pressure of the current point in the buffer. Or even better, only change it if the pressure got greater. Because otherwise, you could "shrink" the point you are currently drawing on, which doesn't really make much sense painting-wise.
That should in theory solve the issue.

So there are two things happening here: - We do not trigger a drawing event when just the pressure changed. - We do not add points if they have the same position as the last point. Now the question is, why is it done this way. I hacked together a patch that ignores the two points above (always add a point if the pressure changes). Here is what this would look like (move the pen, stop, change pressure, move again): ![image.png](https://archive.blender.org/developer/F10052508/image.png) As you can see, that does not look very good. Basically, when we get points that are directly on top/very close to each other, the grease pencil engine does not handle it very well. And I guess that makes sense because a lot of it has to do with the segments between the points. If those have a length of zero then you get problems (as shown in the image). But I think we can do better. My idea would be: Instead of creating new points when the pressure changes but the position is the same, change the pressure of the current point in the buffer. Or even better, only change it if the pressure got greater. Because otherwise, you could "shrink" the point you are currently drawing on, which doesn't really make much sense painting-wise. That should in theory solve the issue.
Author

that was exactly my suggestion 🙂

that was exactly my suggestion 🙂
Member

Well... Apparently, I need glasses

Well... Apparently, I need glasses
Member

Added a patch that implements your idea @bitbutter. From my testing, it works quite well. If you can test the patch for yourself and see if it fixes the problem, that would be great.

Added a patch that implements your idea @bitbutter. From my testing, it works quite well. If you can test the patch for yourself and see if it fixes the problem, that would be great.
Philipp Oeser removed the
Interest
Grease Pencil
label 2023-02-09 15:19:28 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#87984
No description provided.