Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Anisotropic filter

  1. #1
    Intern Newbie
    Join Date
    Dec 2011
    Posts
    46

    Anisotropic filter

    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:

    Code :
     if(gl.isExtensionAvailable("GL_EXT_texture_filter_anisotropic"))    {
                System.out.println("GL_EXT_texture_filter_anisotropic available!");
                float max[] = new float[1];
                gl.glGetFloatv(GL2.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, max, 0);
                System.out.println("max = "+max[0]);
                gl.glTexParameterf(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAX_ANISOTROPY_EXT, 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

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,714

    Re: Anisotropic filter

    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.

  3. #3
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    302

    Re: Anisotropic filter

    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.

  4. #4
    Intern Newbie
    Join Date
    Dec 2011
    Posts
    46

    Re: Anisotropic filter

    Ok, thanks guys for clarification and suggests

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

    Code :
    public void loadFloorTexture(GL2 gl) throws IOException *{
     * * * *//gl.glEnable(GL2.GL_TEXTURE_2D);
     * * * *
     * * * *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(), 
     * * * * * * * * * *GL2.GL_RGB, GL2.GL_UNSIGNED_BYTE, ?); * * * * * *
     * * * *}
     * * * *catch (IOException iOException) {
     * * * * * *System.exit(1);
     * * * *}

    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?

  5. #5
    Intern Newbie
    Join Date
    Dec 2011
    Posts
    46

    Re: Anisotropic filter


  6. #6
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    302

    Re: Anisotropic filter

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •