Ignore:
Timestamp:
Jun 14, 2012, 8:23:06 PM (9 years ago)
Author:
sam
Message:

neercs: improve the upcoming point sprite renderer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/neercs/video/text.lolfx

    r1472 r1476  
    11-- GLSL.Vert --
    22
    3 #version 130
     3#version 150
    44
    55#if 0
     
    1111#endif
    1212attribute vec2 in_Position;
    13 attribute uint in_Char;
    14 //attribute vec4 in_Char;
    15 attribute vec4 in_Color;
     13attribute uint in_Char, in_Attr;
    1614
    1715varying vec4 pass_Foreground;
     
    2119void main()
    2220{
    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;
     21    float u = float(in_Char & 0xfu) / 32.0 + 0.0;
     22    float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5;
    3823    pass_UV = vec2(u, v);
    39 //pass_UV = in_Char.xy / 256;
    4024
    41     float r = in_Color.r;
    42     float g = in_Color.g;
    43     float b = in_Color.b;
    44     float a = in_Color.a;
     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;
    4529
    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);
     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;
    5334
    5435    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);
     36    //pass_Foreground = vec4(F, G, H, 1.0);
     37    pass_Foreground = vec4(1.0, 1.0, H, 1.0);
    5838
     39    // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     40    //gl_PointSize = 40;
    5941    gl_Position = vec4(in_Position, 0.0, 1.0);
    6042}
     
    6244-- GLSL.Frag --
    6345
    64 #version 130
     46#version 150
    6547
    6648varying vec4 pass_Foreground;
     
    7557    float t = texture2D(in_Texture, c).x;
    7658    gl_FragColor = mix(pass_Background, pass_Foreground, t);
    77 gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
    7859}
    7960
Note: See TracChangeset for help on using the changeset viewer.