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

Author Topic: Enable anisotropic filtering  (Read 10168 times)

0 Members and 2 Guests are viewing this topic.

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Enable anisotropic filtering
« on: January 29, 2018, 05:01:03 am »
When I use generateMipmap() with default bilinear filtering the results are very poor.  Is it possible to enable anisotropic filtering from SFML? I would like to avoid forcing it through the driver.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Enable anisotropic filtering
« Reply #1 on: January 29, 2018, 11:23:06 pm »
Anisotropic filtering doesn't make much sense with 2D.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #2 on: January 29, 2018, 11:31:06 pm »
Allow me to disagree. With autogenerated mipmaps zoomed out images look very blurry with default bilinear filtering. When I force aniso through the driver the quality difference is very noticeable. I can sharpen it a little by changing the bias to negative, but then the aliasing and pixel crawling can be seen. With aniso it’s perfectly sharp when scaling and no artiffacts are visible
« Last Edit: January 29, 2018, 11:34:53 pm by oomek »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Enable anisotropic filtering
« Reply #3 on: January 29, 2018, 11:49:55 pm »
Wouldn't this just be using mipmaps, which you can do manually by switching the texture rectangle? If so, the question might have been 'can we enable mipmaps?' or something.
Anisotropic filtering shouldn't really help unless the angle of the surface is away from the camera and that can only happen in 3D.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Enable anisotropic filtering
« Reply #4 on: January 29, 2018, 11:57:04 pm »
the question might have been 'can we enable mipmaps?' or something.
You may have missed, that SFML does support mipmaps.

Since you're using OpenGL directly anyways, isn't there an option to set the wanted filtering? (note: I'm an OpenGL noob).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #5 on: January 30, 2018, 12:17:21 am »
Anisotropic filtering takes way more samples per pixel than bilinear and it really helps with sharpening mipmaps when you display the texture at for example 25% of its size. I’ve tested it and see a huge difference in sharpness, so the argument that anisotropic filtering is only for textures deformed in 3D space has no grounds.
« Last Edit: January 30, 2018, 12:18:56 am by oomek »

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #6 on: January 30, 2018, 12:21:10 am »
I can force aniso in the gpu control panel, but I wish it could be configurable within the app.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Enable anisotropic filtering
« Reply #7 on: January 30, 2018, 01:55:01 pm »
There seems to be some confusion what you are trying to request. If you already have some test code, please post it so everybody can check it out. Maybe some screenshots would help too.

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #8 on: January 30, 2018, 01:57:00 pm »
Sure thing, in the evening I’ll post a video

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #9 on: January 30, 2018, 06:46:43 pm »
Ok, here is an example image and the explanation of what is happening.



When I scale the square image with mipmaps generated to a smaller size with different x/y factors the image is blurred in both axes so you lose a lot of detail. The same happens when I scale an image which is a rectangular shape to a square size.

The conclusion is that anisotropic filtering would really help preserving the scaling detail even in 2D
« Last Edit: January 30, 2018, 07:06:40 pm by oomek »

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #10 on: January 30, 2018, 07:01:33 pm »
Setting anisotropic filtering for the whole app that would affect the result of the setSmooth() function would be of a tremendous help.

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #11 on: January 30, 2018, 08:35:01 pm »
Here is a video showing the filtering quality in motion.



On the left - anisotropic x16 forced in the GPU driver’s settings
On the right - default bilinear SFML filtering
« Last Edit: January 30, 2018, 08:48:33 pm by oomek »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Enable anisotropic filtering
« Reply #12 on: February 03, 2018, 04:25:49 pm »
Is this something that can be achieved with a shader?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

oomek

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Enable anisotropic filtering
« Reply #13 on: February 03, 2018, 04:31:13 pm »
I’m prety sue it can be. But firstly it will be slower and secondly, what is the point of breaking through an open door :)
Much easier would be to set one flag than rewriting all the shaders.
« Last Edit: February 03, 2018, 04:33:28 pm by oomek »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Enable anisotropic filtering
« Reply #14 on: February 03, 2018, 05:13:41 pm »
I just mean that it's at least possible before SFML modifies to include the filtering option, if it does. :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*