Skip to main content
gamedev.net
🔒 Locked

Texture blured

Started by who_knows Jun 7, 2010 at 6:50 AM 14 replies 2.1k views
Original Post
who_knows
who_knows
Hi,
I have some problems with my textures.
When I go close to the ground my textures get blured, it's realy annoying.





I'm working with Ogre3D, and I'm applying my textures with glsl shaders.
who_knows
who_knows
I already have set my anisotropic filter to 4, 8, or 16 but it doesn't change anything.
who_knows
who_knows
This is my shader :
uniform sampler2D maTexture, maTextureDetail, lignes, stripes, vertStripes, contour; //Les textures recues du Velodrome.material

varying float angleX, angleY, angleZ; //Les angles servant à l'affichage dynamique des bandes

void main(void)
{
float niveauLignesHori = 1., niveauLignesVert = 1., testCouleur = .9;

//Chargement de toutes les textures
vec4 herbe = texture2D(maTexture, gl_TexCoord[0].st * 40.), //x40 pour que la texture soit plus nette
herbeDetail = texture2D(maTextureDetail, gl_TexCoord[0].st * 40.), //x40 pour que le texture detail soit en accord avec l'herbe
ligneBlanche = texture2D(lignes, gl_TexCoord[0].st),
contourMasque = texture2D(contour, gl_TexCoord[0].st),
bandesVert = texture2D(vertStripes, gl_TexCoord[0].st * 19.), //x18 pour adapté le nombre de bandes au terrain
bandesHori = texture2D(stripes, gl_TexCoord[0].st * 24.), //x24 idem
rendu = (ligneBlanche + herbe) * herbeDetail; //création du rendu basique (sans les bandes)

//Création des bandes
if(contourMasque.r <= testCouleur) //On vérifie que l'on soit bien a l'interieur des lignes blanches
{
if(bandesVert.b >= testCouleur)
{
if(angleX <= 0.)
{
niveauLignesVert -= (angleX / 17.) - (0. - angleY) / 40.;
}
}
else
{
if(angleX > 0.)
{
niveauLignesVert -= (angleX / 17.) + (0. - angleY) / 40.;
}
}

if(bandesHori.r >= testCouleur)
{
if(angleZ <= 0.)
{
niveauLignesHori -= (angleZ / 14.) - (0. - angleY) / 35.;
}
}
else
{
if(angleZ > 0.)
{
niveauLignesHori -= (angleZ / 14.) + (0. - angleY) / 35.;
}
}

rendu /= niveauLignesHori * niveauLignesVert;
}

gl_FragColor = rendu; //Rendu final du pixel
}


And this is my ogre code :

Ogre::MaterialManager::getSingletonPtr()->setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
Ogre::MaterialManager::getSingletonPtr()->setDefaultAnisotropy(8);

Rene Z
Rene Z
I've never worked with ogre myself, so I'm just guessing now.

Please try to set the default filtering mode as early as possible, before the textures are loaded. It's likely this default filter mode only affects textures loaded after modifying the default values.

Also check if your development machine supports anisotropic filtering at all.

EDIT:
Oh and by the way, your shader has noting to do with anisotropic filtering. It's handled by OpenGL using the settings of the texture unit your samplers are bound to.
who_knows
who_knows
The anisotropic filtering is set at the very begining of my program.
It is activated, it works. If i desactivate it, my texture is still blurred but there is a lot of bog pixels instead of the "soft blur" i have.
who_knows
who_knows
From above it look good ! even if i'm quite far.
And i don't know how i built my mipmaps... (i dont exactly know what it is)
Lord_Evil
Lord_Evil
Which blur does annoy you: the blurred line in the far part of the first image (outside the circle) or the overall blur (i.e. that the circle is blurred, too)?

The first can be solved with anisotropic filtering whereas the latter either needs a higher resolution texture, a non-texture approach (use geometry) or an approach similar to what valve did for their fonts (I don't remember the name, but I might be able to look it up at home, however they used some improved alpha-testing to get rid of blurry or blocky edges when the texture is magnified).
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
szecs
szecs
Quote:
Original post by Lord_Evil
Which blur does annoy you: the blurred line in the far part of the first image (outside the circle) or the overall blur (i.e. that the circle is blurred, too)?

The first can be solved with anisotropic filtering whereas the latter either needs a higher resolution texture, a non-texture approach (use geometry) or an approach similar to what valve did for their fonts (I don't remember the name, but I might be able to look it up at home, however they used some improved alpha-testing to get rid of blurry or blocky edges when the texture is magnified).
Distance field?

OP:
mipmapping
anisotrpic filtering
As you can see, it was invented for your problem, and is built upon mipmapping.
Rene Z
Rene Z
Maybe you override the anisotropic filter settings in the ATI control panel?
Lord_Evil
Lord_Evil
Quote:
Original post by szecs
Quote:
Original post by Lord_Evil
Which blur does annoy you: the blurred line in the far part of the first image (outside the circle) or the overall blur (i.e. that the circle is blurred, too)?

The first can be solved with anisotropic filtering whereas the latter either needs a higher resolution texture, a non-texture approach (use geometry) or an approach similar to what valve did for their fonts (I don't remember the name, but I might be able to look it up at home, however they used some improved alpha-testing to get rid of blurry or blocky edges when the texture is magnified).
Distance field?

Yes that's the correct name, thanks. Here's a thread with a link to the original valve paper in the first post in case you need more information.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
szecs
szecs
Quote:
Original post by Lord_Evil
Quote:
Original post by szecs
Quote:
Original post by Lord_Evil
Which blur does annoy you: the blurred line in the far part of the first image (outside the circle) or the overall blur (i.e. that the circle is blurred, too)?

The first can be solved with anisotropic filtering whereas the latter either needs a higher resolution texture, a non-texture approach (use geometry) or an approach similar to what valve did for their fonts (I don't remember the name, but I might be able to look it up at home, however they used some improved alpha-testing to get rid of blurry or blocky edges when the texture is magnified).
Distance field?

Yes that's the correct name, thanks. Here's a thread with a link to the original valve paper in the first post in case you need more information.
The problem is: I'm not sure if distance fields will solve the OP's problem. He has issues with filtering, so with distance fields he will get sharp edges, but the line will get (I think) wider and wider at each MIP (RIP?) level. Maybe turning off trillinear filtering would solve this? I don't think so, the texture will always be shown at a low angle, since it is a football field.
mrmage
mrmage
wouldn't adding more geometry to the field help?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.