diff --git a/PixelComposer.resource_order b/PixelComposer.resource_order index 3320deaf4..942876770 100644 --- a/PixelComposer.resource_order +++ b/PixelComposer.resource_order @@ -970,6 +970,7 @@ {"name":"s_node_3d_light_directi","order":17,"path":"sprites/s_node_3d_light_directi/s_node_3d_light_directi.yy",}, {"name":"spr_gameframe_pixel","order":3,"path":"sprites/spr_gameframe_pixel/spr_gameframe_pixel.yy",}, {"name":"process_functions","order":36,"path":"scripts/process_functions/process_functions.yy",}, + {"name":"node_quasicrystal","order":9,"path":"scripts/node_quasicrystal/node_quasicrystal.yy",}, {"name":"s_node_radial","order":47,"path":"sprites/s_node_radial/s_node_radial.yy",}, {"name":"s_node_grid","order":3,"path":"sprites/s_node_grid/s_node_grid.yy",}, {"name":"s_patreon_supporter","order":4,"path":"sprites/s_patreon_supporter/s_patreon_supporter.yy",}, @@ -1730,6 +1731,7 @@ {"name":"path_parser","order":3,"path":"scripts/path_parser/path_parser.yy",}, {"name":"s_node_3d_camera","order":13,"path":"sprites/s_node_3d_camera/s_node_3d_camera.yy",}, {"name":"node_crop_content","order":14,"path":"scripts/node_crop_content/node_crop_content.yy",}, + {"name":"sh_quarsicrystal","order":23,"path":"shaders/sh_quarsicrystal/sh_quarsicrystal.yy",}, {"name":"s_node_unicode","order":8,"path":"sprites/s_node_unicode/s_node_unicode.yy",}, {"name":"s_node_color_from_hsv","order":4,"path":"sprites/s_node_color_from_hsv/s_node_color_from_hsv.yy",}, {"name":"fd_rectangle_get_material_type","order":14,"path":"scripts/fd_rectangle_get_material_type/fd_rectangle_get_material_type.yy",}, diff --git a/PixelComposer.yyp b/PixelComposer.yyp index 2d3be50f0..3a0349404 100644 --- a/PixelComposer.yyp +++ b/PixelComposer.yyp @@ -1258,6 +1258,7 @@ {"id":{"name":"s_node_3d_light_directi","path":"sprites/s_node_3d_light_directi/s_node_3d_light_directi.yy",},}, {"id":{"name":"spr_gameframe_pixel","path":"sprites/spr_gameframe_pixel/spr_gameframe_pixel.yy",},}, {"id":{"name":"process_functions","path":"scripts/process_functions/process_functions.yy",},}, + {"id":{"name":"node_quasicrystal","path":"scripts/node_quasicrystal/node_quasicrystal.yy",},}, {"id":{"name":"s_node_radial","path":"sprites/s_node_radial/s_node_radial.yy",},}, {"id":{"name":"s_node_grid","path":"sprites/s_node_grid/s_node_grid.yy",},}, {"id":{"name":"s_patreon_supporter","path":"sprites/s_patreon_supporter/s_patreon_supporter.yy",},}, @@ -2125,6 +2126,7 @@ {"id":{"name":"path_parser","path":"scripts/path_parser/path_parser.yy",},}, {"id":{"name":"s_node_3d_camera","path":"sprites/s_node_3d_camera/s_node_3d_camera.yy",},}, {"id":{"name":"node_crop_content","path":"scripts/node_crop_content/node_crop_content.yy",},}, + {"id":{"name":"sh_quarsicrystal","path":"shaders/sh_quarsicrystal/sh_quarsicrystal.yy",},}, {"id":{"name":"s_node_unicode","path":"sprites/s_node_unicode/s_node_unicode.yy",},}, {"id":{"name":"s_node_color_from_hsv","path":"sprites/s_node_color_from_hsv/s_node_color_from_hsv.yy",},}, {"id":{"name":"fd_rectangle_get_material_type","path":"scripts/fd_rectangle_get_material_type/fd_rectangle_get_material_type.yy",},}, diff --git a/fonts/_f_sdf/_f_sdf.old.png b/fonts/_f_sdf/_f_sdf.old.png index ee1ed111b..ca4a04dfa 100644 Binary files a/fonts/_f_sdf/_f_sdf.old.png and b/fonts/_f_sdf/_f_sdf.old.png differ diff --git a/fonts/_f_sdf/_f_sdf.png b/fonts/_f_sdf/_f_sdf.png index ca4a04dfa..af0235be9 100644 Binary files a/fonts/_f_sdf/_f_sdf.png and b/fonts/_f_sdf/_f_sdf.png differ diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.old.png b/fonts/_f_sdf_medium/_f_sdf_medium.old.png index c40866dc8..f66d04899 100644 Binary files a/fonts/_f_sdf_medium/_f_sdf_medium.old.png and b/fonts/_f_sdf_medium/_f_sdf_medium.old.png differ diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.png b/fonts/_f_sdf_medium/_f_sdf_medium.png index f66d04899..af596078b 100644 Binary files a/fonts/_f_sdf_medium/_f_sdf_medium.png and b/fonts/_f_sdf_medium/_f_sdf_medium.png differ diff --git a/objects/o_dialog_gradient/Draw_64.gml b/objects/o_dialog_gradient/Draw_64.gml index 002a0d415..9a8f0132f 100644 --- a/objects/o_dialog_gradient/Draw_64.gml +++ b/objects/o_dialog_gradient/Draw_64.gml @@ -104,9 +104,10 @@ if !ready exit; if(buttonInstant(THEME.button_hide, bx, by, ui(28), ui(28), mouse_ui, interactable && sFOCUS, sHOVER, __txtx("gradient_editor_key_blend", "Key blending"), THEME.grad_blend) == 2) { menuCall("gradient_window_blend_menu", bx + ui(32), by, [ - menuItem(__txtx("gradient_editor_blend_RGB", "RGB blend"), function() { gradient.type = 0; onApply(gradient); }), - menuItem(__txtx("gradient_editor_blend_HSV", "HSV blend"), function() { gradient.type = 2; onApply(gradient); }), - menuItem(__txtx("gradient_editor_blend_hard", "Hard blend"), function() { gradient.type = 1; onApply(gradient); }), + menuItem(__txtx("gradient_editor_blend_hard", "Hard blend"), function() { gradient.type = 1; onApply(gradient); }), + menuItem(__txtx("gradient_editor_blend_RGB", "RGB blend"), function() { gradient.type = 0; onApply(gradient); }), + menuItem(__txtx("gradient_editor_blend_HSV", "HSV blend"), function() { gradient.type = 2; onApply(gradient); }), + menuItem(__txtx("gradient_editor_blend_OKLAB", "OKLAB blend"), function() { gradient.type = 3; onApply(gradient); }), ],, gradient); } bx -= ui(32); diff --git a/scripts/__matrix3/__matrix3.gml b/scripts/__matrix3/__matrix3.gml index a8a08b307..e80ab343b 100644 --- a/scripts/__matrix3/__matrix3.gml +++ b/scripts/__matrix3/__matrix3.gml @@ -1,9 +1,9 @@ -function __mat3() constructor { - raw = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; +function __mat3(raw = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]) constructor { + self.raw = raw; static det = function() { - return raw[0]*raw[4]*raw[8] + raw[1]*raw[5]*raw[6] + raw[2]*raw[3]*raw[7] - - raw[2]*raw[4]*raw[6] - raw[0]*raw[5]*raw[7] - raw[1]*raw[3]*raw[8]; + return raw[0] * raw[4] * raw[8] + raw[1] * raw[5] * raw[6] + raw[2] * raw[3] * raw[7] + - raw[2] * raw[4] * raw[6] - raw[0] * raw[5] * raw[7] - raw[1] * raw[3] * raw[8]; }; static multiplyMatrix = function(matrix) { diff --git a/scripts/color_function/color_function.gml b/scripts/color_function/color_function.gml index 848b7418d..854f13f76 100644 --- a/scripts/color_function/color_function.gml +++ b/scripts/color_function/color_function.gml @@ -1,70 +1,129 @@ -function cola(color, alpha = 1) { INLINE return int64((color & 0xFFFFFF) + (round(alpha * 255) << 24)); } -function _cola(color, alpha) { INLINE return int64((color & 0xFFFFFF) + (alpha << 24)); } -function colda(color) { INLINE return real(color & 0xFFFFFF); } - -function colorFromRGBArray(arr) { #region - var r = round(real(arr[0]) * 255); - var g = round(real(arr[1]) * 255); - var b = round(real(arr[2]) * 255); - return make_color_rgb(r, g, b); -} #endregion - -function color_get_alpha(color) { INLINE return is_real(color)? 255 : (color & (0xFF << 24)) >> 24; } -function _color_get_alpha(color) { INLINE return is_real(color)? 1 : color_get_alpha(color) / 255; } - -function _color_get_red(color) { INLINE return color_get_red(color) / 255; } -function _color_get_green(color) { INLINE return color_get_green(color) / 255; } -function _color_get_blue(color) { INLINE return color_get_blue(color) / 255; } - -function _color_get_hue(color) { INLINE return color_get_hue(color) / 255; } -function _color_get_saturation(color) { INLINE return color_get_saturation(color) / 255; } -function _color_get_value(color) { INLINE return color_get_value(color) / 255; } - -function colorArrayFromReal(clr) { #region - INLINE - return [ _color_get_red(clr), _color_get_green(clr), _color_get_blue(clr) ]; -} #endregion - -function paletteToArray(_pal) { #region - var _colors = array_create(array_length(_pal) * 4); - for(var i = 0; i < array_length(_pal); i++) { - _colors[i * 4 + 0] = _color_get_red(_pal[i]); - _colors[i * 4 + 1] = _color_get_green(_pal[i]); - _colors[i * 4 + 2] = _color_get_blue(_pal[i]); - _colors[i * 4 + 3] = _color_get_alpha(_pal[i]); - } +#region channels + function cola(color, alpha = 1) { INLINE return int64((color & 0xFFFFFF) + (round(alpha * 255) << 24)); } + function _cola(color, alpha) { INLINE return int64((color & 0xFFFFFF) + (alpha << 24)); } + function colda(color) { INLINE return real(color & 0xFFFFFF); } - return _colors; -} #endregion + function color_get_alpha(color) { INLINE return is_real(color)? 255 : (color & (0xFF << 24)) >> 24; } + function _color_get_alpha(color) { INLINE return is_real(color)? 1 : color_get_alpha(color) / 255; } -function colorBrightness(clr, normalize = true) { #region - INLINE - var r2 = color_get_red(clr) / (normalize? 255 : 1); - var g2 = color_get_green(clr) / (normalize? 255 : 1); - var b2 = color_get_blue(clr) / (normalize? 255 : 1); - return 0.299 * r2 + 0.587 * g2 + 0.224 * b2; -} #endregion + function _color_get_red(color) { INLINE return color_get_red(color) / 255; } + function _color_get_green(color) { INLINE return color_get_green(color) / 255; } + function _color_get_blue(color) { INLINE return color_get_blue(color) / 255; } -function colorMultiply(c1, c2) { #region - if(c1 * c2 == 0) return 0; - if(c1 == c_white) return c2; - if(c2 == c_white) return c1; - - var r1 = _color_get_red(c1); - var g1 = _color_get_green(c1); - var b1 = _color_get_blue(c1); - var a1 = _color_get_alpha(c1); - - var r2 = _color_get_red(c2); - var g2 = _color_get_green(c2); - var b2 = _color_get_blue(c2); - var a2 = _color_get_alpha(c2); - - if(is_real(c1)) return make_color_rgb((r1 * r2) * 255, (g1 * g2) * 255, (b1 * b2) * 255); - return make_color_rgba((r1 * r2) * 255, (g1 * g2) * 255, (b1 * b2) * 255, (a1 * a2) * 255); -} #endregion + function _color_get_hue(color) { INLINE return color_get_hue(color) / 255; } + function _color_get_saturation(color) { INLINE return color_get_saturation(color) / 255; } + function _color_get_value(color) { INLINE return color_get_value(color) / 255; } +#endregion -function colorAdd(c1, c2) { #region +#region conversions + function make_color_rgba(r, g, b, a) { INLINE return int64(round(r) + (round(g) << 8) + (round(b) << 16) + (round(a) << 24)); } + + function make_color_hsva(h, s, v, a) { INLINE return _cola(make_color_hsv(h, s, v), a); } + + function make_color_oklab(ok, a = 1) { #region + INLINE + var k = new __vec3(ok[0], ok[1], ok[2]); + k.x = power(k.x, 3); + k.y = power(k.y, 3); + k.z = power(k.z, 3); + + var rg = global.CVTMAT_OKLAB_RGB.multiplyVector(k); + rg.x = power(rg.x, 1 / 2.2); + rg.y = power(rg.y, 1 / 2.2); + rg.z = power(rg.z, 1 / 2.2); + + return make_color_rgba(rg.x, rg.y, rg.z, a); + } #endregion + + function colorFromRGBArray(arr) { #region + var r = round(real(arr[0]) * 255); + var g = round(real(arr[1]) * 255); + var b = round(real(arr[2]) * 255); + return make_color_rgb(r, g, b); + } #endregion + + function colorArrayFromReal(clr) { #region + INLINE + return [ _color_get_red(clr), _color_get_green(clr), _color_get_blue(clr) ]; + } #endregion + + function paletteToArray(_pal) { #region + var _colors = array_create(array_length(_pal) * 4); + for(var i = 0; i < array_length(_pal); i++) { + _colors[i * 4 + 0] = _color_get_red(_pal[i]); + _colors[i * 4 + 1] = _color_get_green(_pal[i]); + _colors[i * 4 + 2] = _color_get_blue(_pal[i]); + _colors[i * 4 + 3] = _color_get_alpha(_pal[i]); + } + + return _colors; + } #endregion +#endregion + +#region color spaces + function color_rgb(col) { #region + INLINE + return [ color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255 ]; + } #endregion + + function color_hsv(col) { #region + INLINE + return [ color_get_hue(col) / 255, color_get_saturation(col) / 255, color_get_value(col) / 255 ]; + } #endregion + + global.CVTMAT_RGB_OKLAB = new __mat3([ 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616 ]); + + global.CVTMAT_OKLAB_RGB = new __mat3([ 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689 ]); + + function color_oklab(col) { #region + INLINE + var v = new __vec3(color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255); + v.x = power(v.x, 2.2); + v.y = power(v.y, 2.2); + v.z = power(v.z, 2.2); + + var ok = global.CVTMAT_RGB_OKLAB.multiplyVector(v); + ok.x = power(ok.x, 1 / 3); + ok.y = power(ok.y, 1 / 3); + ok.z = power(ok.z, 1 / 3); + + return [ ok.x, ok.y, ok.z ]; + } #endregion +#endregion + +#region data + function colorBrightness(clr, normalize = true) { #region + INLINE + var r2 = color_get_red(clr) / (normalize? 255 : 1); + var g2 = color_get_green(clr) / (normalize? 255 : 1); + var b2 = color_get_blue(clr) / (normalize? 255 : 1); + return 0.299 * r2 + 0.587 * g2 + 0.224 * b2; + } #endregion + + function colorMultiply(c1, c2) { #region + if(c1 * c2 == 0) return 0; + if(c1 == c_white) return c2; + if(c2 == c_white) return c1; + + var r1 = _color_get_red(c1); + var g1 = _color_get_green(c1); + var b1 = _color_get_blue(c1); + var a1 = _color_get_alpha(c1); + + var r2 = _color_get_red(c2); + var g2 = _color_get_green(c2); + var b2 = _color_get_blue(c2); + var a2 = _color_get_alpha(c2); + + if(is_real(c1)) return make_color_rgb((r1 * r2) * 255, (g1 * g2) * 255, (b1 * b2) * 255); + return make_color_rgba((r1 * r2) * 255, (g1 * g2) * 255, (b1 * b2) * 255, (a1 * a2) * 255); + } #endregion + + function colorAdd(c1, c2) { #region if(c1 == 0) return c2; if(c2 == 0) return c1; @@ -78,6 +137,7 @@ function colorAdd(c1, c2) { #region return make_color_rgb(min(r1 + r2, 255), min(g1 + g2, 255), min(b1 + b2, 255)); } #endregion +#endregion function color_diff(c1, c2, fast = false, alpha = false) { #region var _c1_r = color_get_red(c1); @@ -104,49 +164,55 @@ function color_diff(c1, c2, fast = false, alpha = false) { #region return sqrt(sqr(_c1_r - _c2_r) + sqr(_c1_g - _c2_g) + sqr(_c1_b - _c2_b) + sqr(_c1_a - _c2_a)); } #endregion -function color_get_brightness(col) { #region - INLINE - return (0.299 * color_get_red(col) + 0.587 * color_get_green(col) + 0.114 * color_get_blue(col)) / 255; -} #endregion +#region merge + #macro merge_color merge_color_ext + #macro __merge_color merge_color -function color_rgb(col) { #region - INLINE - return [ color_get_red(col) / 255, color_get_green(col) / 255, color_get_blue(col) / 255 ]; -} #endregion - -function make_color_rgba(r, g, b, a) { INLINE return int64(round(r) + (round(g) << 8) + (round(b) << 16) + (round(a) << 24)); } -function make_color_hsva(h, s, v, a) { INLINE return _cola(make_color_hsv(h, s, v), a); } - -#macro merge_color merge_color_ext -#macro __merge_color merge_color - -function merge_color_ext(c0, c1, t) { #region - INLINE - if(is_real(c0)) return __merge_color(c0, c1, t); + function merge_color_ext(c0, c1, t) { #region + INLINE + if(is_real(c0)) return __merge_color(c0, c1, t); - return make_color_rgba( - clamp(round(lerp(color_get_red(c0), color_get_red(c1), t)), 0, 255), - clamp(round(lerp(color_get_green(c0), color_get_green(c1), t)), 0, 255), - clamp(round(lerp(color_get_blue(c0), color_get_blue(c1), t)), 0, 255), - clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255), - ); -} #endregion + return make_color_rgba( + clamp(round(lerp(color_get_red(c0), color_get_red(c1), t)), 0, 255), + clamp(round(lerp(color_get_green(c0), color_get_green(c1), t)), 0, 255), + clamp(round(lerp(color_get_blue(c0), color_get_blue(c1), t)), 0, 255), + clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255), + ); + } #endregion -function merge_color_hsv(c0, c1, t) { #region - INLINE - if(is_real(c0)) return make_color_hsv( - clamp(round(lerp(color_get_hue(c0), color_get_hue(c1), t)), 0, 255), - clamp(round(lerp(color_get_saturation(c0), color_get_saturation(c1), t)), 0, 255), - clamp(round(lerp(color_get_value(c0), color_get_value(c1), t)), 0, 255), - ); + function merge_color_hsv(c0, c1, t) { #region + INLINE + if(is_real(c0)) return make_color_hsv( + clamp(round(lerp(color_get_hue(c0), color_get_hue(c1), t)), 0, 255), + clamp(round(lerp(color_get_saturation(c0), color_get_saturation(c1), t)), 0, 255), + clamp(round(lerp(color_get_value(c0), color_get_value(c1), t)), 0, 255), + ); - return make_color_hsva( - clamp(round(lerp(color_get_hue(c0), color_get_hue(c1), t)), 0, 255), - clamp(round(lerp(color_get_saturation(c0), color_get_saturation(c1), t)), 0, 255), - clamp(round(lerp(color_get_value(c0), color_get_value(c1), t)), 0, 255), - clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255), - ); -} #endregion + return make_color_hsva( + clamp(round(lerp(color_get_hue(c0), color_get_hue(c1), t)), 0, 255), + clamp(round(lerp(color_get_saturation(c0), color_get_saturation(c1), t)), 0, 255), + clamp(round(lerp(color_get_value(c0), color_get_value(c1), t)), 0, 255), + clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255), + ); + } #endregion + + function merge_color_oklab(c0, c1, t) { #region + INLINE + + var ok0 = color_oklab(c0); + var ok1 = color_oklab(c1); + + var ok = [ + lerp(ok0[0], ok1[0], t), + lerp(ok0[1], ok1[1], t), + lerp(ok0[2], ok1[2], t), + ]; + + var a = is_real(c0)? 255 : clamp(round(lerp(color_get_alpha(c0), color_get_alpha(c1), t)), 0, 255); + + return make_color_oklab(ok, a); + } #endregion +#endregion #region sorting functions function __valHSV(c, h, s, v) { return color_get_hue(c) * h + color_get_saturation(c) * s + color_get_value(c) * v; } diff --git a/scripts/d3d_rot3/d3d_rot3.gml b/scripts/d3d_rot3/d3d_rot3.gml index 404ac252f..d83fdf3eb 100644 --- a/scripts/d3d_rot3/d3d_rot3.gml +++ b/scripts/d3d_rot3/d3d_rot3.gml @@ -16,25 +16,17 @@ function __rot3(_x = 0, _y = 0, _z = 0) constructor { var _y = degtorad( y); var _z = degtorad(-z); - var rotationMatrix = new __mat3(); - var cosX = cos(_x); var sinX = sin(_x); var cosY = cos(_y); var sinY = sin(_y); var cosZ = cos(_z); var sinZ = sin(_z); - - rotationMatrix.raw[0][0] = cosY * cosZ; - rotationMatrix.raw[0][1] = -cosX * sinZ + sinX * sinY * cosZ; - rotationMatrix.raw[0][2] = sinX * sinZ + cosX * sinY * cosZ; - rotationMatrix.raw[1][0] = cosY * sinZ; - rotationMatrix.raw[1][1] = cosX * cosZ + sinX * sinY * sinZ; - rotationMatrix.raw[1][2] = -sinX * cosZ + cosX * sinY * sinZ; - rotationMatrix.raw[2][0] = -sinY; - rotationMatrix.raw[2][1] = sinX * cosY; - rotationMatrix.raw[2][2] = cosX * cosY; - + + var rotationMatrix = new __mat3([ cosY * cosZ, -cosX * sinZ + sinX * sinY * cosZ, sinX * sinZ + cosX * sinY * cosZ, + cosY * sinZ, cosX * cosZ + sinX * sinY * sinZ, -sinX * cosZ + cosX * sinY * sinZ, + -sinY, sinX * cosY, cosX * cosY ]); + var initialVector = new __vec3(1, 0, 0); var rotatedVector = rotationMatrix.multiplyVector(initialVector); rotatedVector.z *= -1; diff --git a/scripts/gradients_function/gradients_function.gml b/scripts/gradients_function/gradients_function.gml index ccd9d5645..e92d1f674 100644 --- a/scripts/gradients_function/gradients_function.gml +++ b/scripts/gradients_function/gradients_function.gml @@ -1,7 +1,8 @@ enum GRADIENT_INTER { smooth, none, - hue + hue, + oklab } function gradientKey(time, value) constructor { #region @@ -75,8 +76,9 @@ function gradientObject(color = c_black) constructor { #region var rat = (position - _pkey.time) / (_key.time - _pkey.time); switch(type) { - case GRADIENT_INTER.smooth : return merge_color (_pkey.value, _key.value, rat); - case GRADIENT_INTER.hue : return merge_color_hsv(_pkey.value, _key.value, rat); + case GRADIENT_INTER.smooth : return merge_color (_pkey.value, _key.value, rat); + case GRADIENT_INTER.hue : return merge_color_hsv (_pkey.value, _key.value, rat); + case GRADIENT_INTER.oklab : return merge_color_oklab(_pkey.value, _key.value, rat); case GRADIENT_INTER.none : return _pkey.value; } } diff --git a/scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.gml b/scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.gml index d8a463baf..47972be63 100644 --- a/scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.gml +++ b/scripts/node_3d_mesh_terrain/node_3d_mesh_terrain.gml @@ -48,7 +48,7 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr for( var i = 0; i < _sub + 1; i++ ) for( var j = 0; j < _sub + 1; j++ ) { var cc = surface_getpixel(_his, j * _pxw, i * _pxh); - _h[_ind] = color_get_brightness(cc); + _h[_ind] = colorBrightness(cc); _ind++; } } else if(_inT == 1 && !array_empty(_hia)) { diff --git a/scripts/node_color_mix/node_color_mix.gml b/scripts/node_color_mix/node_color_mix.gml index 0356c7ef1..3f73172a8 100644 --- a/scripts/node_color_mix/node_color_mix.gml +++ b/scripts/node_color_mix/node_color_mix.gml @@ -10,7 +10,7 @@ function Node_Color_Mix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) .setDisplay(VALUE_DISPLAY.slider); inputs[| 3] = nodeValue("Color space", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) - .setDisplay(VALUE_DISPLAY.enum_button, [ "RGB", "HSV" ]); + .setDisplay(VALUE_DISPLAY.enum_button, [ "RGB", "HSV", "OKLAB" ]); outputs[| 0] = nodeValue("Color", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, c_white); @@ -20,6 +20,7 @@ function Node_Color_Mix(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) switch(_data[3]) { case 0 : return merge_color_ext(_data[0], _data[1], _data[2]); case 1 : return merge_color_hsv(_data[0], _data[1], _data[2]); + case 2 : return merge_color_oklab(_data[0], _data[1], _data[2]); } } diff --git a/scripts/node_displacement/node_displacement.gml b/scripts/node_displacement/node_displacement.gml index 8cce4686c..738dbcb32 100644 --- a/scripts/node_displacement/node_displacement.gml +++ b/scripts/node_displacement/node_displacement.gml @@ -3,9 +3,9 @@ function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); - inputs[| 1] = nodeValue("Displace map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); + inputs[| 1] = nodeValue("Displace map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); - inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [1, 0], "Vector to displace pixel by." ) + inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 1, 0 ], "Vector to displace pixel by." ) .setDisplay(VALUE_DISPLAY.vector) .setUnitRef(function(index) { return getDimension(index); }); @@ -15,11 +15,11 @@ function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) inputs[| 4] = nodeValue("Mid value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0., "Brightness value to be use as a basis for 'no displacement'.") .setDisplay(VALUE_DISPLAY.slider); - inputs[| 5] = nodeValue("Color data", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, @"Use color data set extra information. - - Ignore: Don't use color data. + inputs[| 5] = nodeValue("Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, @"Use color data for extra information. + - Linear: Displace along a line. - Vector: Use red as X displacement, green as Y displacement. - Angle: Use red as angle, green as distance.") - .setDisplay(VALUE_DISPLAY.enum_button, [ "Ignore", "Vector", "Angle" ]); + .setDisplay(VALUE_DISPLAY.enum_button, [ "Linear", "Vector", "Angle" ]); inputs[| 6] = nodeValue("Iterate", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false, @"If not set, then strength value is multiplied directly to the displacement. If set, then strength value control how many times the effect applies on itself."); @@ -50,11 +50,15 @@ If set, then strength value control how many times the effect applies on itself. //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + inputs[| 16] = nodeValue("Separate axis", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); + + inputs[| 17] = nodeValue("Displace map 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); + input_display_list = [ 10, 12, - ["Surfaces", true], 0, 8, 9, 13, 14, - ["Displace", false], 1, 3, 15, 4, - ["Color", false], 5, 2, - ["Algorithm", true], 6, 11, + ["Surfaces", true], 0, 8, 9, 13, 14, + ["Strength", false], 1, 17, 3, 15, 4, + ["Displacement", false], 5, 16, 2, + ["Algorithm", true], 6, 11, ]; outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -65,9 +69,26 @@ If set, then strength value control how many times the effect applies on itself. static step = function() { #region __step_mask_modifier(); - - inputs[| 2].setVisible(getInputData(5) == 0); inputs[| 3].mappableStep(); + + var _mode = getInputData(5); + var _sep = getInputData(16); + + inputs[| 2].setVisible(_mode == 0); + inputs[| 16].setVisible(_mode); + inputs[| 17].setVisible(_mode && _sep); + + if(_mode == 1 && _sep) { + inputs[| 1].setName("Displace X"); + inputs[| 17].setName("Displace Y"); + + } else if(_mode == 2 && _sep) { + inputs[| 1].setName("Displace angle"); + inputs[| 17].setName("Displace amount"); + + } else { + inputs[| 1].setName("Displace map"); + } } #endregion static processData = function(_outSurf, _data, _output_index, _array_index) { #region @@ -78,15 +99,18 @@ If set, then strength value control how many times the effect applies on itself. surface_set_shader(_outSurf, sh_displace); shader_set_interpolation(_data[0]); - shader_set_surface("map", _data[1]); + shader_set_surface("map", _data[1]); + shader_set_surface("map2", _data[17]); + shader_set_f("dimension", [ww, hh]); shader_set_f("map_dimension", [mw, mh]); shader_set_f("displace", _data[ 2]); shader_set_f_map("strength", _data[ 3], _data[15], inputs[| 3]); shader_set_f("middle", _data[ 4]); - shader_set_i("use_rg", _data[ 5]); + shader_set_i("mode", _data[ 5]); shader_set_i("iterate", _data[ 6]); shader_set_i("blendMode", _data[11]); + shader_set_i("sepAxis", _data[16]); draw_surface_safe(_data[0]); surface_reset_shader(); diff --git a/scripts/node_gradient_palette/node_gradient_palette.gml b/scripts/node_gradient_palette/node_gradient_palette.gml index d698810d5..57b8f2066 100644 --- a/scripts/node_gradient_palette/node_gradient_palette.gml +++ b/scripts/node_gradient_palette/node_gradient_palette.gml @@ -12,8 +12,8 @@ function Node_Gradient_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y, .setVisible(true, true); inputs[| 2].array_depth = 1; - inputs[| 3] = nodeValue("Blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) - .setDisplay(VALUE_DISPLAY.enum_button, [ "RGB", "HSV", "Hard" ]); + inputs[| 3] = nodeValue("Blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1) + .setDisplay(VALUE_DISPLAY.enum_button, [ "Hard", "RGB", "HSV", "OKLAB" ]); outputs[| 0] = nodeValue("Gradient", self, JUNCTION_CONNECT.output, VALUE_TYPE.gradient, new gradientObject(c_white) ) @@ -42,9 +42,10 @@ function Node_Gradient_Palette(_x, _y, _group = noone) : Node_Processor(_x, _y, } switch(type) { - case 0 : grad.type = GRADIENT_INTER.smooth; break; - case 1 : grad.type = GRADIENT_INTER.hue; break; - case 2 : grad.type = GRADIENT_INTER.none; break; + case 0 : grad.type = GRADIENT_INTER.none; break; + case 1 : grad.type = GRADIENT_INTER.smooth; break; + case 2 : grad.type = GRADIENT_INTER.hue; break; + case 3 : grad.type = GRADIENT_INTER.oklab; break; } return grad; diff --git a/scripts/node_quasicrystal/node_quasicrystal.gml b/scripts/node_quasicrystal/node_quasicrystal.gml new file mode 100644 index 000000000..72c7954c6 --- /dev/null +++ b/scripts/node_quasicrystal/node_quasicrystal.gml @@ -0,0 +1,93 @@ +function Node_Quasicrystal(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { + name = "Quasicrystal"; + + inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF ) + .setDisplay(VALUE_DISPLAY.vector); + + inputs[| 1] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 16) + .setDisplay(VALUE_DISPLAY.slider, { range: [1, 64, 0.1] }) + .setMappable(6); + + inputs[| 2] = nodeValue("Angle", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0) + .setDisplay(VALUE_DISPLAY.rotation) + .setMappable(7); + + inputs[| 3] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 0 ] ) + .setDisplay(VALUE_DISPLAY.vector) + .setUnitRef(function(index) { return getDimension(index); }); + + inputs[| 4] = nodeValue("Color 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white); + + inputs[| 5] = nodeValue("Color 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + + inputs[| 6] = nodeValueMap("Scale map", self); + + inputs[| 7] = nodeValueMap("Angle map", self); + + ////////////////////////////////////////////////////////////////////////////////////////////////// + + inputs[| 8] = nodeValue("Phase", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) + .setDisplay(VALUE_DISPLAY.slider) + .setMappable(8); + + inputs[| 9] = nodeValueMap("Phasemap", self); + + inputs[| 10] = nodeValue("Angle Range", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 180 ]) + .setDisplay(VALUE_DISPLAY.rotation_range); + + outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); + + input_display_list = [ + ["Output", true], 0, + ["Pattern", false], 1, 6, 2, 7, 8, 9, 10, + ["Colors", false], 4, 5, + ]; + + attribute_surface_depth(); + + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region + var pos = getInputData(3); + var px = _x + pos[0] * _s; + var py = _y + pos[1] * _s; + + var a = inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); active &= !a; + var a = inputs[| 2].drawOverlay(active, px, py, _s, _mx, _my, _snx, _sny); active &= !a; + } #endregion + + static step = function() { #region + inputs[| 1].mappableStep(); + inputs[| 2].mappableStep(); + inputs[| 8].mappableStep(); + } #endregion + + static processData = function(_outSurf, _data, _output_index, _array_index) { #region + var _dim = _data[ 0]; + var _fre = _data[ 1]; + var _ang = _data[ 2]; + var _pos = _data[ 3]; + var _clr0 = _data[ 4]; + var _clr1 = _data[ 5]; + var _aran = _data[10]; + + _outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth()); + + surface_set_shader(_outSurf, sh_quarsicrystal); + shader_set_f("dimension", _dim[0], _dim[1]); + shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]); + shader_set_f("rangleRange", _aran); + + shader_set_f_map("amount", _data[1], _data[6], inputs[| 1]); + shader_set_f_map("angle", _data[2], _data[7], inputs[| 2]); + shader_set_f_map("phase", _data[8], _data[9], inputs[| 8]); + + shader_set_color("color0", _clr0); + shader_set_color("color1", _clr1); + + draw_sprite_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], 0, c_white, 1); + surface_reset_shader(); + + return _outSurf; + } #endregion +} \ No newline at end of file diff --git a/scripts/node_quasicrystal/node_quasicrystal.yy b/scripts/node_quasicrystal/node_quasicrystal.yy new file mode 100644 index 000000000..028b09dc7 --- /dev/null +++ b/scripts/node_quasicrystal/node_quasicrystal.yy @@ -0,0 +1,11 @@ +{ + "resourceType": "GMScript", + "resourceVersion": "1.0", + "name": "node_quasicrystal", + "isCompatibility": false, + "isDnD": false, + "parent": { + "name": "pattern", + "path": "folders/nodes/data/generator/pattern.yy", + }, +} \ No newline at end of file diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 1bc33c112..8b2de963b 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -538,7 +538,7 @@ function __initNodes() { addNodeObject(filter, "Chromatic Aberration", s_node_chromatic_abarration, "Node_Chromatic_Aberration", [1, Node_Chromatic_Aberration],, "Apply chromatic aberration effect to the image."); addNodeObject(filter, "Vignette", s_node_vignette, "Node_Vignette", [1, Node_Vignette],, "Apply vignette effect to the border.").setVersion(11630); addNodeObject(filter, "FXAA", s_node_FXAA, "Node_FXAA", [1, Node_FXAA],, "Apply fast approximate anti-aliasing to the image."); - addNodeObject(filter, "Kuwahara", s_node_kuwahara, "Node_Kuwahara", [1, Node_Kuwahara]); + addNodeObject(filter, "Kuwahara", s_node_kuwahara, "Node_Kuwahara", [1, Node_Kuwahara]).setVersion(11660); //addNodeObject(filter, "Blend Edge", s_node_FXAA, "Node_Blend_Edge", [1, Node_Blend_Edge]).setVersion(11640); ds_list_add(filter, "Colors"); @@ -657,6 +657,7 @@ function __initNodes() { addNodeObject(generator, "Pytagorean Tile", s_node_pytagorean_tile, "Node_Pytagorean_Tile", [1, Node_Pytagorean_Tile],, "Generate Pytagorean tile pattern.").patreonExtra(); addNodeObject(generator, "Herringbone Tile", s_node_herringbone_tile, "Node_Herringbone_Tile", [1, Node_Herringbone_Tile],, "Generate Herringbone tile pattern.").patreonExtra(); addNodeObject(generator, "Random Tile", s_node_random_tile, "Node_Random_Tile", [1, Node_Random_Tile],, "Generate Random tile pattern.").patreonExtra(); + addNodeObject(generator, "Quasicrystal", s_node_random_tile, "Node_Quasicrystal", [1, Node_Quasicrystal]).setVersion(11660); ds_list_add(generator, "Populate"); addNodeObject(generator, "Repeat", s_node_repeat, "Node_Repeat", [1, Node_Repeat],, "Repeat image multiple times linearly, or in grid pattern.").setVersion(1100); diff --git a/scripts/node_scatter/node_scatter.gml b/scripts/node_scatter/node_scatter.gml index a9b4e556e..c48e32ada 100644 --- a/scripts/node_scatter/node_scatter.gml +++ b/scripts/node_scatter/node_scatter.gml @@ -478,7 +478,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c case 1 : ind = safe_mod(i, _arrLen); break; case 2 : ind = irandom(_arrLen - 1); break; case 3 : ind = array_safe_get(arrId, i, 0); break; - case 4 : if(useArrTex) ind = color_get_brightness(surface_get_pixel(arrTex, _x, _y)) * (_arrLen - 1); break; + case 4 : if(useArrTex) ind = colorBrightness(surface_get_pixel(arrTex, _x, _y)) * (_arrLen - 1); break; } if(arrAnim[0] != 0 || arrAnim[1] != 0) { diff --git a/scripts/rotatorRandom/rotatorRandom.gml b/scripts/rotatorRandom/rotatorRandom.gml index 0bbcacaba..ac174c4b7 100644 --- a/scripts/rotatorRandom/rotatorRandom.gml +++ b/scripts/rotatorRandom/rotatorRandom.gml @@ -1,11 +1,13 @@ function rotatorRandom(_onModify) : widget() constructor { onModify = _onModify; - dragging = false; dragging_index = -1; + dragging = false; drag_sv = 0; drag_dat = [ 0, 0, 0, 0, 0 ]; + knob_hovering = noone; + mode = 0; tb_min_0 = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(1, val); } ).setSlidable(true, 1); tb_max_0 = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(2, val); } ).setSlidable(true, 1); @@ -46,6 +48,8 @@ function rotatorRandom(_onModify) : widget() constructor { w = _w; h = ui(80); + var _kHover = dragging_index; + _x += _w / 2; mode = _data[0]; @@ -111,7 +115,7 @@ function rotatorRandom(_onModify) : widget() constructor { draw_arc_width(knx, kny, _r, 3, _a0, _a1); for(var i = 0; i < 2; i++) - draw_sprite(THEME.rotator_knob, 0, px[i], py[i]); + draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]); #endregion if(dragging_index > -1) { #region @@ -139,8 +143,6 @@ function rotatorRandom(_onModify) : widget() constructor { var curr_val = round(dragging.delta_acc + drag_sv); val = key_mod_press(CTRL)? round(curr_val / 15) * 15 : curr_val; - draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]); - if(_data[dragging_index] != val) { var modi = false; modi |= onModify(1 + dragging_index, val); @@ -175,7 +177,7 @@ function rotatorRandom(_onModify) : widget() constructor { for(var i = 0; i < 2; i++) { if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) { - draw_sprite(THEME.rotator_knob, 1, px[i], py[i]); + _kHover = i; if(mouse_press(mb_left, active)) { dragging_index = i; @@ -221,7 +223,7 @@ function rotatorRandom(_onModify) : widget() constructor { draw_arc_width(knx, kny, _r, 3, _a0, _a1); for( var i = 0; i < 3; i++ ) - draw_sprite(THEME.rotator_knob, 0, px[i], py[i]); + draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]); #endregion if(dragging_index > -1) { #region @@ -235,15 +237,11 @@ function rotatorRandom(_onModify) : widget() constructor { real_val[1] = round(dragging.delta_acc + drag_sv[1]); val = key_mod_press(CTRL)? round(real_val[1] / 15) * 15 : real_val[1]; - draw_sprite(THEME.rotator_knob, 1, px[2], py[2]); - if(onModify(1, val)) UNDO_HOLDING = true; } else { real_val[2] = round(drag_sv[2] + (dragging.delta_acc * (dragging_index? 1 : -1))); val = key_mod_press(CTRL)? round(real_val[2] / 15) * 15 : real_val[2]; - draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]); - if(onModify(2, val)) UNDO_HOLDING = true; } @@ -267,7 +265,7 @@ function rotatorRandom(_onModify) : widget() constructor { } else if(hover) { #region for(var i = 0; i < 3; i++) { if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) { - draw_sprite(THEME.rotator_knob, 1, px[i], py[i]); + _kHover = i; if(mouse_press(mb_left, active)) { dragging_index = i; @@ -314,7 +312,7 @@ function rotatorRandom(_onModify) : widget() constructor { draw_arc_width(knx, kny, _r, 3, _a2, _a3); for( var i = 0; i < 4; i++ ) - draw_sprite(THEME.rotator_knob, 0, px[i], py[i]); + draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]); #endregion if(dragging_index > -1) { #region @@ -328,8 +326,6 @@ function rotatorRandom(_onModify) : widget() constructor { real_val[ind] = round(drag_sv[ind] + (dragging.delta_acc * (ind? 1 : -1))); val = key_mod_press(CTRL)? round(real_val[ind] / 15) * 15 : real_val[ind]; - draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]); - if(onModify(ind, val)) UNDO_HOLDING = true; MOUSE_BLOCK = true; @@ -352,7 +348,7 @@ function rotatorRandom(_onModify) : widget() constructor { } else if(hover) { #region for(var i = 0; i < 4; i++) { if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) { - draw_sprite(THEME.rotator_knob, 1, px[i], py[i]); + _kHover = i; if(mouse_press(mb_left, active)) { dragging_index = i; @@ -405,8 +401,8 @@ function rotatorRandom(_onModify) : widget() constructor { draw_arc_width(knx, kny, _r, 3, _a2, _a3); draw_arc_width(knx, kny, _r, 3, _a4, _a5); - draw_sprite(THEME.rotator_knob, 0, px[0], py[0]); - draw_sprite(THEME.rotator_knob, 0, px[1], py[1]); + for( var i = 0; i < 2; i++ ) + draw_sprite(THEME.rotator_knob, i == knob_hovering, px[i], py[i]); #endregion if(dragging_index > -1) { #region @@ -420,8 +416,6 @@ function rotatorRandom(_onModify) : widget() constructor { real_val[ind] = round(drag_sv[ind] + (dragging.delta_acc * (ind? 1 : -1))); val = key_mod_press(CTRL)? round(real_val[ind] / 15) * 15 : real_val[ind]; - draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]); - if(onModify(ind, val)) UNDO_HOLDING = true; MOUSE_BLOCK = true; @@ -444,7 +438,7 @@ function rotatorRandom(_onModify) : widget() constructor { } else if(hover) { #region for(var i = 0; i < 2; i++) { if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) { - draw_sprite(THEME.rotator_knob, 1, px[i], py[i]); + _kHover = i; if(mouse_press(mb_left, active)) { dragging_index = i; @@ -459,6 +453,7 @@ function rotatorRandom(_onModify) : widget() constructor { break; } + knob_hovering = _kHover; resetFocus(); return h; diff --git a/scripts/rotatorRange/rotatorRange.gml b/scripts/rotatorRange/rotatorRange.gml index 0212c1791..560af3db8 100644 --- a/scripts/rotatorRange/rotatorRange.gml +++ b/scripts/rotatorRange/rotatorRange.gml @@ -6,6 +6,8 @@ function rotatorRange(_onModify) : widget() constructor { drag_sv = 0; drag_dat = [ 0, 0 ]; + knob_hovering = noone; + tb_min = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(0, val); } ).setSlidable(); tb_max = new textBox(TEXTBOX_INPUT.number, function(val) { return onModify(1, val); } ).setSlidable(); @@ -31,6 +33,7 @@ function rotatorRange(_onModify) : widget() constructor { w = _w; h = ui(64); + knob_hovering = dragging_index; _x += _w / 2; if(!is_real(_data[0])) return; @@ -72,9 +75,6 @@ function rotatorRange(_onModify) : widget() constructor { draw_set_color(hover_arc? COLORS.widget_rotator_range_hover : COLORS.widget_rotator_range); draw_arc_forward(_x, knob_y, _r, 3, _data[0], _data[1]); #endregion - - for(var i = 0; i < 2; i++) - draw_sprite(THEME.rotator_knob, 0, px[i], py[i]); if(dragging_index > -1) { #region var val = point_direction(_x, knob_y, _m[0], _m[1]); @@ -100,8 +100,6 @@ function rotatorRange(_onModify) : widget() constructor { real_val = round(dragging.delta_acc + drag_sv); val = key_mod_press(CTRL)? round(real_val / 15) * 15 : real_val; - draw_sprite(THEME.rotator_knob, 1, px[dragging_index], py[dragging_index]); - if(_data[dragging_index] != val) { var modi = false; modi |= onModify(dragging_index, val); @@ -132,10 +130,11 @@ function rotatorRange(_onModify) : widget() constructor { UNDO_HOLDING = false; } #endregion + } else if(hover) { #region for(var i = 0; i < 2; i++) { if(point_in_circle(_m[0], _m[1], px[i], py[i], ui(20))) { - draw_sprite(THEME.rotator_knob, 1, px[i], py[i]); + knob_hovering = i; if(mouse_press(mb_left, active)) { dragging_index = i; @@ -153,6 +152,9 @@ function rotatorRange(_onModify) : widget() constructor { } } #endregion + for(var i = 0; i < 2; i++) + draw_sprite(THEME.rotator_knob, knob_hovering == i, px[i], py[i]); + resetFocus(); return h; diff --git a/shaders/sh_colorize/sh_colorize.fsh b/shaders/sh_colorize/sh_colorize.fsh index 2b19fb457..222bf4469 100644 --- a/shaders/sh_colorize/sh_colorize.fsh +++ b/shaders/sh_colorize/sh_colorize.fsh @@ -1,89 +1,128 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -#define GRADIENT_LIMIT 128 -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; - uniform int multiply_alpha; uniform vec2 gradient_shift; uniform int gradient_shiftUseSurf; uniform sampler2D gradient_shiftSurf; -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// void main() { #region float shf = gradient_shift.x; diff --git a/shaders/sh_displace/sh_displace.fsh b/shaders/sh_displace/sh_displace.fsh index ace17f3da..040bb6f6a 100644 --- a/shaders/sh_displace/sh_displace.fsh +++ b/shaders/sh_displace/sh_displace.fsh @@ -1,18 +1,18 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; uniform sampler2D map; +uniform sampler2D map2; + uniform vec2 dimension; uniform vec2 map_dimension; uniform vec2 displace; uniform float middle; uniform int iterate; -uniform int use_rg; +uniform int mode; uniform int sampleMode; uniform int blendMode; +uniform int sepAxis; uniform vec2 strength; uniform int strengthUseSurf; @@ -87,14 +87,31 @@ vec2 shiftMap(in vec2 pos, in float str) { #region vec2 sam_pos; vec2 raw_displace = displace / dimension; float _str; + vec2 _disp; - if(use_rg == 1) { - vec2 _disp = vec2(disP.r - middle, disP.g - middle) * vec2((disP.r + disP.g + disP.b) / 3. - middle) * str; + if(mode == 1) { + if(sepAxis == 0) + _disp = vec2(disP.r - middle, disP.g - middle) * vec2((disP.r + disP.g + disP.b) / 3. - middle) * str; + else if(sepAxis == 1) { + vec4 disP2 = texture2Dintp( map2, pos ); + + _disp.x = (bright(disP) - middle) * str; + _disp.y = (bright(disP2) - middle) * str; + } sam_pos = pos + _disp; - } else if(use_rg == 2) { - float _ang = disP.r * PI * 2.; - _str = (disP.g - middle) * str; + } else if(mode == 2) { + float _ang; + + if(sepAxis == 0) { + _ang = disP.r * PI * 2.; + _str = (disP.g - middle) * str; + } else if(sepAxis == 1) { + vec4 disP2 = texture2Dintp( map2, pos ); + + _ang = bright(disP) * PI * 2.; + _str = (bright(disP2) - middle) * str; + } sam_pos = pos + _str * vec2(cos(_ang), sin(_ang)); } else { diff --git a/shaders/sh_edge_shade_apply/sh_edge_shade_apply.fsh b/shaders/sh_edge_shade_apply/sh_edge_shade_apply.fsh index 5e2b6bae4..42c388d8b 100644 --- a/shaders/sh_edge_shade_apply/sh_edge_shade_apply.fsh +++ b/shaders/sh_edge_shade_apply/sh_edge_shade_apply.fsh @@ -3,7 +3,7 @@ varying vec4 v_vColour; uniform vec2 dimension; -#region ////////////////////////////////////////////////////////////////// GRADIENT ////////////////////////////////////////////////////////////////// +#region //////////////////////////////////// GRADIENT //////////////////////////////////// #define GRADIENT_LIMIT 128 uniform int gradient_blend; @@ -14,6 +14,37 @@ uniform vec2 dimension; uniform vec4 gradient_map_range; uniform sampler2D gradient_map; + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion + + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion + vec3 rgb2hsv(vec3 c) { #region vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); @@ -65,15 +96,16 @@ uniform vec2 dimension; col = gradient_color[i]; else { float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + if(gradient_blend == 0) col = mix(gradient_color[i - 1], gradient_color[i], t); else if(gradient_blend == 1) col = gradient_color[i - 1]; else if(gradient_blend == 2) - col = vec4( - hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), - mix(gradient_color[i - 1].a, gradient_color[i].a, t) - ); + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); } break; } @@ -85,7 +117,8 @@ uniform vec2 dimension; return col; } #endregion -#endregion ////////////////////////////////////////////////////////////////// GRADIENT ////////////////////////////////////////////////////////////////// + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// void main() { vec2 tx = 1. / dimension; diff --git a/shaders/sh_gradient/sh_gradient.fsh b/shaders/sh_gradient/sh_gradient.fsh index 082444bbd..ab8074e5e 100644 --- a/shaders/sh_gradient/sh_gradient.fsh +++ b/shaders/sh_gradient/sh_gradient.fsh @@ -29,93 +29,122 @@ uniform int type; uniform int gradient_loop; uniform int uniAsp; -#region ////////////////////////////////////////// GRADIENT BEGIN ////////////////////////////////////////// - -#define GRADIENT_LIMIT 128 -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; - -vec3 rgb2hsv(vec3 c) { - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } - -vec3 hsv2rgb(vec3 c) { - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} - -float hueDist(float a0, float a1, float t) { - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); - float _ptime = 0.; + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(i >= gradient_keys) { - col = gradient_color[i - 1]; - break; + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); } - - float _time = gradient_time[i]; - - if(_time == prog) { - col = gradient_color[i]; - break; - } else if(_time > prog) { - if(i == 0) + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - _ptime) / (_time - _ptime); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - - _ptime = _time; - } - return col; -} - -#endregion ////////////////////////////////////////// GRADIENT END ////////////////////////////////////////// + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// void main() { #region params diff --git a/shaders/sh_gradient_display/sh_gradient_display.fsh b/shaders/sh_gradient_display/sh_gradient_display.fsh index 3c9bab93e..caab4ac42 100644 --- a/shaders/sh_gradient_display/sh_gradient_display.fsh +++ b/shaders/sh_gradient_display/sh_gradient_display.fsh @@ -1,82 +1,115 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; #define TAU 6.283185307179586 -#define GRADIENT_LIMIT 128 -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 -vec3 rgb2hsv(vec3 c) { - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } - -vec3 hsv2rgb(vec3 c) { - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} - -float hueDist(float a0, float a1, float t) { - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} - -vec4 gradientEval(in float prog) { - vec4 col = vec4(0.); - - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) - col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4( - hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), - mix(gradient_color[i - 1].a, gradient_color[i].a, t) - ); - } - break; - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); - if(i >= gradient_keys - 1) - return gradient_color[gradient_keys - 1]; - } + return c; + } #endregion - return col; -} + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion + + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { + col = gradient_color[i]; + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + + if(i >= gradient_keys - 1) + return gradient_color[gradient_keys - 1]; + } + + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// void main() { vec4 col = gradientEval(v_vTexcoord.x); diff --git a/shaders/sh_gradient_display_alpha/sh_gradient_display_alpha.fsh b/shaders/sh_gradient_display_alpha/sh_gradient_display_alpha.fsh index 202ad5bc4..cf6d3fc75 100644 --- a/shaders/sh_gradient_display_alpha/sh_gradient_display_alpha.fsh +++ b/shaders/sh_gradient_display_alpha/sh_gradient_display_alpha.fsh @@ -1,82 +1,115 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; #define TAU 6.283185307179586 -#define GRADIENT_LIMIT 128 -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); -} #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion - -vec4 gradientEval(in float prog) { #region - vec4 col = vec4(0.); - - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) - col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4( - hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), - mix(gradient_color[i - 1].a, gradient_color[i].a, t) - ); - } - break; - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); - if(i >= gradient_keys - 1) - return gradient_color[gradient_keys - 1]; - } + return c; + } #endregion - return col; -} #endregion + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion + + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { + col = gradient_color[i]; + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + + if(i >= gradient_keys - 1) + return gradient_color[gradient_keys - 1]; + } + + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// void main() { float a = gradientEval(v_vTexcoord.x).a; diff --git a/shaders/sh_grid/sh_grid.fsh b/shaders/sh_grid/sh_grid.fsh index 24754cf71..07f72ca19 100644 --- a/shaders/sh_grid/sh_grid.fsh +++ b/shaders/sh_grid/sh_grid.fsh @@ -35,7 +35,7 @@ uniform vec2 truchetAngle; float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } -#region ////////////////////////////////////////////////////////////////// GRADIENT ////////////////////////////////////////////////////////////////// +#region //////////////////////////////////// GRADIENT //////////////////////////////////// #define GRADIENT_LIMIT 128 uniform int gradient_blend; @@ -46,6 +46,37 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.5406 uniform vec4 gradient_map_range; uniform sampler2D gradient_map; + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion + + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion + vec3 rgb2hsv(vec3 c) { #region vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); @@ -97,15 +128,16 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.5406 col = gradient_color[i]; else { float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + if(gradient_blend == 0) col = mix(gradient_color[i - 1], gradient_color[i], t); else if(gradient_blend == 1) col = gradient_color[i - 1]; else if(gradient_blend == 2) - col = vec4( - hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), - mix(gradient_color[i - 1].a, gradient_color[i].a, t) - ); + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); } break; } @@ -117,7 +149,8 @@ float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.5406 return col; } #endregion -#endregion ////////////////////////////////////////////////////////////////// GRADIENT ////////////////////////////////////////////////////////////////// + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// void main() { #region #region params diff --git a/shaders/sh_grid_hex/sh_grid_hex.fsh b/shaders/sh_grid_hex/sh_grid_hex.fsh index 25163b7e6..f3aeeff2b 100644 --- a/shaders/sh_grid_hex/sh_grid_hex.fsh +++ b/shaders/sh_grid_hex/sh_grid_hex.fsh @@ -23,13 +23,6 @@ uniform sampler2D thickSurf; uniform vec4 gapCol; uniform int gradient_use; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; uniform int textureTruchet; uniform float truchetSeed; @@ -40,74 +33,122 @@ uniform vec2 truchetAngle; float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// float HexDist(vec2 p) { #region p = abs(p); diff --git a/shaders/sh_grid_tri/sh_grid_tri.fsh b/shaders/sh_grid_tri/sh_grid_tri.fsh index 18ed8e0ac..e41d78990 100644 --- a/shaders/sh_grid_tri/sh_grid_tri.fsh +++ b/shaders/sh_grid_tri/sh_grid_tri.fsh @@ -3,7 +3,6 @@ varying vec4 v_vColour; #define c30 (1.0 / 0.86602540378) #define PI 3.14159265359 -#define GRADIENT_LIMIT 128 uniform vec2 position; uniform vec2 dimension; @@ -25,13 +24,6 @@ uniform sampler2D widthSurf; uniform vec4 gapCol; uniform int gradient_use; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; uniform int textureTruchet; uniform float truchetSeed; @@ -40,74 +32,122 @@ uniform vec2 truchetAngle; float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); -} #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// vec3 triGrid(vec2 p){ #region float _stx = (p.x + c30 / 2.0 * p.y); diff --git a/shaders/sh_herringbone_tile/sh_herringbone_tile.fsh b/shaders/sh_herringbone_tile/sh_herringbone_tile.fsh index a3c7a8833..1e50b8815 100644 --- a/shaders/sh_herringbone_tile/sh_herringbone_tile.fsh +++ b/shaders/sh_herringbone_tile/sh_herringbone_tile.fsh @@ -1,8 +1,6 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -#define GRADIENT_LIMIT 128 - uniform vec2 dimension; uniform vec2 position; uniform float seed; @@ -23,13 +21,6 @@ uniform sampler2D thickSurf; uniform vec4 gapCol; uniform int gradient_use; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; uniform int textureTruchet; uniform float truchetSeed; @@ -43,74 +34,122 @@ uniform float tileLength; float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// float round(float val) { return fract(val) >= 0.5? ceil(val) : floor(val); } diff --git a/shaders/sh_interpret_number/sh_interpret_number.fsh b/shaders/sh_interpret_number/sh_interpret_number.fsh index 909aabee2..eb099c1d2 100644 --- a/shaders/sh_interpret_number/sh_interpret_number.fsh +++ b/shaders/sh_interpret_number/sh_interpret_number.fsh @@ -7,87 +7,124 @@ uniform int mode; uniform vec2 range; uniform float number[BATCH_SIZE]; -#region ////////////////////////////////////////// GRADIENT BEGIN ////////////////////////////////////////// -#define GRADIENT_LIMIT 128 -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; - -vec3 rgb2hsv(vec3 c) { - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } - -vec3 hsv2rgb(vec3 c) { - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} - -float hueDist(float a0, float a1, float t) { - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// -#endregion ////////////////////////////////////////// GRADIENT END ////////////////////////////////////////// void main() { vec2 px = v_vTexcoord; diff --git a/shaders/sh_pixel_cloud/sh_pixel_cloud.fsh b/shaders/sh_pixel_cloud/sh_pixel_cloud.fsh index 6ae8654c4..ab0136225 100644 --- a/shaders/sh_pixel_cloud/sh_pixel_cloud.fsh +++ b/shaders/sh_pixel_cloud/sh_pixel_cloud.fsh @@ -1,37 +1,24 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; -#define GRADIENT_LIMIT 128 - uniform float seed; uniform float strength; uniform float dist; -uniform int useMap; +uniform int useMap; uniform sampler2D strengthMap; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; - uniform float alpha_curve[64]; uniform int curve_amount; uniform float randomAmount; -float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) { +float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) { #region return _y0 * pow(1. - prog, 3.) + ay0 * 3. * pow(1. - prog, 2.) * prog + by1 * 3. * (1. - prog) * pow(prog, 2.) + _y1 * pow(prog, 3.); -} +} #endregion -float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) { +float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float _x) { #region float st = 0.; float ed = 1.; float _prec = 0.0001; @@ -76,9 +63,9 @@ float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx _xt = clamp(_xt, 0., 1.); return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt); -} +} #endregion -float curveEval(in float _x) { +float curveEval(in float _x) { #region _x = clamp(_x, 0., 1.); int segments = curve_amount / 6 - 1; @@ -105,87 +92,135 @@ float curveEval(in float _x) { } return alpha_curve[0]; -} +} #endregion -vec3 rgb2hsv(vec3 c) { - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } - -vec3 hsv2rgb(vec3 c) { - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} - -float hueDist(float a0, float a1, float t) { - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// -float frandom (in vec2 st, in float _seed) { +float frandom (in vec2 st, in float _seed) { #region float f = fract(sin(dot(st.xy, vec2(12.9898, 78.233)) * mod(15.15 + seed, 32.156 + _seed) * 12.588) * 43758.5453123); return mix(-1., 1., f); -} +} #endregion -vec2 vrandom (in vec2 st) { +vec2 vrandom (in vec2 st) { #region return vec2(frandom(st, 165.874), frandom(st, 98.601)); -} +} #endregion -void main() { +void main() { #region vec2 _pos = v_vTexcoord; float str = strength; @@ -211,5 +246,4 @@ void main() { } gl_FragColor = _col; -} - +} #endregion \ No newline at end of file diff --git a/shaders/sh_pytagorean_tile/sh_pytagorean_tile.fsh b/shaders/sh_pytagorean_tile/sh_pytagorean_tile.fsh index 2a59b5e7a..adc4f4691 100644 --- a/shaders/sh_pytagorean_tile/sh_pytagorean_tile.fsh +++ b/shaders/sh_pytagorean_tile/sh_pytagorean_tile.fsh @@ -1,11 +1,6 @@ -// Pytagorean tiling -// gelami Pythagorean Square Tiling 2 - varying vec2 v_vTexcoord; varying vec4 v_vColour; -#define GRADIENT_LIMIT 128 - uniform vec2 dimension; uniform vec2 position; uniform float seed; @@ -24,16 +19,6 @@ uniform vec2 thick; uniform int thickUseSurf; uniform sampler2D thickSurf; -uniform vec4 gapCol; -uniform int gradient_use; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; - uniform int textureTruchet; uniform float truchetSeed; uniform float truchetThres; @@ -41,79 +26,130 @@ uniform vec2 truchetAngle; uniform float phase; +uniform vec4 gapCol; +uniform int gradient_use; + #define PI 3.14159265359 #define TAU 6.28318530718 -float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } - -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// + +float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } float HexDist(vec2 p) { #region p = abs(p); diff --git a/shaders/sh_quarsicrystal/sh_quarsicrystal.fsh b/shaders/sh_quarsicrystal/sh_quarsicrystal.fsh new file mode 100644 index 000000000..42f20da46 --- /dev/null +++ b/shaders/sh_quarsicrystal/sh_quarsicrystal.fsh @@ -0,0 +1,66 @@ +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +#define PI 3.14159265359 + +uniform vec2 dimension; +uniform vec2 position; + +uniform vec2 amount; +uniform int amountUseSurf; +uniform sampler2D amountSurf; + +uniform vec2 angle; +uniform int angleUseSurf; +uniform sampler2D angleSurf; + +uniform vec2 phase; +uniform int phaseUseSurf; +uniform sampler2D phaseSurf; + +uniform vec2 rangleRange; + +uniform vec4 color0; +uniform vec4 color1; + +void main() { #region + #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.); + } + + 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); + + float pha = phase.x; + if(phaseUseSurf == 1) { + vec4 _vMap = texture2D( phaseSurf, v_vTexcoord ); + pha = mix(phase.x, phase.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + #endregion + + vec2 pos = (v_vTexcoord - position) * mat2(cos(ang), -sin(ang), sin(ang), cos(ang)) * amo; + + float value = 0.0; + int num = 4; + + float as = radians(rangleRange.x); + float an = radians(rangleRange.y); + + for(int i = 0; i < num; i++) { + float a = mix(as, an, float(i) / float(num)); + float w = pos.x * sin(a) + pos.y * cos(a); + + value += sin(w + pha * PI * 2.); + } + + float _s = 1. + sin(value * PI / 2.0); + gl_FragColor = mix(color0, color1, _s); +} #endregion diff --git a/shaders/sh_quarsicrystal/sh_quarsicrystal.vsh b/shaders/sh_quarsicrystal/sh_quarsicrystal.vsh new file mode 100644 index 000000000..3900c20f4 --- /dev/null +++ b/shaders/sh_quarsicrystal/sh_quarsicrystal.vsh @@ -0,0 +1,19 @@ +// +// Simple passthrough vertex shader +// +attribute vec3 in_Position; // (x,y,z) +//attribute vec3 in_Normal; // (x,y,z) unused in this shader. +attribute vec4 in_Colour; // (r,g,b,a) +attribute vec2 in_TextureCoord; // (u,v) + +varying vec2 v_vTexcoord; +varying vec4 v_vColour; + +void main() +{ + vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0); + gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos; + + v_vColour = in_Colour; + v_vTexcoord = in_TextureCoord; +} diff --git a/shaders/sh_quarsicrystal/sh_quarsicrystal.yy b/shaders/sh_quarsicrystal/sh_quarsicrystal.yy new file mode 100644 index 000000000..2e100c6d8 --- /dev/null +++ b/shaders/sh_quarsicrystal/sh_quarsicrystal.yy @@ -0,0 +1,10 @@ +{ + "resourceType": "GMShader", + "resourceVersion": "1.0", + "name": "sh_quarsicrystal", + "parent": { + "name": "generator", + "path": "folders/shader/generator.yy", + }, + "type": 1, +} \ No newline at end of file diff --git a/shaders/sh_random_tile/sh_random_tile.fsh b/shaders/sh_random_tile/sh_random_tile.fsh index fc99678c3..25262be96 100644 --- a/shaders/sh_random_tile/sh_random_tile.fsh +++ b/shaders/sh_random_tile/sh_random_tile.fsh @@ -1,8 +1,6 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -#define GRADIENT_LIMIT 128 - uniform vec2 dimension; uniform vec2 position; uniform float seed; @@ -23,13 +21,6 @@ uniform sampler2D thickSurf; uniform vec4 gapCol; uniform int gradient_use; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; uniform int textureTruchet; uniform float truchetSeed; @@ -41,74 +32,122 @@ uniform vec2 truchetAngle; float random (in vec2 st) { return fract(sin(dot(st.xy + vec2(85.456034, 64.54065), vec2(12.9898, 78.233))) * (43758.5453123 + seed) ); } -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); - } #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// float round(float val) { return fract(val) >= 0.5? ceil(val) : floor(val); } diff --git a/shaders/sh_stripe/sh_stripe.fsh b/shaders/sh_stripe/sh_stripe.fsh index 6014014be..5185fbc37 100644 --- a/shaders/sh_stripe/sh_stripe.fsh +++ b/shaders/sh_stripe/sh_stripe.fsh @@ -1,6 +1,3 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; @@ -28,85 +25,124 @@ uniform sampler2D ratioSurf; uniform vec4 color0; uniform vec4 color1; - -#define GRADIENT_LIMIT 128 uniform int gradient_use; -uniform int gradient_blend; -uniform vec4 gradient_color[GRADIENT_LIMIT]; -uniform float gradient_time[GRADIENT_LIMIT]; -uniform int gradient_keys; -uniform int gradient_use_map; -uniform vec4 gradient_map_range; -uniform sampler2D gradient_map; -vec3 rgb2hsv(vec3 c) { #region - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); - vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); - vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); - - float d = q.x - min(q.w, q.y); - float e = 0.0000000001; - return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); -} #endregion - -vec3 hsv2rgb(vec3 c) { #region - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); - vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); - return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); -} #endregion - -float hueDist(float a0, float a1, float t) { #region - float da = fract(a1 - a0); - float ds = fract(2. * da) - da; - return a0 + ds * t; -} #endregion - -vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region - vec3 h1 = rgb2hsv(c1); - vec3 h2 = rgb2hsv(c2); +#region //////////////////////////////////// GRADIENT //////////////////////////////////// + #define GRADIENT_LIMIT 128 - vec3 h = vec3(0.); - h.x = h.x + hueDist(h1.x, h2.x, t); - h.y = mix(h1.y, h2.y, t); - h.z = mix(h1.z, h2.z, t); - - return hsv2rgb(h); -} #endregion + uniform int gradient_blend; + uniform vec4 gradient_color[GRADIENT_LIMIT]; + uniform float gradient_time[GRADIENT_LIMIT]; + uniform int gradient_keys; + uniform int gradient_use_map; + uniform vec4 gradient_map_range; + uniform sampler2D gradient_map; -vec4 gradientEval(in float prog) { #region - if(gradient_use_map == 1) { - vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); - return texture2D( gradient_map, samplePos ); - } + vec3 rgb2oklab(vec3 c) { #region + const mat3 kCONEtoLMS = mat3( + 0.4121656120, 0.2118591070, 0.0883097947, + 0.5362752080, 0.6807189584, 0.2818474174, + 0.0514575653, 0.1074065790, 0.6302613616); + + c = pow(c, vec3(2.2)); + c = pow( kCONEtoLMS * c, vec3(1.0 / 3.0) ); + + return c; + } #endregion - vec4 col = vec4(0.); + vec3 oklab2rgb(vec3 c) { #region + const mat3 kLMStoCONE = mat3( + 4.0767245293, -1.2681437731, -0.0041119885, + -3.3072168827, 2.6093323231, -0.7034763098, + 0.2307590544, -0.3411344290, 1.7068625689); + + c = kLMStoCONE * (c * c * c); + c = pow(c, vec3(1. / 2.2)); + + return c; + } #endregion + + vec3 oklabMax(vec3 c1, vec3 c2, float t) { #region + vec3 k1 = rgb2oklab(c1); + vec3 k2 = rgb2oklab(c2); + + return oklab2rgb(mix(k1, k2, t)); + } #endregion - for(int i = 0; i < GRADIENT_LIMIT; i++) { - if(gradient_time[i] == prog) { - col = gradient_color[i]; - break; - } else if(gradient_time[i] > prog) { - if(i == 0) + vec3 rgb2hsv(vec3 c) { #region + vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); + vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); + + float d = q.x - min(q.w, q.y); + float e = 0.0000000001; + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); + } #endregion + + vec3 hsv2rgb(vec3 c) { #region + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); + } #endregion + + float hueDist(float a0, float a1, float t) { #region + float da = fract(a1 - a0); + float ds = fract(2. * da) - da; + return a0 + ds * t; + } #endregion + + vec3 hsvMix(vec3 c1, vec3 c2, float t) { #region + vec3 h1 = rgb2hsv(c1); + vec3 h2 = rgb2hsv(c2); + + vec3 h = vec3(0.); + h.x = h.x + hueDist(h1.x, h2.x, t); + h.y = mix(h1.y, h2.y, t); + h.z = mix(h1.z, h2.z, t); + + return hsv2rgb(h); + } #endregion + + vec4 gradientEval(in float prog) { #region + if(gradient_use_map == 1) { + vec2 samplePos = mix(gradient_map_range.xy, gradient_map_range.zw, prog); + return texture2D( gradient_map, samplePos ); + } + + vec4 col = vec4(0.); + + for(int i = 0; i < GRADIENT_LIMIT; i++) { + if(gradient_time[i] == prog) { col = gradient_color[i]; - else { - float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); - if(gradient_blend == 0) - col = mix(gradient_color[i - 1], gradient_color[i], t); - else if(gradient_blend == 1) - col = gradient_color[i - 1]; - else if(gradient_blend == 2) - col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), 1.); + break; + } else if(gradient_time[i] > prog) { + if(i == 0) + col = gradient_color[i]; + else { + float t = (prog - gradient_time[i - 1]) / (gradient_time[i] - gradient_time[i - 1]); + float a = mix(gradient_color[i - 1].a, gradient_color[i].a, t); + + if(gradient_blend == 0) + col = mix(gradient_color[i - 1], gradient_color[i], t); + else if(gradient_blend == 1) + col = gradient_color[i - 1]; + else if(gradient_blend == 2) + col = vec4(hsvMix(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + else if(gradient_blend == 3) + col = vec4(oklabMax(gradient_color[i - 1].rgb, gradient_color[i].rgb, t), a); + } + break; + } + if(i >= gradient_keys - 1) { + col = gradient_color[gradient_keys - 1]; + break; } - break; } - if(i >= gradient_keys - 1) { - col = gradient_color[gradient_keys - 1]; - break; - } - } - return col; -} #endregion + return col; + } #endregion + +#endregion //////////////////////////////////// GRADIENT //////////////////////////////////// float random (in vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); } diff --git a/sprites/s_node_kuwahara/8a406345-89b9-471e-9af6-1f2bcc937fd9.png b/sprites/s_node_kuwahara/8a406345-89b9-471e-9af6-1f2bcc937fd9.png new file mode 100644 index 000000000..373a5e666 Binary files /dev/null and b/sprites/s_node_kuwahara/8a406345-89b9-471e-9af6-1f2bcc937fd9.png differ diff --git a/sprites/s_node_kuwahara/d32dffb4-8395-4ac5-800e-6d35f00f9167.png b/sprites/s_node_kuwahara/d32dffb4-8395-4ac5-800e-6d35f00f9167.png deleted file mode 100644 index 1488f077f..000000000 Binary files a/sprites/s_node_kuwahara/d32dffb4-8395-4ac5-800e-6d35f00f9167.png and /dev/null differ diff --git a/sprites/s_node_kuwahara/layers/8a406345-89b9-471e-9af6-1f2bcc937fd9/f8c4784e-d1f2-4f62-bfea-b59001ce1031.png b/sprites/s_node_kuwahara/layers/8a406345-89b9-471e-9af6-1f2bcc937fd9/f8c4784e-d1f2-4f62-bfea-b59001ce1031.png new file mode 100644 index 000000000..373a5e666 Binary files /dev/null and b/sprites/s_node_kuwahara/layers/8a406345-89b9-471e-9af6-1f2bcc937fd9/f8c4784e-d1f2-4f62-bfea-b59001ce1031.png differ diff --git a/sprites/s_node_kuwahara/layers/d32dffb4-8395-4ac5-800e-6d35f00f9167/7f08cf06-022b-4f31-ad2e-39f9ebdaa522.png b/sprites/s_node_kuwahara/layers/d32dffb4-8395-4ac5-800e-6d35f00f9167/7f08cf06-022b-4f31-ad2e-39f9ebdaa522.png deleted file mode 100644 index 1488f077f..000000000 Binary files a/sprites/s_node_kuwahara/layers/d32dffb4-8395-4ac5-800e-6d35f00f9167/7f08cf06-022b-4f31-ad2e-39f9ebdaa522.png and /dev/null differ diff --git a/sprites/s_node_kuwahara/s_node_kuwahara.yy b/sprites/s_node_kuwahara/s_node_kuwahara.yy index 4a2d383f1..6685a6575 100644 --- a/sprites/s_node_kuwahara/s_node_kuwahara.yy +++ b/sprites/s_node_kuwahara/s_node_kuwahara.yy @@ -13,14 +13,14 @@ "edgeFiltering": false, "For3D": false, "frames": [ - {"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"d32dffb4-8395-4ac5-800e-6d35f00f9167",}, + {"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"8a406345-89b9-471e-9af6-1f2bcc937fd9",}, ], "gridX": 0, "gridY": 0, "height": 64, "HTile": false, "layers": [ - {"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"7f08cf06-022b-4f31-ad2e-39f9ebdaa522","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,}, + {"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"f8c4784e-d1f2-4f62-bfea-b59001ce1031","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,}, ], "nineSlice": null, "origin": 4, @@ -54,7 +54,7 @@ "timeUnits": 1, "tracks": [ {"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore","resourceVersion":"1.0","Keyframes":[ - {"resourceType":"Keyframe","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"d32dffb4-8395-4ac5-800e-6d35f00f9167","path":"sprites/s_node_kuwahara/s_node_kuwahara.yy",},},},"Disabled":false,"id":"e7a17aeb-e2e6-4c0b-a6aa-ec494d2715ae","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,}, + {"resourceType":"Keyframe","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"8a406345-89b9-471e-9af6-1f2bcc937fd9","path":"sprites/s_node_kuwahara/s_node_kuwahara.yy",},},},"Disabled":false,"id":"9fa76e34-7a1b-4483-803f-cabf9e9eddc1","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,}, ],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,}, ], "visibleRange": null,