View Full Version : Anisotropic filter

01-31-2012, 08:23 AM
Hi all,

I am using a png image of size 6400x6400

I dont need any mip since my scene is going to be quite simple to render...

I just have some problem with aliasing within the texture. Basically it looks like there is no filter, although I am trying to apply it:


You can notice the lines (especially the horizzontal and vertical ones)

Here my code:

if(gl.isExtensionAvailable("GL_EXT_texture_filter_anisotropic")) {
System.out.println("GL_EXT_texture_filter_anisotropic available!");
float max[] = new float[1];
System.out.println("max = "+max[0]);
else {
System.out.println("GL_EXT_texture_filter_anisotropic NOT available!");

Where am I wrong?

Ps: take in account my max allowed value for the anisotropic filter is 16.0

Alfonse Reinheart
01-31-2012, 09:44 AM
Anisotropic filtering is not magic. It's not a way of saying, "make this look good". It's a specific filtering technique designed to solve a specific filtering problem.

A problem that your particular rendering case does not have. You are scaling the image uniformly. Isotropicly. There is no anisotropy, so there is no anisotropic filtering.

Furthermore, an implementation is allowed to completely ignore your anisotropic filtering settings if you have no mipmaps. This is because aniso works best with mipmaps, and will not work nearly as well or efficiently without them.

So, you should get some mipmaps, use GL_LINEAR_MIPMAP_LINEAR min filtering, and then you'll get a better result.

02-01-2012, 02:48 AM
As Alfonse said, you scale your image isotropicly, so unless your window will be 6400x6400 or _larger_ you need mipmaps to get the best rendering/filtering results.

02-02-2012, 01:02 AM
Ok, thanks guys for clarification and suggests

Therefore I am now trying to load a texture from a file and then creating automatically mipmaps

public void loadFloorTexture(GL2 gl) throws IOException {

check3dFloorFile = new File(check3dFloorPath);

check3dFloorTexture = TextureIO.newTexture(check3dFloorFile, false);

check3dFloorTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
check3dFloorTexture.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);

try {
InputStream inputStream = getClass().getResourceAsStream(""
+ "/graphics/EMM-Check_3d_Floor.png");

TextureData textureData = TextureIO.newTextureData(glProfile,
inputStream, false, "png");
check3dFloorTexture = TextureIO.newTexture(textureData);

glu.gluBuild2DMipmaps(GL2.GL_TEXTURE_2D, GL2.GL_RGB8,
check3dFloorTexture.getWidth(), check3dFloorTexture.getHeight(),
catch (IOException iOException) {

The problem is that the gluBuild2DMipmaps requires as last parameter a ByteBuffer object... and I have instead only a texture object...

How can I do?

02-02-2012, 01:09 AM
I guess I found it

http://jogamp.org/deployment/jogamp-next.../TextureIO.html (http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/texture/TextureIO.html)

02-02-2012, 01:14 AM
For MipMap generation you can also use glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
Or on GL 3: glGenerateMipmap( GL_TEXTURE_2D );

I don't use the glu stuff any more, so i can't help with that, sorry.

The min filter should be GL_LINEAR_MIPMAP_LINEAR for trilinear filtering, with just GL_LINEAR the MipMaps woun't get used.