🔒 Locked
Texture blured
Advertisement
Original Post
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);
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);
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.
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.
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).
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).
Quote:Distance field?
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).
OP:
mipmapping
anisotrpic filtering
As you can see, it was invented for your problem, and is built upon mipmapping.
Quote:
Original post by szecs Quote:Distance field?
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).
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.
Quote: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.
Original post by Lord_Evil Quote:
Original post by szecs Quote:Distance field?
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).
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement

