0
votes

I have a simple GLSL texture renderer:

Vertex shader:

varying vec2 UV;
void main() {
    UV = gl_MultiTexCoord0.xy;
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

Fragment shader:

varying vec2 UV;
uniform sampler2D diffuseMap;

void main(void) {
    gl_FragColor = texture2D(diffuseMap, UV);
}

And I have texture made of solid colors. I need to render this texture without any interpolation or antialiasing (which seems to happen at the edges of the solid colors). For me it would be better to just take the nearest pixel, rather than try to interpolate.

I'm not sure I was clear. Imagine it like this: I want to texture a ball with a chess pattern, and I want the result to be pure black and white. But the rendered creates a little bit of gray where black and white meet.

1

1 Answers

1
votes

Set GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAX_FILTER to GL_NEAREST and make sure that you do not have mipmaps.