Forked from slembcke/NearlyNearestNeighborFiltering.glsl
Created
January 19, 2017 08:47
-
-
Save Volcanoscar/26d5cc17cead4c9d6f6a56dc213b35f8 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; | |
| uniform vec2 textureSize; | |
| varying vec2 uv; | |
| void main(){ | |
| vec2 puv = uv*textureSize; | |
| vec2 hfw = fwidth(puv)/2.0; | |
| vec2 fl = floor(puv - 0.5) + 0.5; | |
| vec2 nnn = (fl + smoothstep(0.5 - hfw, 0.5 + hfw, puv - fl))/textureSize; | |
| gl_FragColor = texture2D(texture, nnn); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment