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

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

neercs: improve the upcoming point sprite renderer.

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