Last active
December 19, 2015 11:08
-
-
Save johnbartholomew/5945143 to your computer and use it in GitHub Desktop.
This file contains 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
// ---- text.vert.glsl | |
#version 150 | |
uniform vec2 text_offset; | |
uniform vec2 rcp_screen_size; | |
in vec2 v_screen_pos; | |
in vec2 v_uv; | |
out vec2 f_uv; | |
void main() { | |
f_uv = v_uv; | |
gl_Position.xy = (v_screen_pos * rcp_screen_size) + text_offset; | |
gl_Position.z = 0.0; | |
gl_Position.w = 1.0; | |
} | |
// ---- text.frag.glsl | |
#version 150 | |
uniform usampler2DRect tex; | |
uniform vec4 text_color_outer; | |
uniform vec4 text_color_inner; | |
in vec2 f_uv; | |
out vec4 out_color; | |
void main() { | |
float v = float(texture(tex, f_uv).r) / 254.0; | |
float a = clamp(2.0 * v, 0, 1); | |
float c = clamp((v - 0.5) * 2.0, 0, 1); | |
out_color = a * mix(text_color_outer, text_color_inner, c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment