Sign in to follow this  
leggyguy

Texture blurring

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Yes, that is one bad side-effect of mipmapping. It can be greatly reduced by using anisotropic filtering.

copy&paste form my code:

// setup anisotrophycy
int maxSupportedAnisotrophy = 1;
glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxSupportedAnisotrophy );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, Math::GetMin<int>( maxSupportedAnisotrophy, maxUserSelectedAnisotrophy ) );

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this