Created
November 18, 2016 23:58
-
-
Save shakesoda/46017e5b57ef7fa36ea4fda8c5280b8e 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
| #if VERTEX | |
| $input a_position, a_texcoord0 | |
| $output v_texcoord0 | |
| #include "common.glsl" | |
| void main() { | |
| v_texcoord0 = a_texcoord0; | |
| gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0)); | |
| } | |
| #endif | |
| #if FRAGMENT | |
| $input v_texcoord0 | |
| #include "common.glsl" | |
| SAMPLER2D(s_tex_color, 0); | |
| const float distancethreshold = 0.5; | |
| float aastep(float threshold, float dist) { | |
| float afwidth = 0.75 * length(vec2(dFdx(dist), dFdy(dist))); | |
| return smoothstep(threshold - afwidth, threshold + afwidth, dist); | |
| } | |
| float sample(vec2 tc, vec2 offset, float width) { | |
| float dist = texture2D(s_tex_color, tc - offset).a; | |
| return aastep(distancethreshold - width, dist); | |
| } | |
| void main() { | |
| vec4 out_color = vec4(vec3_splat(1.0), 0.0); | |
| vec2 tc = v_texcoord0; | |
| out_color += vec4(0.0, 0.0, 0.0, 1.0) * sample(tc, vec2(0.0, 0.0025), 0.125); | |
| out_color += vec4(4.0, 4.0, 4.0, 1.0) * sample(tc, vec2(0.0, 0.0), 0.0); | |
| out_color.a = clamp(out_color.a, 0.0, 1.0); | |
| gl_FragColor = out_color; | |
| } | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment