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

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

neercs: font blitting is now pixel perfect.

File size: 1.3 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
33    // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
34    //gl_PointSize = 40;
35
36    gl_Position = in_Transform * vec4(in_Position, 0.0, 1.0);
37}
38
39-- GLSL.Frag --
40
41#version 130
42
43varying vec4 pass_Foreground;
44varying vec4 pass_Background;
45varying vec2 pass_UV;
46
47uniform sampler2D in_Texture;
48
49void main(void)
50{
51    vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV;
52    float t = texture2D(in_Texture, c).x;
53    gl_FragColor = mix(pass_Background, pass_Foreground, t);
54}
55
Note: See TracBrowser for help on using the repository browser.