02 June 2012

Quick example of Anisotropic Filtering in OpenGL

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

Interested in new blog posts and occasional updates? Please sign up for my free newsletter.

© 2017, Bartlomiej Filipek, Blogger platform
Any opinions expressed herein are in no way representative of those of my employers.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.