source: trunk/neercs/video/text.lolfx @ 1472

Last change on this file since 1472 was 1472, checked in by sam, 9 years ago

neercs: fix mismatched signed/unsigned operations.

File size: 1.8 KB
Line 
1-- GLSL.Vert --
2
3#version 130
4
5#if 0
6uniform mat4 MVP;
7void main()
8{
9   gl_Position = MVP*vec4(vVertex,1);
10}
11#endif
12attribute vec2 in_Position;
13attribute uint in_Char;
14//attribute vec4 in_Char;
15attribute vec4 in_Color;
16
17varying vec4 pass_Foreground;
18varying vec4 pass_Background;
19varying vec2 pass_UV;
20
21void main()
22{
23    float u = float((in_Char >> 17u) & 0xfu) / 32.0 + 0.0;
24// bits
25// 1: 0 // 2: 0 // 4: 0 // 8: 0
26// 16: 0  32: 0   64: 0  128: 0
27// ...
28// 17: bit 0
29// 18: bit 1
30// 19: bit 2
31// 20: bit 3
32//float u = float(in_Char & 2097152u) / 2097152.0 / 32.0;
33    float v = float((in_Char >> 21u) & 0xfu) / 32.0 + 0.5;
34    //float v = float(2) / 32.0 + 0.5;
35    //float ch = in_Char * 255.0;
36    //    float u = (in_Char - mod(in_Char, 1.0 / 16.0)) * 0.5;
37    //    float v = 0.5 - mod(in_Char, 1.0 / 16.0) * 8.0;// - 13.5 / 32.0;
38    pass_UV = vec2(u, v);
39//pass_UV = in_Char.xy / 256;
40
41    float r = in_Color.r;
42    float g = in_Color.g;
43    float b = in_Color.b;
44    float a = in_Color.a;
45
46    float A = r - mod(r, 1.0 / 8.0);
47    float B = mod(r, 1.0 / 8.0) * 8.0;
48          B = B - mod(B, 1.0 / 16.0);
49    float C = mod(r, 1.0 / 128.0)
50            + (g - mod(g, 1.0 / 8.0)) / 8.0;
51    float D = mod(g, 1.0 / 8.0) * 8.0;
52          D = D - mod(D, 1.0 / 8.0);
53
54    pass_Background = vec4(B, C, D, 1.0);
55    pass_Foreground = vec4(1.0, 0.0, 1.0, 1.0);
56//pass_Background =  vec4(0.0, 0.0, 1.0, 1.0);
57//pass_Foreground =  vec4(0.0, 1.0, 0.0, 1.0);
58
59    gl_Position = vec4(in_Position, 0.0, 1.0);
60}
61
62-- GLSL.Frag --
63
64#version 130
65
66varying vec4 pass_Foreground;
67varying vec4 pass_Background;
68varying vec2 pass_UV;
69
70uniform sampler2D in_Texture;
71
72void main(void)
73{
74    vec2 c = (gl_PointCoord + vec2(0.0,0.0)) / 32 + pass_UV;
75    float t = texture2D(in_Texture, c).x;
76    gl_FragColor = mix(pass_Background, pass_Foreground, t);
77gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
78}
79
Note: See TracBrowser for help on using the repository browser.