You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

81 lines
1.8 KiB

  1. -- GLSL.Vert --
  2. #version 130
  3. #define HAVE_UINT 1
  4. attribute vec2 in_Position;
  5. #if HAVE_UINT
  6. attribute uint in_Char, in_Attr;
  7. #else
  8. attribute vec4 in_Char, in_Attr;
  9. #endif
  10. varying vec4 pass_Foreground;
  11. varying vec4 pass_Background;
  12. varying vec2 pass_UV;
  13. uniform mat4 in_Transform;
  14. void main()
  15. {
  16. #if HAVE_UINT
  17. float u = float(in_Char & 0xfu) / 32.0 + 0.0;
  18. float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5;
  19. #else
  20. float u = 3.0 / 32.0;
  21. float v = 3.0 / 32.0 + 0.5;
  22. #endif
  23. pass_UV = vec2(u, v);
  24. #if HAVE_UINT
  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. float E = float((in_Attr >> 15u) & 0x7u) / 7.0;
  30. float F = float((in_Attr >> 11u) & 0xfu) / 15.0;
  31. float G = float((in_Attr >> 7u) & 0xfu) / 15.0;
  32. float H = float((in_Attr >> 4u) & 0x7u) / 7.0;
  33. #else
  34. float A = 0.0;
  35. float B = 0.0;
  36. float C = 0.0;
  37. float D = 0.0;
  38. float E = 0.0;
  39. float F = 1.0;
  40. float G = 1.0;
  41. float H = 1.0;
  42. #endif
  43. //pass_Background = vec4(B, C, D, 1.0 - A); // original
  44. pass_Background = vec4(B + 0.0625, C + 0.125, D + 0.125, 1.0 - A);
  45. pass_Foreground = vec4(F, G, H, 1.0 - E);
  46. if (B + C + D < 0.01) A = 1.0;
  47. if (F + G + H < 0.01) E = 1.0;
  48. // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
  49. //gl_PointSize = 40;
  50. gl_Position = in_Transform * vec4(in_Position, 0.0, 1.0);
  51. }
  52. -- GLSL.Frag --
  53. #version 130
  54. varying vec4 pass_Foreground;
  55. varying vec4 pass_Background;
  56. varying vec2 pass_UV;
  57. uniform sampler2D in_Texture;
  58. void main(void)
  59. {
  60. vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV;
  61. float t = texture2D(in_Texture, c).x;
  62. gl_FragColor = mix(pass_Background, pass_Foreground, t);
  63. }