Last active
June 6, 2016 14:25
-
-
Save BigZaphod/e695d101c5f4499481b2b3c16d19ca23 to your computer and use it in GitHub Desktop.
This file contains 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
// translates a normalized texture coordinate into a normalized texture coordinate that has been "snapped" to the center of a pixel | |
vec2 nearest(vec2 uv, vec2 size) { | |
vec2 pixel = uv * size; | |
vec2 snapped = floor(pixel - 0.5) + 0.5; | |
return (snapped + step(0.5, pixel - snapped)) / size; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment