ソースを参照

Removing Tile Font Shader

Vinicius Teshima 1 年間 前
コミット
4f3b232096
2 ファイル変更0 行追加100 行削除
  1. 0 57
      shaders/tile_font.frag
  2. 0 43
      shaders/tile_font.vert

+ 0 - 57
shaders/tile_font.frag

@@ -1,57 +0,0 @@
-#version 330 core
-
-#define FONT_WIDTH 128
-#define FONT_HEIGHT 64
-#define FONT_COLS 18
-#define FONT_ROWS 7
-#define FONT_CH_W (FONT_WIDTH  / FONT_COLS)
-#define FONT_CH_H (FONT_HEIGHT / FONT_ROWS)
-#define FONT_CH_W_UV (float(FONT_CH_W) / float(FONT_WIDTH))
-#define FONT_CH_H_UV (float(FONT_CH_H) / float(FONT_HEIGHT))
-
-uniform sampler2D font;
-uniform float time;
-uniform vec2 resolution;
-
-flat in int glyph_c;
-in vec4 glyph_fg_color;
-in vec4 glyph_bg_color;
-in vec2 uv;
-
-float map01(float x)
-{
-  return (x + 1) / 2;
-}
-
-vec3 hsl2rgb( in vec3 c )
-{
-    vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0,
-		      0.0, 1.0 );
-
-    return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0));
-}
-
-void main() {
-  int c = glyph_c;
-  if ( ! (c >= 32 && c <= 126) ) {
-    c = 63;
-  }
-
-  int index = c - 32;
-  float x = float(index % FONT_COLS) * FONT_CH_W_UV;
-  float y = float(index / FONT_COLS) * FONT_CH_H_UV;
-
-  vec2 ch_size = vec2(FONT_CH_W_UV, -FONT_CH_H_UV);
-  vec2 pos = vec2(x, y + FONT_CH_H_UV);
-  vec2 uv_ = vec2(uv.x, uv.y);
-
-  vec4 t = texture(font, pos + ch_size * uv_);
-
-  vec2 frag_uv = gl_FragCoord.xy / resolution;
-  vec4 rainbow = vec4(hsl2rgb(vec3((time + frag_uv.x + frag_uv.y) * 0.5,
-				   0.5,
-				   0.5)),
-		      1);
-
-  gl_FragColor = glyph_bg_color * (1.0 - t.x) + t.x * glyph_fg_color * rainbow;
-}

+ 0 - 43
shaders/tile_font.vert

@@ -1,43 +0,0 @@
-#version 330 core
-
-#define FONT_WIDTH 128
-#define FONT_HEIGHT 64
-#define FONT_COLS 18
-#define FONT_ROWS 7
-#define FONT_CH_W (FONT_WIDTH / FONT_COLS)
-#define FONT_CH_H (FONT_HEIGHT / FONT_ROWS)
-
-uniform float scale;
-uniform vec2 resolution;
-uniform float time;
-uniform vec2 camera;
-
-layout(location = 0) in ivec2 tile;
-layout(location = 1) in int c;
-layout(location = 2) in vec4 fg_color;
-layout(location = 3) in vec4 bg_color;
-
-out vec2 uv;
-flat out int glyph_c;
-out vec4 glyph_fg_color;
-out vec4 glyph_bg_color;
-
-vec2 project_point(vec2 point)
-{
-  return (2.0 * (point - camera)) / resolution;
-}
-
-void main()
-{
-  uv = vec2(float(gl_VertexID & 1),
-	    float((gl_VertexID >> 1) & 1));
-
-  vec2 char_size = vec2(float(FONT_CH_W), float(FONT_CH_H));
-  vec2 shake = vec2(cos(time + tile.x), sin(time + tile.y)) * 0;
-  vec2 pos = tile * char_size * scale + shake;
-  gl_Position = vec4(project_point(uv * char_size * scale + pos), 0.0, 1.0);
-
-  glyph_c = c;
-  glyph_fg_color = fg_color;
-  glyph_bg_color = bg_color;
-}