Texture blurring

Started by
6 comments, last by lc_overlord 19 years, 6 months ago
hi. I am having some texture blurring as illustrated in this picture: http://img86.exs.cx/img86/7831/floorblur.jpg Is this due to mipmapping? I expect it to blur when I get the camera far away from the plane, but in the image I provide, I would want the floor image to be crisp. Could anyone give me a quick way to solve this problem? Do I need to create my own mipmaps, or can I alter something within my code to sharpen this up?
Advertisement
Looks like mipmapping to me. To get rid of that sudden line use GL_LINEAR_MIPMAP_LINEAR (assuming opengl since NeHe forum) in your texture environment, it will turn on the blending between mipmaps.
Yes, that is one bad side-effect of mipmapping. It can be greatly reduced by using anisotropic filtering.

copy&paste form my code:
// setup anisotrophycyint maxSupportedAnisotrophy = 1;glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxSupportedAnisotrophy );glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Math::GetMin<int>( maxSupportedAnisotrophy, maxUserSelectedAnisotrophy ) );
You should never let your fears become the boundaries of your dreams.
I get the following cmpile errors when I copy and paste that code into my init code, Darkwing:

D:\Someprogramming stuff\Octree4\Init.cpp(596) : error C2065: 'GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT' : undeclared identifier
D:\Someprogramming stuff\Octree4\Init.cpp(597) : error C2065: 'GL_TEXTURE_MAX_ANISOTROPY_EXT' : undeclared identifier
D:\Someprogramming stuff\Octree4\Init.cpp(597) : error C2653: 'Math' : is not a class or namespace name
D:\Someprogramming stuff\Octree4\Init.cpp(597) : error C2065: 'GetMin' : undeclared identifier
D:\Someprogramming stuff\Octree4\Init.cpp(597) : error C2062: type 'int' unexpected


Do I need to include something in the code to use anisotropic filtering?


Also, I use:
	// Build Mipmaps (builds different versions of the picture for distances - looks better)	gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->sizeX, 					  pImage->sizeY, textureType, GL_UNSIGNED_BYTE, pImage->data);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);


when I load my textures, so I am using Linear already.
Just include glext.h.
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
Using the suggestions is actually having no effect at all.

I'll leave this problem for now and come back to it a little later in my development, it isn't really getting in the way, but will need fixing at some stage.
You need to use LINEAR_MIPMAP_LINEAR for your min_filter, too.
allso GL_TEXTURE_MAG_FILTER shoud be GL_LINEAR and not GL_LINEAR_MIPMAP_LINEAR since mipmaps only work when minifying.

one more thing, choosing the max possible ansiotropic filtering is not good because it can lead to redering artifacts and allso slow down your system.
an ansiotropic level of 2-4 is good depending on your scene and texture requirements.

an ansiotropic level of 1 does practicly nothing.
an ansiotropic level of 8 can start to show the same artifacts as GL_NEAREST(a bit depending on your texture and scene).

This topic is closed to new replies.

Advertisement