Isometric grid & Open GL + Open GL and Antialisating

Hi

I’m looking into grids management code.

And I see the isometric grid option is enabled only if Open GL is active.

@scottyp do you remember why?

On my side, if I allow to use the isometric grid when Open GL is not active, everything works fine.

Also for isometric grids, I’ve tried to activate antialiasing:

With Open GL active, it doesn’t work

Without Open GL active, it works (and result is visually better)

For what I found, it seems items rendered through a KisCanvasDecoration::drawDecoration() and for which antialiasing is active, the antialiasing on QPainter is not applied when OpenGL acceleration is active… (so grids here, but I also discover assistant are rendered really better without open gl…)

Is there a reason for that?
Because looking results of helpers on canvas with antialiasing active it’s visually something really more comfortable :heart_eyes:

Grum999

2 Likes

Looks like that GLContext surface format super sampling is set to 0 by default
(this may have side effects to rendering speed, svg layers, zooming, …).

from PyQt5.QtGui import QSurfaceFormat
    
# enable super sampling, call this before opening view to document
surface_format = QSurfaceFormat.defaultFormat()
surface_format.setSamples(16)
QSurfaceFormat.setDefaultFormat(surface_format)

/AkiR

1 Like

I found something in Qt documentation about QSurfaceFormat::samples(); multisampling is disabled by default.

Here an example of different render (red: isometric grid, grey: a spline assistant)

Render mode Result 800% Zoom
OpenGL, no multisampling
OpenGL, with fix (multisampling=2)
No OpenGL

It’s not as nice as antialiasing without OpenGL, but better than the default settings.

Yes, I found it :slight_smile:

Concerning performances, I don’t know but I suppose a low value shouldn’t have a huge impact?
I tested 2, 10, 100 on my side, results are pretty the same (visually and I don’t feel any perf difference)

What I don’t know is if this settings will have an impact on something else than rendering helpers (example: impact on brushes or canvas, or anything else…)

For me it could be a good thing to have it enabled but I’m not an expert about all of this…

Grum999

Lol I didn’t saw there was a bug reference for this case
https://bugs.kde.org/show_bug.cgi?id=392526

But I don’t have access to the video then I can’t tell what happened here
On my side it seems to work properly without OpenGL

The bug was reported and ‘fixed’ 6 years ago (in 2018) for Krita 4
What was Qt version?

Is still relevant to block this if OpenGL is not active? :thinking:

Grum999

2 Likes

The classic smoothing method, multisampling (MSAA), is rather expensive, although I doubt the amount of geometry to draw the grid would be a challenge for anything but the lowest end graphics cards.

The x2 rate typically doesn’t look that great, probably the best course of action would be to expose it as a settings option. Then people could enable it based on the strength of their hardware.

Tried some values from 2 to 2000, then I don’t see visual differences…

I’m not sure how exactly Qt works, but one thing I’m pretty sure: performances can’t be worst than when graphic acceleration is disabled :sweat_smile:

Also, not sure how Qt does the stuff: why when not using OpenGL the antialiasing applied to draw a line on a QPainter is smooth and visually pretty good and not when OpenGL is activated? :man_shrugging:

Anyway, I won’t touch this setting and won’t add a new option in Krita.
Adding this to Krita’s settings is more on dev team side I think

Grum999

2 Likes

Thanks for the reference. I don’t even remember doing these changes. In the time since that was commited, there could have bee things that changed with other parts of the code base…as well as changes with Qt5 updates (and soon to be Qt6) that could affect this.

We would need a developer to look into this to see what improvements could be made. A new bugzilla ticket should probably be filed instead of reopening one from 2018 that was closed. Usually opening old tickets like that causes more confusion than being helpful.

1 Like