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

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

NEERCS: added copper in setup (not working yet)

File size: 1.7 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 + 0.0625, C + 0.125, D + 0.125, 1.0 - A);
54    pass_Foreground = vec4(F, G, H, 1.0 - E);
55    if (B + C + D < 0.01) A = 1.0;
56    if (F + G + H < 0.01) E = 1.0;
57
58    // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
59    //gl_PointSize = 40;
60
61    gl_Position = in_Transform * vec4(in_Position, 0.0, 1.0);
62}
63
64-- GLSL.Frag --
65
66#version 130
67
68varying vec4 pass_Foreground;
69varying vec4 pass_Background;
70varying vec2 pass_UV;
71
72uniform sampler2D in_Texture;
73
74void main(void)
75{
76    vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV;
77    float t = texture2D(in_Texture, c).x;
78    gl_FragColor = mix(pass_Background, pass_Foreground, t);
79}
Note: See TracBrowser for help on using the repository browser.