Pen strokes in screen resolution not in tablet resolution?

Hi every one,

On my computer it seems that Blender (2.93 - Linux) records my pen strokes (on a drawing tablet) in screen resolution: if I draw a diagonal line (with Grease Pencil, active smooth/post-processing off), then zoom in, I can see the discrete vertical and horizontal “jumps” corresponding to my screen resolution (1). It’s frustrating since my tablet resolution is much higher than my screen’s one.

So I tried to find out if it was a known issue, a misconfiguration or maybe a misunderstanding… But I haven’t found anything yet. Or perhaps is it something with my computer/tablet, however I haven’t experienced such issues with other programs I use.

Then I digged a bit into the code with the silly idea that maybe Blender was using integer screen space cursor position to record pen strokes. So far, I found that GHOST_SystemX11 (2) has references to xinput axis_data, but only for pressure and tilt. It doesn’t seem to use axis_data[0] and axis_data[1] which would contain the pen position in tablet resolution (if I’m not mistaken).

So my (first) question is: does anyone know if Blender use x/y integers in screen resolution to record pen strokes (at least on Linux/X)? Thanks a lot.

(1) The size of the discrete jumps also depends on the Manhattan/Euclidean preference - but with 0px/0px for both, the size of the “jump” is 1px in screen space.
(2) blender/GHOST_SystemX11.cpp at ae085e301c2aac0d6956609bfe93a90a19f0e235 · blender/blender · GitHub

1 Like

Mouse coordinates are integers. Changing them to floats is doable but requires changes in many parts of the code.

The main types to change would be wmEvent and GHOST_TEventCursorData, and more or less all the code that accesses the mouse coordinates of those types.

Ok, thanks for your answer.

So as I understand it, it’s a known limitation but not one causing much trouble to other people (I guess I should upgrade to a hiDPI screen :slight_smile: ).

I don’t know if I have the capacity to code it - I may give it a try. Anyway I will also see if I can get it mentioned somewhere in the documentation or/and in a feature request.

I’ve started a branch here:

Right now I have something working for X11 and grease pencil drawing mode.

Here is attached a screenshot of old vs new stroke with all smoothing/post-processing disabled. On my modest screen the difference is dramatic - but I believe it could as well improve drawing on screens with higher resolutions:

8 Likes

Hey @aperitero, are you intending to push these changes to completion? I could hook Windows pen input into this fairly easily, though I’d recommend some changes.

Hi Nick,

Thanks for your interest.

Yes I’d like to put these changes to completion (for Linux/X11). It’s my first time in Blender dev and in C, so there’s a lot to improve (and I’m very slow). I would be glad to hear/see your recommended changes.

In the things I want to do:

  • make it work without the platform specific code (so it doesn’t break anything for platforms where it’s not implemented yet).
  • make annotation (and other tools?) use the high resolution data from the tablet.

At a high level.

  • Transforming from tablet to subpixel (hi res) space should happen in Ghost instead of being deferred to the Window Manager.
  • I’d add subpixel coordinates to the Cursor instead of Tablet Data types in Ghost and WM, and assign them with pixel coordinates when high res input isn’t available. This allows operators to assume the “subpixel” coordinates are always available and not have to have special handling for it.

It would simplify commenting as you update things if you submit a revision to developer.blender.org. Tag @nicholas_rishel if you do.

1 Like

Thanks a lot for your feedback. I’ll try my best and submit a revision.

Ok here it is:
https://developer.blender.org/D11959

I tried to take into accounts your comments. See you there for further discussion.

1 Like