简体   繁体   中英

GLSL render solid pixels, without interpolation.or antialiasing

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.

将GL_TEXTURE_MIN_FILTER和GL_TEXTURE_MAX_FILTER设置为GL_NEAREST,并确保没有mipmap。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM