| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- #version 330 core
- #define FONT_WIDTH 128
- #define FONT_HEIGHT 64
- #define FONT_COLS 18
- #define FONT_ROWS 7
- #define FONT_CH_W (FONT_WIDTH / FONT_COLS)
- #define FONT_CH_H (FONT_HEIGHT / FONT_ROWS)
- #define FONT_CH_W_UV (float(FONT_CH_W) / float(FONT_WIDTH))
- #define FONT_CH_H_UV (float(FONT_CH_H) / float(FONT_HEIGHT))
- uniform sampler2D font;
- uniform float time;
- flat in int glyph_c;
- in vec4 glyph_fg_color;
- in vec4 glyph_bg_color;
- in vec2 uv;
- void main() {
- int c = glyph_c;
- if ( ! (c >= 32 && c <= 126) ) {
- c = 63;
- }
- int index = c - 32;
- float x = float(index % FONT_COLS) * FONT_CH_W_UV;
- float y = float(index / FONT_COLS) * FONT_CH_H_UV;
- vec2 ch_size = vec2(FONT_CH_W_UV, -FONT_CH_H_UV);
- vec2 pos = vec2(x, y + FONT_CH_H_UV);
- vec2 uv_ = vec2(uv.x, uv.y);
- vec4 t = texture(font, pos + ch_size * uv_);
- gl_FragColor = glyph_bg_color * (1.0 - t.x) + t.x * glyph_fg_color;
- // * vec4((sin(uv.x + time) + 1.0) / 2.0,
- // (cos(uv.y + time) + 1.0) / 2.0,
- // (sin(uv.x + uv.y + time) + 1.0) / 2.0,
- // 1);
- }
|