Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Anti Aliasing, Textures, Fonts and GUIs  (Read 2838 times)

0 Members and 3 Guests are viewing this topic.

Senzin

  • Newbie
  • *
  • Posts: 15
    • View Profile
Anti Aliasing, Textures, Fonts and GUIs
« on: August 03, 2012, 09:12:03 am »
I'm using the latest SFML and TGUI builds as of 8/2/2012.

I've spent the last couple hours experimenting and reading every search result for anti aliasing on the forums. And so here are my questions and concerns.

First, please look at the attached image:



Looking at the lines and tiny boxes (all drawn with rectangles), it should be obvious that I've turned anti aliasing off in the top image and on in the bottom image. I very much want anti aliasing for my geometry. However, if you look at the TGUI controls at the top left (the label, button and edit box), you'll see that they look fine with anti aliasing disabled (top) but quite ugly with it enabled (bottom). It happens to the label as well, it's just harder to see.

To make sure this wasn't a TGUI specific problem I tested this with SFGUI and got the same ugly artifacts. I also tested this with just a regular sf::Text object (before I ever got TGUI) and the same thing happened.

Here are some of the artifacts I'm seeing in the bottom image:
  • Along the top and bottom edges of the button and edit box, there are little light colored artifacts.
  • In the GUI text, especially the 'u' and 't's in "Button" and the 'E', 't', and 'B' in "Edit Box", the artifacts are kind of sticking out of the letters ever so slightly.
  • In the regular sf:Text object, the 'T' in the top is nice and pixel perfect solid, but in the bottom there is a spot in the middle of the 'T' where it's a bit fuzzy. This can be seen in other letters too.

I want the GUI objects to look how they do in the top, but I want my geometry smoothed like they are in the bottom. So what am I to do here?

[attachment deleted by admin]
« Last Edit: August 03, 2012, 09:57:14 am by Senzin »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Anti Aliasing, Textures, Fonts and GUIs
« Reply #1 on: August 03, 2012, 09:28:19 am »
There are two kinds of anti-aliasing.

1. Geometry anti-aliasing: the edges of the geometry (primitives) are smoothed; it is enabled with ContextSettings::antialiasingLevel when creating the window
2. Texture anti-aliasing: the pixels of the textures are smoothed; it is enabled with Texture::setSmooth (and forced for text rendering)

The antialising used for your lines and squares (1) should not be the same as for the labels (2). So what exactly did you do in your code?
Laurent Gomila - SFML developer

Senzin

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Anti Aliasing, Textures, Fonts and GUIs
« Reply #2 on: August 03, 2012, 09:37:58 am »
Without anti-aliasing:
tgui::Window app
    ( sf::VideoMode
        ( std::min(sf::VideoMode::getDesktopMode().width,(unsigned)600)
        , std::min(sf::VideoMode::getDesktopMode().height,(unsigned)600)
        , 32)
    , "Graph Search"
    , sf::Style::Close
    , sf::ContextSettings(0, 0, 0));

With anti-aliasing:
tgui::Window app
    ( sf::VideoMode
        ( std::min(sf::VideoMode::getDesktopMode().width,(unsigned)600)
        , std::min(sf::VideoMode::getDesktopMode().height,(unsigned)600)
        , 32)
    , "Graph Search"
    , sf::Style::Close
    , sf::ContextSettings(0, 0, 8));

To test SFGUI, I simply downloaded the binaries and launched the example programs. Then I forced anti-aliasing on and off in my Radeon Catalyst Control Panel. I'm running Windows 7 64-bit, by the way.

When I was testing just a regular sf::Text without TGUI, I used a normal sf::RenderWindow instead of a tgui::Window.
« Last Edit: August 03, 2012, 09:40:06 am by Senzin »

Senzin

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Anti Aliasing, Textures, Fonts and GUIs
« Reply #3 on: August 03, 2012, 09:54:46 am »
Okay, looks like I found the source of the problem. Here is a screenshot of the anti-aliasing settings in the Radeon control panel:



The "Filter" setting at the bottom has two settings, "Standard" and "Edge-detect". When it's set to "Edge-detect", the "Samples" to the right displays a multiple of the anti-aliasing level. E.g.: 4x to 12x and 8x to 24x. When it's set to "Standard", however, the "Samples" to the right displays the same number as the anti-aliasing level.

More importantly, when the "Filter" is set to "Standard", the artifacts in SFML and TGUI disappear.

Do you know much about this filter? Is there anything that can be done in SFML to prevent this problem from happening when users enable the "Edge-detect" feature?

[attachment deleted by admin]
« Last Edit: August 03, 2012, 09:57:02 am by Senzin »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Anti Aliasing, Textures, Fonts and GUIs
« Reply #4 on: August 03, 2012, 10:22:20 am »
I don't know what this filter does, but you can probably find more relevant information about it with Google (and maybe more users having issues with it).

I don't think that SFML can do anything to avoid the artifacts, this is just how the filter behaves.
Laurent Gomila - SFML developer

 

anything