C++17 In Detail

02 June 2012

Quick example of Anisotropic Filtering in OpenGL

See my new website at cppstories.com

Anisotropic filtering can give great visual quality for rendered objects that are not parallel to the front plane of the camera. In OpenGL it is one of the easiest extension to use.
When creating a texture just write:
float an = 0.0f; 
if (is supported EXT_texture_filter_anisotropic()) 
    glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso); 

// and when creating texture: 
// .. set params... 
Note that to get maximum filtering quality use linear filtering for magnification, and linear_mipmap for minification.
Value 1.0 for anisotropic filtering basically means isotropic (normal) filtering. Higher the value better the quality. The implementation is specific to the vendor. So we cannot guarantee that value 4.0 will look the same on different GPUs.
Here is a quick comparison:

I don't know how much performance do I lose using that filtering, but in this sample the quality has the bigger priority.

linear & mipmap
linear & mipmap & anisotropic 16x

If you want to get additional C++ resources, exlusive articles, early access content, private Discord server and weekly curated news, check out my Patreon website: (see all benefits):

© 2017, Bartlomiej Filipek, Blogger platform
Disclaimer: Any opinions expressed herein are in no way representative of those of my employers. All data and information provided on this site is for informational purposes only. I try to write complete and accurate articles, but the web-site will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.