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

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

neercs: improve the point sprite rendering routine.

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