From 88ef6faf133e96673a1db7f9d74c382016abdfeb Mon Sep 17 00:00:00 2001 From: Tanasart Date: Wed, 27 Mar 2024 20:18:39 +0700 Subject: [PATCH] aa mode for generators --- fonts/_f_sdf/_f_sdf.old.png | Bin 82361 -> 82361 bytes fonts/_f_sdf/_f_sdf.png | Bin 82361 -> 82361 bytes fonts/_f_sdf_medium/_f_sdf_medium.old.png | Bin 59906 -> 59906 bytes fonts/_f_sdf_medium/_f_sdf_medium.png | Bin 59906 -> 59906 bytes .../__panel_linear_setting.gml | 4 +- scripts/nodeValue_drawer/nodeValue_drawer.gml | 7 +- scripts/node_checker/node_checker.gml | 6 +- scripts/node_stripe/node_stripe.gml | 5 +- scripts/node_value/node_value.gml | 4 +- scripts/node_zigzag/node_zigzag.gml | 21 +++++- scripts/panel_graph/panel_graph.gml | 2 +- .../panel_graph_export_image.gml | 2 +- scripts/panel_test/panel_test.gml | 30 +++++++-- scripts/vectorBox/vectorBox.gml | 14 ++-- shaders/sh_checkerboard/sh_checkerboard.fsh | 42 ++++++++---- shaders/sh_stripe/sh_stripe.fsh | 12 +++- shaders/sh_zigzag/sh_zigzag.fsh | 62 ++++++++++++------ 17 files changed, 149 insertions(+), 62 deletions(-) diff --git a/fonts/_f_sdf/_f_sdf.old.png b/fonts/_f_sdf/_f_sdf.old.png index 62eb07cceafd0cf6906332bfd93eb6a6586d4744..e182668ae95ac7039cc173bc781648b180f7766f 100644 GIT binary patch delta 90 zcmdnl%(}CgwP6dRnWK=Qft9hPm4T_Yfq|8QK|$V(&(l2|8RgN$8I2YEr&l^MD#@X$ T4^v~DzyJiEu6{1-oD!MFVdQ&MBb@0FtvAr~m)} diff --git a/fonts/_f_sdf/_f_sdf.png b/fonts/_f_sdf/_f_sdf.png index e182668ae95ac7039cc173bc781648b180f7766f..d9199c9d1c840b26fadef14f0c1d35cfaac145c7 100644 GIT binary patch delta 87 zcmdnl%(}CgwP6dRxuc+wm5G^^p@Fu6ft7(l*aV;c=^l=Z3aG;BXTKOvuXJQomPJur TaO3J51|aZs^>bP0l+XkKHUb#F delta 87 zcmdnl%(}CgwP6dRxuc+gm9eFjfvL8Eft7(lLEend(>)v+6;Op4jTQW-S2{8(%c7_b SQ)8UK00f?{elF{r5}E)DbQS&p diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.old.png b/fonts/_f_sdf_medium/_f_sdf_medium.old.png index b28d2564adfc77ddf9892d5073f9683229324757..b26c72c3e48e3b29a2e247a7b75336f19646a63e 100644 GIT binary patch delta 86 zcmZp=!rXL)c|-k6AwvTzV@oRoQ*8qSD+7aqycwS-PkbqlCd_E8;6M4$OC>o})nRIk Q6BvNN)78&qol`;+0IAFw1poj5 delta 86 zcmZp=!rXL)c|-k6Ap;95Q!^_QOKk%KD+7bKX7MW~PkbqlCOjwmxya;0FO}p_RiCaq RcA5bQJYD@<);T3K0RZyG92@`u diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.png b/fonts/_f_sdf_medium/_f_sdf_medium.png index b26c72c3e48e3b29a2e247a7b75336f19646a63e..1c4e01336fafa79640ee325c08fab80f2553e864 100644 GIT binary patch delta 83 zcmZp=!rXL)c|*fXK_e>@Gb=*_Z36=<1B0*$KK+v?zEnUJRX_X1c=Dl_%CabG3vOI} P!vF-Hu6{1-oD!M Test complete"); + show_debug_message($" > Test complete : {(get_timer() - __start_time) / 1_000_000} s"); } catch(e) { show_debug_message($" > Test failed"); exception_print(e); @@ -67,12 +72,27 @@ function Panel_Test() : PanelContent() constructor { var yy = 8; var hh = TEXTBOX_HEIGHT; + tb_test_dir.setFocusHover(pFOCUS, pHOVER); + tb_index.setFocusHover(pFOCUS, pHOVER); + tb_amount.setFocusHover(pFOCUS, pHOVER); + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); draw_text(8, yy + hh / 2, "Directory"); - tb_test_dir.setFocusHover(pFOCUS, pHOVER); tb_test_dir.draw(128, yy, w - 8 - 128, hh, test_dir, [ mx, my ]); yy += hh + 8; + + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); + draw_text(8, yy + hh / 2, "Start"); + + tb_index.draw(128, yy, w - 8 - 128, hh, start_index, [ mx, my ]); + yy += hh + 8; + + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text); + draw_text(8, yy + hh / 2, "Amount"); + + tb_amount.draw(128, yy, w - 8 - 128, hh, test_amount, [ mx, my ]); + yy += hh + 8; if(testing) { var _w = (w - 16) * test_index / array_length(test_files); diff --git a/scripts/vectorBox/vectorBox.gml b/scripts/vectorBox/vectorBox.gml index 3c36414fa..fc0adb9a8 100644 --- a/scripts/vectorBox/vectorBox.gml +++ b/scripts/vectorBox/vectorBox.gml @@ -49,7 +49,6 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { for(var i = 0; i < 4; i++) { tb[i] = new textBox(TEXTBOX_INPUT.number, onModifySingle[i]); tb[i].slidable = true; - tb[i].label = axis[i]; } static setLinkInactiveColor = function(color) { #region @@ -95,7 +94,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { x = _x; y = _y; w = _w; - h = per_line? (_h + ui(8)) * size - ui(8) : _h; + h = per_line? (_h + ui(4)) * size - ui(4) : _h; if(struct_has(_display_data, "linked")) linked = _display_data.linked; if(struct_has(_display_data, "side_button")) side_button = _display_data.side_button; @@ -143,16 +142,19 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { var sz = min(size, array_length(_data)); var ww = per_line? _w : _w / sz; - draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1); - draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable); + if(!per_line) { + draw_sprite_stretched_ext(THEME.textbox, 3, _x, _y, _w, _h, c_white, 1); + draw_sprite_stretched_ext(THEME.textbox, 0, _x, _y, _w, _h, c_white, 0.5 + 0.5 * interactable); + } for(var i = 0; i < sz; i++) { var bx = per_line? _x : _x + ww * i; - var by = per_line? _y + (_h + ui(8)) * i : _y; + var by = per_line? _y + (_h + ui(4)) * i : _y; tb[i].setFocusHover(active, hover); - tb[i].hide = true; + tb[i].hide = !per_line; + tb[i].label = axis[i]; tb[i].draw(bx, by, ww, _h, _data[i], _m); } diff --git a/shaders/sh_checkerboard/sh_checkerboard.fsh b/shaders/sh_checkerboard/sh_checkerboard.fsh index 0828eda71..a896b8e59 100644 --- a/shaders/sh_checkerboard/sh_checkerboard.fsh +++ b/shaders/sh_checkerboard/sh_checkerboard.fsh @@ -1,11 +1,11 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; +#define PI 3.14159265359 + uniform vec2 dimension; uniform vec2 position; +uniform int blend; uniform vec2 amount; uniform int amountUseSurf; @@ -18,6 +18,19 @@ uniform sampler2D angleSurf; uniform vec4 col1; uniform vec4 col2; +float check(vec2 c, float amo, float ang) { + float _x = c.x * cos(ang) - c.y * sin(ang); + float _y = c.x * sin(ang) + c.y * cos(ang); + float _a = 1. / amo; + + vec2 px = vec2(floor(_x / _a) + 0.5, floor(_y / _a) + 0.5) * _a; + float dd = 1. - (max(abs(px.x - _x), abs(px.y - _y)) / _a + 0.5); + float mm = mod(floor(_x / _a) + floor(_y / _a), 2.); + + return mm < .5? 0.5 + dd : 0.5 - dd; + //return mod(floor(_x / _a) + floor(_y / _a), 2.); +} + void main() { #region params float amo = amount.x; @@ -34,14 +47,19 @@ void main() { ang = radians(ang); #endregion - vec2 dimension_norm = dimension / dimension.y; - vec2 c = (v_vTexcoord - position) * dimension_norm; - float _x = c.x * cos(ang) - c.y * sin(ang); - float _y = c.x * sin(ang) + c.y * cos(ang); - float _a = 1. / amo; + vec2 a = dimension / dimension.y; + vec2 c = (v_vTexcoord - position) * a; - if(mod(floor(_x / _a) + floor(_y / _a), 2.) > 0.5) - gl_FragColor = col1; - else - gl_FragColor = col2; + float ch = check(c, amo, ang); + + if(blend == 0) gl_FragColor = ch < 0.5? col1 : col2; + else if(blend == 1) { + gl_FragColor = mix(col1, col2, ch); + + } else if(blend == 2) { + float px = 2. / max(dimension.x, dimension.y); + ch = smoothstep(0.5 - px, 0.5 + px, ch); + + gl_FragColor = mix(col1, col2, ch); + } } diff --git a/shaders/sh_stripe/sh_stripe.fsh b/shaders/sh_stripe/sh_stripe.fsh index 5f6015bf2..eaa391342 100644 --- a/shaders/sh_stripe/sh_stripe.fsh +++ b/shaders/sh_stripe/sh_stripe.fsh @@ -203,10 +203,16 @@ void main() { #region float _s = (prog - ground) / (ceiling - ground); if(gradient_use == 0) { - if(blend == 0) gl_FragColor = _s > rat? color0 : color1; - else { + if(blend == 0) gl_FragColor = _s > rat? color0 : color1; + else if(blend == 1) { _s = sin(_s * 2. * PI) * 0.5 + 0.5; - gl_FragColor = mix(color0, color1, _s); + gl_FragColor = mix(color0, color1, _s); + + } else if(blend == 2) { + float px = 3. / max(dimension.x, dimension.y); + _s = smoothstep(-px, px, sin(_s * 2. * PI)); + + gl_FragColor = mix(color0, color1, _s); } } else { if(_s > rat) gl_FragColor = gradientEval(random(vec2(slot))); diff --git a/shaders/sh_zigzag/sh_zigzag.fsh b/shaders/sh_zigzag/sh_zigzag.fsh index 73a501690..647cbb9fe 100644 --- a/shaders/sh_zigzag/sh_zigzag.fsh +++ b/shaders/sh_zigzag/sh_zigzag.fsh @@ -1,27 +1,42 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; +uniform vec2 dimension; uniform vec2 position; -uniform int blend; +uniform int blend; +uniform float rotation; uniform vec2 amount; uniform int amountUseSurf; uniform sampler2D amountSurf; +uniform vec2 angle; +uniform int angleUseSurf; +uniform sampler2D angleSurf; + uniform vec4 col1, col2; void main() { - float amo = amount.x; - if(amountUseSurf == 1) { - vec4 _vMap = texture2D( amountSurf, v_vTexcoord ); - amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); - } + #region params + float amo = amount.x; + if(amountUseSurf == 1) { + vec4 _vMap = texture2D( amountSurf, v_vTexcoord ); + amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } - vec2 pos = v_vTexcoord - position; - float _cell = 1. / (amo * 2.); + float ang = angle.x; + if(angleUseSurf == 1) { + vec4 _vMap = texture2D( angleSurf, v_vTexcoord ); + ang = mix(angle.x, angle.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + ang = radians(ang); + #endregion + + + vec2 pos = v_vTexcoord - position; + float _cell = 1. / (amo * 2.); + pos.y -= _cell / 2.; + pos *= mat2(cos(ang), -sin(ang), sin(ang), cos(ang)); float _xind = floor(pos.x / _cell); float _yind = floor(pos.y / _cell); @@ -35,16 +50,21 @@ void main() { if(mod(_xind, 2.) == 1.) _x = 1. - _xcell; + float _h = _x > _y? _y + (1. - _x) : _y - _x; + + float _ychi = _x > _y ? _yind + 1. : _yind; + if(mod(_ychi, 2.) == 1.) _h = 1. - _h; + if(blend == 0) { - if(mod(_yind, 2.) == 1.) { - if(_x > _y) gl_FragColor = col1; - else gl_FragColor = col2; - } else { - if(_x > _y) gl_FragColor = col2; - else gl_FragColor = col1; - } - } else { - if(_x > _y) gl_FragColor = mix(col1, col2, _y + (1. - _x)); - else gl_FragColor = mix(col1, col2, _y - _x); + gl_FragColor = _h < 0.5? col1 : col2; + + } else if(blend == 1) { + gl_FragColor = mix(col1, col2, _h); + + } else if(blend == 2) { + float px = 1. / max(dimension.x, dimension.y); + _h = smoothstep(0.5 - px, 0.5 + px, _h); + + gl_FragColor = mix(col1, col2, _h); } }