Texture Aliasing problem while rendering large chunks: OpenGL

Viewed 124

Texture rendering is good without any texture error when the world size is small, but when it increased to some extend then it shows texture error. tried several texture mapping techniques but none helped(or may be I am doing it wrong) The issue is similar with shadow acne but it not shadow acne(That i am sure), as I haven't implemented any shadow mapping yet.

Don't know how to solve this one, any help would be appreciated(or what i am doing wrong).

(Attaching the shader code for reference)

out vec4 FragColor;
in vec2 ChunkTexCoords;

uniform sampler2D sampler;

void main() {
    FragColor = texture(sampler, ChunkTexCoords);   
    if(FragColor.a == 0) discard;
}

Texture parameters

    glTexParameteri(
        GL_TEXTURE_2D,
        GL_TEXTURE_WRAP_S,
        GL_CLAMP_TO_EDGE
    );
    glTexParameteri(
        GL_TEXTURE_2D,
        GL_TEXTURE_WRAP_T,
        GL_CLAMP_TO_EDGE
    );
    glTexParameteri(
        GL_TEXTURE_2D,
        GL_TEXTURE_MIN_FILTER,
        GL_NEAREST
    );
    glTexParameteri(
        GL_TEXTURE_2D,
        GL_TEXTURE_MAG_FILTER,
        GL_NEAREST
    );

While rendering texture making weird noises

1 Answers

Your texture minification filter is nearest neighbor box sampling. As soon as the sampling frequency falls below half the highest spatial frequency in your texture (the so called Nyquist frequency) you're going to get sampling aliasing artifacts.

The solution: Create complete set of mipmap levels that are properly low pass filtered.

Related