-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathbig.glsl
6 lines (6 loc) · 3.34 KB
/
big.glsl
1
2
3
4
5
6
//sdf来自 https://www.shadertoy.com/view/XtsGRl 可以去https://www.shadertoy.com/new 运行
#define CHAR_SIZE vec2(3, 7)
#define CHAR_SPACING vec2(4, 8)
#define STRWIDTH(c) (c * CHAR_SPACING.x)
#define STRHEIGHT(c) (c * CHAR_SPACING.y)
float ch_sp = 0.0; float ch_a = 712557.0; float ch_b = 1760622.0; float ch_c = 706858.0; float ch_d = 1760110.0; float ch_e = 2018607.0; float ch_f = 2018596.0; float ch_g = 706922.0; float ch_h = 1498989.0; float ch_i = 1909911.0; float ch_j = 1872746.0; float ch_k = 1498477.0; float ch_l = 1198375.0; float ch_m = 1571693.0; float ch_n = 1760109.0; float ch_o = 711530.0; float ch_p = 711972.0; float ch_q = 711675.0; float ch_r = 1760621.0; float ch_s = 2018927.0; float ch_t = 1909906.0; float ch_u = 1497963.0; float ch_v = 1497938.0; float ch_w = 1498109.0; float ch_x = 1496429.0; float ch_y = 1496210.0; float ch_z = 2004271.0; float ch_1 = 730263.0; float ch_2 = 693543.0; float ch_3 = 693354.0; float ch_4 = 1496649.0; float ch_5 = 1985614.0; float ch_6 = 707946.0; float ch_7 = 1873042.0; float ch_8 = 709994.0; float ch_9 = 710250.0; float ch_0 = 711530.0; float ch_per = 2.0; float ch_que = 693378.0; float ch_exc = 599170.0; float ch_com = 10.0; float ch_scl = 65556.0; float ch_col = 65552.0; float ch_usc = 7.0; float ch_crs = 11904.0; float ch_dsh = 3584.0; float ch_ast = 21824.0; float ch_fsl = 304292.0; float ch_bsl = 1189001.0; float ch_lpr = 346385.0; float ch_rpr = 1118804.0; float ch_lba = 862355.0; float ch_rpa = 1647254.0; vec2 res = vec2(0); vec2 print_pos = vec2(2,2); float extract_bit(float n, float b) { return floor(mod(floor(n / pow(2.0,floor(b))),2.0)); } float sprite(float spr, vec2 size, vec2 uv) { uv = floor(uv); float bit = (size.x-uv.x-1.0) + uv.y * size.x; bool bounds = all(greaterThanEqual(uv,vec2(0))); bounds = bounds && all(lessThan(uv,size)); return bounds ? extract_bit(spr, bit) : 0.0; } float get_digit(float d) { d = floor(d); if(d == 0.0) return ch_0; if(d == 1.0) return ch_1; if(d == 2.0) return ch_2; if(d == 3.0) return ch_3; if(d == 4.0) return ch_4; if(d == 5.0) return ch_5; if(d == 6.0) return ch_6; if(d == 7.0) return ch_7; if(d == 8.0) return ch_8; if(d == 9.0) return ch_9; return 0.0; } float print_number(float number,vec2 pos, vec2 uv) { vec2 dec_pos = pos; float result = 0.0; for(int i = 3;i >= 0;i--) { float clip = float(abs(number) > pow(10.0, float(i)) || i == 0); float digit = mod(number / pow(10.0, float(i)),10.0); result += sprite(get_digit(digit),CHAR_SIZE, uv - dec_pos) * clip; dec_pos.x += CHAR_SPACING.x * clip; } return result; } float char(float ch, vec2 uv) { float px = sprite(ch, CHAR_SIZE, uv - print_pos); print_pos.x += CHAR_SPACING.x; return px; } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { res = iResolution.xy / 1.5; vec2 uv = fragCoord.xy / 1.5; uv = floor(uv); float col = 0.0; print_pos = vec2(res.x/2.0 - STRWIDTH(17.0)/2.0,res.y/2.0 - STRHEIGHT(1.0)/2.0); for(int i=1;i<=9;i++){ for(int l=1;l<=i;l++){ print_pos = vec2(float((l-1)*58)+10.,200.-float(i*10)); col += print_number(float(l),print_pos,uv); print_pos.x += 10.; col += char(ch_x,uv); print_pos.x += 10.; col += print_number(float(i),print_pos,uv); print_pos.y += 2.; print_pos.x += 10.; col += char(ch_usc,uv); print_pos.y += 2.; print_pos.x -= 4.; col += char(ch_usc,uv); print_pos.x += 2.; print_pos.y -= 4.; col += print_number(float(i*l),print_pos,uv); } } fragColor = vec4(vec3(col), 1.0); }