Last active
December 27, 2020 21:19
-
-
Save slembcke/23e1d96d7e3c739caf12 to your computer and use it in GitHub Desktop.
Anti-aliased Nearest Neighbor Filtering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform sampler2D texture; | |
varying vec2 uv; | |
void main(){ | |
vec2 size = textureSize(texture); | |
vec2 puv = uv*size; | |
vec2 hfw = 0.5*fwidth(puv); | |
vec2 fl = floor(puv - 0.5) + 0.5; | |
vec2 nnn = (fl + smoothstep(0.5 - hfw, 0.5 + hfw, puv - fl))/size; | |
gl_FragColor = texture2D(texture, nnn); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment