Skip to content

Instantly share code, notes, and snippets.

@shakesoda
Created October 29, 2013 22:25
Show Gist options
  • Save shakesoda/7223786 to your computer and use it in GitHub Desktop.
Save shakesoda/7223786 to your computer and use it in GitHub Desktop.
#extension GL_OES_standard_derivatives : enable
precision highp float;
varying vec2 v_texCoord;
uniform sampler2D texture0;
const float distancethreshold = 0.5;
float aastep(float threshold, float dist)
{
float afwidth = 0.5 * length(vec2(dFdx(dist), dFdy(dist)));
return smoothstep(threshold - afwidth, threshold + afwidth, dist);
}
void main()
{
float dist = texture2D(texture0, v_texCoord).a;
float alpha = aastep(distancethreshold, dist);
gl_FragColor = vec4(vec3(1.0), alpha);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment