LWJGL Forum

Programming => OpenGL => Topic started by: sergicion on August 15, 2014, 18:59:49

Title: Texture filtering issue
Post by: sergicion on August 15, 2014, 18:59:49
Hello!
I'm using linear filtering on my textures, but I've got this problem:

(http://i61.tinypic.com/ddjfhj.jpg)
On the left I'm using GL_NEAREST and on the right GL_LINEAR, but some color lines appear on the edges, and I don't like it.
How can I fix that?

This is my code when I load the texture:

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, textureBuffer);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);


Thank you :)

PS: maybe there are some grammar mistakes because I'm Spanish, sorry for that :(
Title: Re: Texture filtering issue
Post by: Kai on November 04, 2014, 16:24:10
This is just a guess, but:

Is your red texture a texture atlas? That is to say: Does it include also other parts except for the red rectangle and only the parts of the texture with that red rectangle is mapped onto your box?

If so, then you have the problem which is described in http://stackoverflow.com/questions/19611745/opengl-black-lines-in-between-tiles (http://stackoverflow.com/questions/19611745/opengl-black-lines-in-between-tiles).

Basically, when linear 2x2 filtering is done at the edge of your box, it also takes into account the texel values which lie outside of the texture parameter range for your box. And that seems to have some "whiteish" colour.