Bug 300138

Summary: No Anti-aliasing for Thin Lines with OpenGL Option Enabled.
Product: [Applications] krita Reporter: Ico_dY <enrico_guarnieri>
Component: GeneralAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: ahiemstra, halla
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: left qpainter, right opengl
Thin Lines Test with/without OpenGL Enabled
Thin Lines Test for OpenGL

Description Ico_dY 2012-05-16 13:46:53 UTC
With the opengl option disabled thin lines are smooth and neat at any zoom level, but if I rotate the viewport everything is terribly aliased.
With the opengl option enabled thin lines are aliased in any situation instead. I experienced the same problem with the proprietary Nvidia driver and with the free nouveau driver, so I tried to force the anti-aliasing by the Nvidia x server setting panel but it doesn't work. I tested it with a Geforce 9500 GT. 

For instance under Mypaint I don't experience such problems with/without the rotated viewport at any zoom level and Mypaint takes advantage of display hardware acceleration through the Cairo library for zooming and rotating, so my graphic card should be ok...  :) 

It's a big problem for inking and creating line-art, because the user is forced to switch to the "software" mode to see the result of his work and he can't rotate the viewport without the aliasing curse.  ;D 

Reproducible: Always

Actual Results:  
 

Expected Results:
Comment 1 Halla Rempt 2012-05-16 13:55:23 UTC
Hm, I don't see any aliasing when using opengl, but a thin straight line at 100% zoom rotated two clicks to the right in the qpainter canvas does show aliasing. I'm using an intel graphics card here (I think...)
Comment 2 Halla Rempt 2012-05-16 13:56:05 UTC
Created attachment 71139 [details]
left qpainter, right opengl
Comment 3 Halla Rempt 2012-05-16 14:12:13 UTC
Git commit 24ce177b7225eb83378b65821b10fe32d45a0a25 by Boudewijn Rempt.
Committed on 16/05/2012 at 16:09.
Pushed by rempt into branch 'master'.

Antialias when painting a rotated canvas

I'm not sure that this doesn't close the bug yet -- opengl canvas anti-
aliasing is graphics card dependent. But I'll ask around for some tips
since I'm not an opengl expert (at all).

M  +2    -0    krita/ui/canvas/kis_qpainter_canvas.cpp

http://commits.kde.org/calligra/24ce177b7225eb83378b65821b10fe32d45a0a25
Comment 4 Ico_dY 2012-05-16 14:37:45 UTC
(In reply to comment #1)
> Hm, I don't see any aliasing when using opengl, but a thin straight line at
> 100% zoom rotated two clicks to the right in the qpainter canvas does show
> aliasing. I'm using an intel graphics card here (I think...)

I've an Intel graphic chipset integrated in my motherboard, I could try it to see the difference...
Comment 5 Halla Rempt 2012-05-16 14:39:49 UTC
I'd be really interested in the results!
Comment 6 Ico_dY 2012-05-16 16:13:49 UTC
Created attachment 71144 [details]
Thin Lines Test with/without OpenGL Enabled
Comment 7 Ico_dY 2012-05-16 16:19:19 UTC
Same problem with the Intel card... I've just taken a screenshot to show the difference... Please, look the attachment... ^^
Comment 8 Halla Rempt 2012-05-16 16:24:53 UTC
Weird...

Could you attach the document as well?
Comment 9 Ico_dY 2012-05-16 17:00:10 UTC
Created attachment 71147 [details]
Thin Lines Test for OpenGL

Please, look at it with a zoom factor <= 33% and with OpenGL enabled and disabled.
Comment 10 Ico_dY 2012-05-16 17:06:17 UTC
I've just attached a new one, because I didn't save the old one. ^^(In reply to comment #8)
> Weird...
> 
> Could you attach the document as well?

I've just attached a new one, because I didn't save the old one. ^^
Comment 11 Halla Rempt 2012-05-16 20:31:06 UTC
Er... weird: ahiemstra just committed a possible fix and tagged the commit, but nothing is attached here.
Comment 12 Halla Rempt 2012-05-16 20:32:07 UTC
Git commit 988dcefeaf90809356db5932d8d6407802259c8a by Arjen Hiemstra.
Committed on 16/05/2012 at 19:31.
Pushed by ahiemstra into branch 'master'.

Set the right filtering modes for rendered textures when using OpenGL.

Now use nearest for near filtering and trilinear filtering for fa
filtering. This prevents aliassing issues at low zoom levels and still
gives the right behaviour at high zoom levels.

BUG: 300138
Comment 13 Ico_dY 2012-05-16 21:51:16 UTC
Yes, the commit works! ^^
Although a little problem arises...
When I turn on the  OpenGL feature everything painted on the canvas disappears, so I've to hide and unhide the levels to force the refreshing. After that Krita works regularly.
Comment 14 Halla Rempt 2012-05-17 13:05:03 UTC
That sounds strange -- I wonder whether that wasn't always present. The opengl commit (988dcefeaf90809356db5932d8d6407802259c8a) cannot have anything to do with that, I'd say.
Comment 15 Arjen Hiemstra 2012-05-17 22:19:35 UTC
Hmm, from the looks of it, it seems it is actually more a bug in the underlying system that is exposed by my changes. For some reason, the texture data is not updated when OpenGL is enabled, so it does not generate mipmaps properly which are needed for trilinear filtering. I will take a look and see if I can find out what's causing it.
Comment 16 Arjen Hiemstra 2012-05-17 22:35:29 UTC
(Where's an edit button when you need one...)

Just realised the actual problem: Textures are generated, data is uploaded and only after that is set that it also needs to generate mipmaps - which it does not do directly since none of the data changed... Well I already thought most of the commands in that bit of code don't belong there, but this just confirms it.
Comment 17 Arjen Hiemstra 2012-05-17 23:34:38 UTC
Git commit a9a08a81059b2c71b8cce2a7356e5482a72b4cae by Arjen Hiemstra.
Committed on 18/05/2012 at 01:25.
Pushed by ahiemstra into branch 'master'.

Set texture parameters before uploading any texture data.

This avoids needlessly resetting the texture parameters and also makes
sure we always generate mipmaps, since those are required by the new
trilinear filtering.

M  +0    -5    krita/ui/opengl/kis_opengl_canvas2.cpp
M  +4    -0    krita/ui/opengl/kis_texture_tile.cpp

http://commits.kde.org/calligra/a9a08a81059b2c71b8cce2a7356e5482a72b4cae
Comment 18 Ico_dY 2012-05-18 07:31:33 UTC
I've just tested it... 
The commit works perfectly. Thanks. :)
Comment 19 Halla Rempt 2012-05-18 08:14:34 UTC
Great! Closing the bug then :-)
Comment 20 Halla Rempt 2012-05-20 07:56:03 UTC
Okay, we're not here yet... On some hardware, the new opengl code breaks the canvas, and the qpainter smoothing should probably be off while panning, moving, rotating etc., since it's slowing down everything. See also https://bugs.kde.org/show_bug.cgi?id=300339.
Comment 21 Halla Rempt 2012-12-28 14:13:58 UTC
Only 300339 is still relevant now.