PDA

View Full Version : Irritating gotcha with textures



jheriko
07-14-2009, 05:13 AM
The default texture minification filter is GL_NEAREST_MIPMAP_LINEAR, which is all well and good if you are using mipmaps, but useless if you aren't and your texture is being drawn small enough to need the minification filter.

I don't ever expect these incompatible defaults to be fixed... it would be a breaking change.

I first encountered this a few years ago when I started out with OpenGL and it took me a while to work out. I also struggled to debug this problem last night... since searching the internet and these forums proved practically useless I decided to post it up here.

Changing the minification filter with glTexParameteri to GL_LINEAR fixes the "problem".

Why GL_NEAREST is not the default is beyond me though...

ZbuffeR
07-14-2009, 07:42 AM
Surprising you did not see it, it is in the faq.
http://www.opengl.org/resources/faq/technical/texture.htm#text0020

And each time someone has problems with texturing, I ask to check mipmaps and use GL_LINEAR as min function if they don't understand mipmaps :)

Mipmaps are very important since a lot of time to allow both better performance (thanks to tex mem access coherence) and nicer look. No wonder it is the default.
Even software mode Quake 1 used mipmaps, without bilinear filtering.

jheriko
07-14-2009, 09:52 AM
No wonder it is the default.

Right... as opposed to GL_NEAREST, which just /always/ renders some texture (even if its ugly).

Its a bad default.