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

Last change on this file since 1588 was 1588, checked in by rez, 11 years ago

debug shortcuts added

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