source: trunk/tools/neercs/video/text.lolfx @ 1917

Last change on this file since 1917 was 1917, checked in by rez, 8 years ago

NEERCS: multiple pageup/pagedown now works

File size: 1.8 KB
Line 
1-- GLSL.Vert --
2
3#version 130
4
5#define HAVE_UINT 1
6
7attribute vec2 in_Position;
8#if HAVE_UINT
9attribute uint in_Char, in_Attr;
10#else
11attribute vec4 in_Char, in_Attr;
12#endif
13
14varying vec4 pass_Foreground;
15varying vec4 pass_Background;
16varying vec2 pass_UV;
17
18uniform mat4 in_Transform;
19
20void main()
21{
22#if HAVE_UINT
23    float u = float(in_Char & 0xfu) / 32.0 + 0.0;
24    float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5;
25#else
26    float u = 3.0 / 32.0;
27    float v = 3.0 / 32.0 + 0.5;
28#endif
29    pass_UV = vec2(u, v);
30
31#if HAVE_UINT
32    float A = float(in_Attr >> 29u) / 7.0;
33    float B = float((in_Attr >> 25u) & 0xfu) / 15.0;
34    float C = float((in_Attr >> 21u) & 0xfu) / 15.0;
35    float D = float((in_Attr >> 18u) & 0x7u) / 7.0;
36
37    float E = float((in_Attr >> 15u) & 0x7u) / 7.0;
38    float F = float((in_Attr >> 11u) & 0xfu) / 15.0;
39    float G = float((in_Attr >> 7u) & 0xfu) / 15.0;
40    float H = float((in_Attr >> 4u) & 0x7u) / 7.0;
41#else
42    float A = 0.0;
43    float B = 0.0;
44    float C = 0.0;
45    float D = 0.0;
46
47    float E = 0.0;
48    float F = 1.0;
49    float G = 1.0;
50    float H = 1.0;
51#endif
52
53    //pass_Background = vec4(B, C, D, 1.0 - A); // original
54    pass_Background = vec4(B + 0.0625, C + 0.125, D + 0.125, 1.0 - A);
55    pass_Foreground = vec4(F, G, H, 1.0 - E);
56    if (B + C + D < 0.01) A = 1.0;
57    if (F + G + H < 0.01) E = 1.0;
58
59    // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
60    //gl_PointSize = 40;
61
62    gl_Position = in_Transform * vec4(in_Position, 0.0, 1.0);
63}
64
65-- GLSL.Frag --
66
67#version 130
68
69varying vec4 pass_Foreground;
70varying vec4 pass_Background;
71varying vec2 pass_UV;
72
73uniform sampler2D in_Texture;
74
75void main(void)
76{
77    vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV;
78    float t = texture2D(in_Texture, c).x;
79    gl_FragColor = mix(pass_Background, pass_Foreground, t);
80}
Note: See TracBrowser for help on using the repository browser.