SFML community forums

Help => Graphics => Topic started by: mkalex777 on November 15, 2015, 01:25:53 am

Title: Is there any way to eliminate aliasing?
Post by: mkalex777 on November 15, 2015, 01:25:53 am
I'm already using AA=16, so there is even fonts looks a little blurry.
But when I drawing lines with RenderWindow.Draw (with PrimitiveType.Lines) and change View zoom and position, the result is still aliased. It looks very ugly and each line jumps from pixel to pixel when view position or zoom is changed.
So, how can I draw antialiased lines?
Title: Re: Is there any way to eliminate aliasing?
Post by: Nexus on November 15, 2015, 04:01:18 pm
There are various workarounds, why don't you search a bit?
http://stackoverflow.com/questions/1813035/opengl-es-iphone-drawing-anti-aliased-lines
Title: Re: Is there any way to eliminate aliasing?
Post by: mkalex777 on November 15, 2015, 09:42:06 pm
All those solutions requires direct access to opengl functions. I'm using sfml.net and don't want to inject opengl code into my code. And all those solutions is a bit complicated. I just need to render simple line. So, why I need to implement those shaders, triangulation and complicated render code?
Title: Re: Is there any way to eliminate aliasing?
Post by: Ztormi on November 16, 2015, 11:15:52 am
I just need to render simple line. So, why I need to implement those shaders, triangulation and complicated render code?

Yes, that triangulation approach is definitely neat but may be an overkill most of the times.
Other than that, I'm not really sure what are you expecting. Shaders are integral part of graphics programming and SFML too. There are so many ways of doing antialiasing it would be kinda pointless to include them in SFML in my opinion considering how many shader resources there are online.
Title: Re: Is there any way to eliminate aliasing?
Post by: Laurent on November 16, 2015, 11:29:30 am
I'm curious, can you show the result that you get with native 16x AA?
Title: Re: Is there any way to eliminate aliasing?
Post by: mkalex777 on November 16, 2015, 09:40:25 pm
I'm curious, can you show the result that you get with native 16x AA?

yes:
(http://savepic.su/6530426.png)

I magnified it for 4x (with no interpolation of course).
As you can see, there is difference between lines, but actually all they rendered with one call to the RenderWindow.Draw function with the same color. In action it looks much more ugly, because all these artifacts jumping from one line to another and it looks terribly, especially with black background.

PS: just tried to round vertex coordinates to integer and it definitely looks much better, but with some  specific zoom factors, aliasing still exists. I see moire effect with moving view position and zoom.

here is screenshot with integer vertex coordinates (zoom and position is different with previous screenshot, because it's changed everytime)
(http://savepic.su/6506879.png)
Title: Re: Is there any way to eliminate aliasing?
Post by: mkalex777 on December 02, 2015, 06:48:11 am
It seems that AA is a problem here. Because AA=16 leads to moire effect for dynamic objects.
I can eliminate it by decreasing AA level, but it leads to aliasing.
So it seems that there is no way to render lines with no moire and aliasing artefacts... :(