Created
October 29, 2013 22:25
-
-
Save shakesoda/7223786 to your computer and use it in GitHub Desktop.
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
| #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