Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Volcanoscar/26d5cc17cead4c9d6f6a56dc213b35f8 to your computer and use it in GitHub Desktop.

Select an option

Save Volcanoscar/26d5cc17cead4c9d6f6a56dc213b35f8 to your computer and use it in GitHub Desktop.
Anti-aliased Nearest Neighbor Filtering.
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