From 9b273e86e6ca311c2a59a90fd3544a55c52d84d6 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Fri, 22 Dec 2023 20:46:54 +0700 Subject: [PATCH] Mappable value 1 --- fonts/_f_sdf/_f_sdf.old.png | Bin 82361 -> 82361 bytes fonts/_f_sdf/_f_sdf.png | Bin 82361 -> 82361 bytes fonts/_f_sdf_medium/_f_sdf_medium.old.png | Bin 59906 -> 59906 bytes fonts/_f_sdf_medium/_f_sdf_medium.png | Bin 59906 -> 59906 bytes objects/o_dialog_add_node/Create_0.gml | 16 +- scripts/button/button.gml | 40 +++-- scripts/nodeValue_drawer/nodeValue_drawer.gml | 6 +- scripts/node_bw/node_bw.gml | 37 +++-- scripts/node_cache/node_cache.gml | 6 +- scripts/node_cache_array/node_cache_array.gml | 6 +- .../node_color_adjustment.gml | 153 ++++++++++++++---- .../node_displacement/node_displacement.gml | 26 +-- scripts/node_greyscale/node_greyscale.gml | 37 +++-- scripts/node_skew/node_skew.gml | 28 ++-- scripts/node_value/node_value.gml | 44 +++++ scripts/shader_functions/shader_functions.gml | 75 ++++----- scripts/slider/slider.gml | 13 +- scripts/vectorBox/vectorBox.gml | 14 +- shaders/sh_bw/sh_bw.fsh | 36 +++-- shaders/sh_color_adjust/sh_color_adjust.fsh | 103 +++++++++--- shaders/sh_displace/sh_displace.fsh | 23 +-- shaders/sh_greyscale/sh_greyscale.fsh | 25 ++- shaders/sh_skew/sh_skew.fsh | 25 +-- 23 files changed, 475 insertions(+), 238 deletions(-) diff --git a/fonts/_f_sdf/_f_sdf.old.png b/fonts/_f_sdf/_f_sdf.old.png index 31ec70297cd21a5d7fb3faf961dab42432b14dad..7ce7062555e1133dfc0d60879e511c716dc665dd 100644 GIT binary patch delta 87 zcmdnl%(}CgwP6dRxuc+km5GIwfrYk#ft7*5UeC98r+YXuDxeCV5eZG4Ug^lFEQ_Lg THe<;?1|aZs^>bP0l+XkKS?w4) delta 87 zcmdnl%(}CgwP6dRxuc-5m4S(siK(`Mft7)Q=#O)v+6;Op!mWq9uUg^lFEQ_Mr Tc!Rk%0}yz+`njxgN@xNAEbbRQ diff --git a/fonts/_f_sdf/_f_sdf.png b/fonts/_f_sdf/_f_sdf.png index 276cb0f80c6a5b997d13cc4547c940ce1859031a..d150f152df40e5ad92c7644f745c062b250e8a9b 100644 GIT binary patch delta 87 zcmdnl%(}CgwP6dRxuc+^m8q$fk%hK_ft7)QSXX-JbPq>H1ytem>-S$yuXJQomPJu* TaOj^I0}yz+`njxgN@xNAJg*p$ delta 87 zcmdnl%(}CgwP6dRxuc-5m9eRnse!hEft7*5U#}j&=^l=Z3aG+8;wGP_S2{8(%c7{h S%_OSJ00f?{elF{r5}E)g;1=ru diff --git a/fonts/_f_sdf_medium/_f_sdf_medium.old.png b/fonts/_f_sdf_medium/_f_sdf_medium.old.png index 917e5847838e3a02cecb34e5c54f8742c186f6e2..1f348a208816eebe6b3fdc2978665a290792bc42 100644 GIT binary patch delta 83 zcmZp=!rXL)c|*fXK?^Gr3o8Q)Z36=<1B1PuZ|_c?_)-B?^o&So;^adwm1R-X&Sosx P#{dMLu6{1-oD!MpUh;e5rscnzB^v%j82Zm1R-X8gDSy PW&i?DS3j3^P6gTe~DWM4fZvYu8 diff --git a/objects/o_dialog_add_node/Create_0.gml b/objects/o_dialog_add_node/Create_0.gml index 184eec910..45e1a5e09 100644 --- a/objects/o_dialog_add_node/Create_0.gml +++ b/objects/o_dialog_add_node/Create_0.gml @@ -482,9 +482,9 @@ event_inherited(); if(_hoverContent && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_size)) { draw_sprite_stretched_ext(THEME.node_active, 0, _boxx, yy, grid_size, grid_size, COLORS._main_accent, 1); - if(mouse_press(mb_left, sFOCUS)) + if(mouse_release(mb_left, sFOCUS)) buildNode(_node); - else if(mouse_press(mb_right, sFOCUS)) + else if(mouse_release(mb_right, sFOCUS)) rightClick(_node); } @@ -602,9 +602,9 @@ event_inherited(); } draw_sprite_stretched_ext(THEME.node_active, 0, ui(16), yy, list_width - ui(32), list_height, COLORS._main_accent, 1); - if(mouse_press(mb_left, sFOCUS)) + if(mouse_release(mb_left, sFOCUS)) buildNode(_node); - else if(mouse_press(mb_right, sFOCUS)) + else if(mouse_release(mb_right, sFOCUS)) rightClick(_node); } @@ -813,9 +813,9 @@ event_inherited(); if(_hover && point_in_rectangle(_m[0], _m[1], _nx, yy, _nx + grid_width, yy + grid_size)) { node_selecting = i; - if(mouse_press(mb_left, sFOCUS)) + if(mouse_release(mb_left, sFOCUS)) buildNode(_node, _param); - else if(struct_has(_node, "node") && mouse_press(mb_right, sFOCUS)) + else if(struct_has(_node, "node") && mouse_release(mb_right, sFOCUS)) rightClick(_node); } @@ -908,9 +908,9 @@ event_inherited(); } node_selecting = i; - if(mouse_press(mb_left, sFOCUS)) + if(mouse_release(mb_left, sFOCUS)) buildNode(_node, _param); - else if(struct_has(_node, "node") && mouse_press(mb_right, sFOCUS)) + else if(struct_has(_node, "node") && mouse_release(mb_right, sFOCUS)) rightClick(_node); } diff --git a/scripts/button/button.gml b/scripts/button/button.gml index 86a634209..1098319a2 100644 --- a/scripts/button/button.gml +++ b/scripts/button/button.gml @@ -1,6 +1,4 @@ -function button(_onClick, _icon = noone) { - return new buttonClass(_onClick, _icon); -} +function button(_onClick, _icon = noone) { INLINE return new buttonClass(_onClick, _icon); } function buttonClass(_onClick, _icon = noone) : widget() constructor { icon = _icon; @@ -19,49 +17,49 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor { toggled = false; - static setLua = function(_lua_thread, _lua_key, _lua_func) { + static setLua = function(_lua_thread, _lua_key, _lua_func) { #region lua_thread = _lua_thread; lua_thread_key = _lua_key; onClick = method(self, _lua_func); - } + } #endregion - static trigger = function() { + static trigger = function() { #region clicked = true; if(!is_callable(onClick)) return noone; triggered = true; onClick(); - } + } #endregion - static isTriggered = function() { + static isTriggered = function() { #region var t = triggered; triggered = false; return t; - } + } #endregion - static setIcon = function(_icon, _index = 0, _blend = c_white) { + static setIcon = function(_icon, _index = 0, _blend = c_white) { #region icon = _icon; icon_index = _index; icon_blend = _blend; return self; - } + } #endregion - static setText = function(_text) { + static setText = function(_text) { #region text = _text; return self; - } + } #endregion - static setTooltip = function(_tip) { + static setTooltip = function(_tip) { #region tooltip = _tip; return self; - } + } #endregion - static drawParam = function(params) { + static drawParam = function(params) { #region return draw(params.x, params.y, params.w, params.h, params.m); - } + } #endregion - static draw = function(_x, _y, _w, _h, _m, spr = THEME.button, blend = c_white) { + static draw = function(_x, _y, _w, _h, _m, spr = THEME.button, blend = c_white) { #region x = _x; y = _y; w = _w; @@ -106,10 +104,10 @@ function buttonClass(_onClick, _icon = noone) : widget() constructor { resetFocus(); return _h; - } + } #endregion } -function buttonInstant(spr, _x, _y, _w, _h, _m, _act, _hvr, _tip = "", _icon = noone, _icon_index = 0, _icon_blend = COLORS._main_icon, _icon_alpha = 1, _icon_scale = 1) { +function buttonInstant(spr, _x, _y, _w, _h, _m, _act, _hvr, _tip = "", _icon = noone, _icon_index = 0, _icon_blend = COLORS._main_icon, _icon_alpha = 1, _icon_scale = 1) { #region var res = 0; var cc = is_array(_icon_blend)? _icon_blend[0] : _icon_blend; @@ -138,4 +136,4 @@ function buttonInstant(spr, _x, _y, _w, _h, _m, _act, _hvr, _tip = "", _icon = n draw_sprite_ui_uniform(_icon, _icon_index, _x + _w / 2, _y + _h / 2, _icon_scale, cc, _icon_alpha); return res; -} \ No newline at end of file +} #endregion \ No newline at end of file diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index f497d1f8b..c7fbd4271 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -110,7 +110,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc lb_w += ui(24); } #endregion - if(!jun.active) { + if(!jun.active) { #region draw_set_text(_font, fa_left, fa_center, COLORS._main_text_sub_inner); draw_text_add(lb_x, lb_y - ui(2), _name); @@ -126,7 +126,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc } return [ 0, true ]; - } + } #endregion draw_text_add(lb_x, lb_y - ui(2), _name); @@ -281,7 +281,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc #endregion } else if(wid && jun.display_type != VALUE_DISPLAY.none) { #region edit widget wid.setFocusHover(_focus, _hover); - + if(jun.connect_type == JUNCTION_CONNECT.input) { wid.setInteract(!jun.hasJunctionFrom()); if(_focus) wid.register(_scrollPane); diff --git a/scripts/node_bw/node_bw.gml b/scripts/node_bw/node_bw.gml index ff66870f1..c8cdd282c 100644 --- a/scripts/node_bw/node_bw.gml +++ b/scripts/node_bw/node_bw.gml @@ -1,17 +1,15 @@ function Node_BW(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "BW"; - shader = sh_bw; - uniform_exp = shader_get_uniform(shader, "brightness"); - uniform_con = shader_get_uniform(shader, "contrast"); - inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); inputs[| 1] = nodeValue("Brightness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01] }) + .setMappable(9); inputs[| 2] = nodeValue("Contrast", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 4, 0.01] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 4, 0.01] }) + .setMappable(10); inputs[| 3] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); @@ -26,9 +24,15 @@ function Node_BW(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr __init_mask_modifier(3); // inputs 7, 8 + inputs[| 9] = nodeValue("Brightness map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 10] = nodeValue("Contrast map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + input_display_list = [ 5, 6, ["Surfaces", true], 0, 3, 4, 7, 8, - ["BW", false], 1, 2, + ["BW", false], 1, 9, 2, 10, ] outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -37,23 +41,18 @@ function Node_BW(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constr static step = function() { #region __step_mask_modifier(); + + inputs[| 1].mappableStep(); + inputs[| 2].mappableStep(); } #endregion static processData = function(_outSurf, _data, _output_index, _array_index) { #region - var _exp = _data[1]; - var _con = _data[2]; - surface_set_target(_outSurf); - DRAW_CLEAR - BLEND_OVERRIDE; - shader_set(shader); - shader_set_uniform_f(uniform_exp, _exp); - shader_set_uniform_f(uniform_con, _con); + surface_set_shader(_outSurf, sh_bw); + shader_set_f_map("brightness", _data[1], _data[ 9], inputs[| 1]); + shader_set_f_map("contrast", _data[2], _data[10], inputs[| 2]); draw_surface_safe(_data[0], 0, 0); - shader_reset(); - - BLEND_NORMAL; - surface_reset_target(); + surface_reset_shader(); __process_mask_modifier(_data); _outSurf = mask_apply(_data[0], _outSurf, _data[3], _data[4]); diff --git a/scripts/node_cache/node_cache.gml b/scripts/node_cache/node_cache.gml index 65a910a95..c622c41fc 100644 --- a/scripts/node_cache/node_cache.gml +++ b/scripts/node_cache/node_cache.gml @@ -37,8 +37,12 @@ function Node_Cache(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) const static update = function() { #region if(recoverCache()) return; + if(!inputs[| 0].value_from) return; - if(!inputs[| 0].value_from.node.renderActive) return; + if(!inputs[| 0].value_from.node.renderActive) { + enableNodeGroup(); + return; + } var _surf = getInputData(0); cacheCurrentFrame(_surf); diff --git a/scripts/node_cache_array/node_cache_array.gml b/scripts/node_cache_array/node_cache_array.gml index 2d35b2175..b8e17e4b4 100644 --- a/scripts/node_cache_array/node_cache_array.gml +++ b/scripts/node_cache_array/node_cache_array.gml @@ -46,7 +46,11 @@ function Node_Cache_Array(_x, _y, _group = noone) : __Node_Cache(_x, _y, _group) static update = function() { #region if(!inputs[| 0].value_from) return; - if(!inputs[| 0].value_from.node.renderActive) return; + if(!inputs[| 0].value_from.node.renderActive) { + if(!cacheExist(CURRENT_FRAME)) + enableNodeGroup(); + return; + } var ss = []; var str = getInputData(1); diff --git a/scripts/node_color_adjustment/node_color_adjustment.gml b/scripts/node_color_adjustment/node_color_adjustment.gml index bdff5e626..4428d36f7 100644 --- a/scripts/node_color_adjustment/node_color_adjustment.gml +++ b/scripts/node_color_adjustment/node_color_adjustment.gml @@ -4,32 +4,40 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); inputs[| 1] = nodeValue("Brightness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }) + .setMappable(18); inputs[| 2] = nodeValue("Contrast", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5) - .setDisplay(VALUE_DISPLAY.slider); + .setDisplay(VALUE_DISPLAY.slider) + .setMappable(19); inputs[| 3] = nodeValue("Hue", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }) + .setMappable(20); inputs[| 4] = nodeValue("Saturation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }) + .setMappable(21); inputs[| 5] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01 ] }) + .setMappable(22); inputs[| 6] = nodeValue("Blend", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white); inputs[| 7] = nodeValue("Blend amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider); + .setDisplay(VALUE_DISPLAY.slider) + .setMappable(23); inputs[| 8] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); inputs[| 9] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) - .setDisplay(VALUE_DISPLAY.slider); + .setDisplay(VALUE_DISPLAY.slider) + .setMappable(24); inputs[| 10] = nodeValue("Exposure", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) - .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 0.01 ] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 0.01 ] }) + .setMappable(25); inputs[| 11] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); active_index = 11; @@ -52,19 +60,47 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro inputs[| 17] = nodeValue("Mask feather", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) .setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 1] }); + //////////////////////////////////////////////////////////////////////////////////////// + + inputs[| 18] = nodeValue("Brightness map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 19] = nodeValue("Contrast map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 20] = nodeValue("Hue map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 21] = nodeValue("Saturation map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 22] = nodeValue("Value map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 23] = nodeValue("Blend map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 24] = nodeValue("Alpha map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 25] = nodeValue("Exposure map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + //////////////////////////////////////////////////////////////////////////////////////// + outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 1] = nodeValue("Color out", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, []) .setDisplay(VALUE_DISPLAY.palette); - input_display_list = [11, 12, 15, 9, + input_display_list = [11, 12, 15, 9, 24, ["Surface", false], 0, 8, 16, 17, 13, - ["Brightness", false], 1, 10, 2, - ["HSV", false], 3, 4, 5, - ["Color blend", false], 6, 14, 7 + ["Brightness", false], 1, 18, 10, 25, 2, 19, + ["HSV", false], 3, 20, 4, 21, 5, 22, + ["Color blend", false], 6, 14, 7, 23, ]; - temp_surface = [ surface_create(1, 1) ]; + temp_surface = [ surface_create(1, 1), surface_create(1, 1) ]; attribute_surface_depth(); @@ -83,6 +119,15 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro var _msk = is_surface(getSingleValue(8)); inputs[| 16].setVisible(_msk); inputs[| 17].setVisible(_msk); + + inputs[| 1].mappableStep(); + inputs[| 2].mappableStep(); + inputs[| 3].mappableStep(); + inputs[| 4].mappableStep(); + inputs[| 5].mappableStep(); + inputs[| 7].mappableStep(); + inputs[| 9].mappableStep(); + inputs[| 10].mappableStep(); } #endregion static processData = function(_outSurf, _data, _output_index, _array_index) { #region @@ -113,7 +158,16 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro _col = array_clone(_col); - if(_type == 1) { + if(_type == 1) { #region color adjust + if(is_array(_bri)) _bri = array_safe_get(_bri, 0); + if(is_array(_con)) _con = array_safe_get(_con, 0); + if(is_array(_hue)) _hue = array_safe_get(_hue, 0); + if(is_array(_sat)) _sat = array_safe_get(_sat, 0); + if(is_array(_val)) _val = array_safe_get(_val, 0); + if(is_array(_bla)) _bla = array_safe_get(_bla, 0); + if(is_array(_alp)) _alp = array_safe_get(_alp, 0); + if(is_array(_exp)) _exp = array_safe_get(_exp, 0); + if(!is_array(_col)) _col = [ _col ]; for( var i = 0, n = array_length(_col); i < n; i++ ) { @@ -144,29 +198,62 @@ function Node_Color_adjust(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro } return _col; - } + } #endregion - _m = mask_modify(_m, _mskInv, _mskFea); + #region param + var sw = surface_get_width_safe(_baseSurf); + var sh = surface_get_height_safe(_baseSurf); - surface_set_shader(_baseSurf, sh_color_adjust); - shader_set_f("brightness", _bri); - shader_set_f("exposure", _exp); - shader_set_f("contrast", _con); - shader_set_f("hue", _hue); - shader_set_f("sat", _sat); - shader_set_f("val", _val); + temp_surface[0] = surface_verify(temp_surface[0], sw * 2, sh * 2); + temp_surface[1] = surface_verify(temp_surface[1], sw * 2, sh * 2); + + surface_set_target(temp_surface[0]); + DRAW_CLEAR + + draw_surface_stretched_safe(_data[18], sw * 0, sh * 0, sw, sh); //Brightness + draw_surface_stretched_safe(_data[25], sw * 1, sh * 0, sw, sh); //Exposure + draw_surface_stretched_safe(_data[19], sw * 0, sh * 1, sw, sh); //Contrast + draw_surface_stretched_safe(_data[20], sw * 1, sh * 1, sw, sh); //Hue + surface_reset_target(); + + surface_set_target(temp_surface[1]); + DRAW_CLEAR + + draw_surface_stretched_safe(_data[21], sw * 0, sh * 0, sw, sh); //Sat + draw_surface_stretched_safe(_data[22], sw * 1, sh * 0, sw, sh); //Val + draw_surface_stretched_safe(_data[23], sw * 0, sh * 1, sw, sh); //Blend + draw_surface_stretched_safe(_data[24], sw * 1, sh * 1, sw, sh); //Alpha + surface_reset_target(); + #endregion + + #region surface adjust + _m = mask_modify(_m, _mskInv, _mskFea); + surface_set_shader(_baseSurf, sh_color_adjust); + shader_set_surface("param0", temp_surface[0]); + shader_set_surface("param1", temp_surface[1]); + + shader_set_f_map_s("brightness", _bri, _data[18], inputs[| 1]); + shader_set_f_map_s("exposure", _exp, _data[25], inputs[| 10]); + shader_set_f_map_s("contrast", _con, _data[19], inputs[| 2]); + shader_set_f_map_s("hue", _hue, _data[20], inputs[| 3]); + shader_set_f_map_s("sat", _sat, _data[21], inputs[| 4]); + shader_set_f_map_s("val", _val, _data[22], inputs[| 5]); - shader_set_color("blend", _bl, _bla); - shader_set_i("blendMode", _blm); + shader_set_color("blend", _bl); + shader_set_f_map_s("blendAmount", _bla, _data[23], inputs[| 7]); + shader_set_i("blendMode", _blm); + + shader_set_f_map_s("alpha", _alp, _data[24], inputs[| 9]); + shader_set_i("use_mask", is_surface(_m)); + shader_set_surface("mask", _m); + + gpu_set_colorwriteenable(1, 1, 1, 0); + draw_surface_safe(_surf, 0, 0); //replace clear color with surface color + gpu_set_colorwriteenable(1, 1, 1, 1); - shader_set_i("use_mask", is_surface(_m)); - shader_set_surface("mask", _m); - - gpu_set_colorwriteenable(1, 1, 1, 0); - draw_surface_safe(_surf, 0, 0); - gpu_set_colorwriteenable(1, 1, 1, 1); - draw_surface_ext_safe(_surf, 0, 0, 1, 1, 0, c_white, _alp); - surface_reset_shader(); + draw_surface_ext_safe(_surf, 0, 0, 1, 1, 0, c_white, 1); + surface_reset_shader(); + #endregion return _outSurf; } #endregion diff --git a/scripts/node_displacement/node_displacement.gml b/scripts/node_displacement/node_displacement.gml index 737aa7401..87a1423cd 100644 --- a/scripts/node_displacement/node_displacement.gml +++ b/scripts/node_displacement/node_displacement.gml @@ -10,13 +10,7 @@ function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) .setUnitRef(function(index) { return getDimension(index); }); inputs[| 3] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) - .setDisplay(VALUE_DISPLAY._default, { side_button: button(function() { - var jun = inputs[| 15]; - - jun.visible = !jun.visible; - setHeight(); - }).setIcon( THEME.value_use_surface, [ function() { return inputs[| 15].visible; } ], COLORS._main_icon ) - .setTooltip("Use map") }); + .setMappable(15); 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); @@ -67,19 +61,12 @@ 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(); } #endregion static processData = function(_outSurf, _data, _output_index, _array_index) { #region - switch(_data[5]) { - case 0 : - inputs[| 2].setVisible(true); - break; - case 1 : - case 2 : - inputs[| 2].setVisible(false); - break; - } - var ww = surface_get_width_safe(_data[0]); var hh = surface_get_height_safe(_data[0]); var mw = surface_get_width_safe(_data[1]); @@ -91,10 +78,7 @@ If set, then strength value control how many times the effect applies on itself. shader_set_f("dimension", [ww, hh]); shader_set_f("map_dimension", [mw, mh]); shader_set_f("displace", _data[ 2]); - shader_set_f("strength", _data[ 3]); - - shader_set_surface_i("strengthSurf", "strengthUseSurf", _data[15]); - + shader_set_f_map("strength", _data[ 3], _data[15], inputs[| 3].attributes.mapped); shader_set_f("middle", _data[ 4]); shader_set_i("use_rg", _data[ 5]); shader_set_i("iterate", _data[ 6]); diff --git a/scripts/node_greyscale/node_greyscale.gml b/scripts/node_greyscale/node_greyscale.gml index 2f417f66b..a80f8ccdb 100644 --- a/scripts/node_greyscale/node_greyscale.gml +++ b/scripts/node_greyscale/node_greyscale.gml @@ -1,17 +1,15 @@ function Node_Greyscale(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Greyscale"; - shader = sh_greyscale; - uniform_exp = shader_get_uniform(shader, "brightness"); - uniform_con = shader_get_uniform(shader, "contrast"); - inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); inputs[| 1] = nodeValue("Brightness", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 1, 0.01] }) + .setMappable(9); inputs[| 2] = nodeValue("Contrast", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1) - .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 4, 0.01] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [ -1, 4, 0.01] }) + .setMappable(10); inputs[| 3] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); @@ -26,9 +24,15 @@ function Node_Greyscale(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) __init_mask_modifier(3); // inputs 7, 8 + inputs[| 9] = nodeValue("Brightness map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + + inputs[| 10] = nodeValue("Contrast map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + input_display_list = [ 5, 6, ["Surfaces", true], 0, 3, 4, 7, 8, - ["Greyscale", false], 1, 2, + ["Greyscale", false], 1, 9, 2, 10, ] outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -37,23 +41,18 @@ function Node_Greyscale(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) static step = function() { #region __step_mask_modifier(); + + inputs[| 1].mappableStep(); + inputs[| 2].mappableStep(); } #endregion static processData = function(_outSurf, _data, _output_index, _array_index) { #region - var _exp = _data[1]; - var _con = _data[2]; - surface_set_target(_outSurf); - DRAW_CLEAR - BLEND_OVERRIDE; - shader_set(shader); - shader_set_uniform_f(uniform_exp, _exp); - shader_set_uniform_f(uniform_con, _con); + surface_set_shader(_outSurf, sh_greyscale); + shader_set_f_map("brightness", _data[1], _data[ 9], inputs[| 1]); + shader_set_f_map("contrast", _data[2], _data[10], inputs[| 2]); draw_surface_safe(_data[0], 0, 0); - shader_reset(); - - BLEND_NORMAL; - surface_reset_target(); + surface_reset_shader(); __process_mask_modifier(_data); _outSurf = mask_apply(_data[0], _outSurf, _data[3], _data[4]); diff --git a/scripts/node_skew/node_skew.gml b/scripts/node_skew/node_skew.gml index d8c5ea238..19423fccc 100644 --- a/scripts/node_skew/node_skew.gml +++ b/scripts/node_skew/node_skew.gml @@ -6,7 +6,8 @@ function Node_Skew(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons .setDisplay(VALUE_DISPLAY.enum_button, ["x", "y"]); inputs[| 2] = nodeValue("Amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) - .setDisplay(VALUE_DISPLAY.slider, { range: [-1, 1, 0.01] }); + .setDisplay(VALUE_DISPLAY.slider, { range: [-1, 1, 0.01] }) + .setMappable(12); inputs[| 3] = nodeValue("Wrap", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); @@ -25,15 +26,18 @@ function Node_Skew(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons inputs[| 8] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); active_index = 8; - + inputs[| 9] = nodeValue("Channel", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0b1111) .setDisplay(VALUE_DISPLAY.toggle, { data: array_create(4, THEME.inspector_channel) }); - + __init_mask_modifier(6); // inputs 10, 11 + inputs[| 12] = nodeValue("Strength map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) + .setVisible(false, false); + input_display_list = [ 8, 9, ["Surfaces", true], 0, 6, 7, 10, 11, - ["Skew", false], 1, 2, 4, + ["Skew", false], 1, 2, 12, 4, ] outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); @@ -42,23 +46,25 @@ function Node_Skew(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons attribute_oversample(); attribute_interpolation(); - static centerAnchor = function() { + static centerAnchor = function() { #region if(!is_surface(current_data[0])) return; var ww = surface_get_width_safe(current_data[0]); var hh = surface_get_height_safe(current_data[0]); inputs[| 4].setValue([ww / 2, hh / 2]); - } + } #endregion - static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { + static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region inputs[| 4].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny); - } + } #endregion static step = function() { #region __step_mask_modifier(); + + inputs[| 2].mappableStep(); } #endregion - static processData = function(_outSurf, _data, _output_index, _array_index) { + static processData = function(_outSurf, _data, _output_index, _array_index) { #region var _axis = _data[1]; var _amou = _data[2]; var _wrap = _data[3]; @@ -70,7 +76,7 @@ function Node_Skew(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons shader_set_dim("dimension", _data[0]); shader_set_f("center", _cent); shader_set_i("axis", _axis); - shader_set_f("amount", _amou); + shader_set_f_map("amount", _amou, _data[12], inputs[| 2]); shader_set_i("sampleMode", _samp); draw_surface_safe(_data[0], 0, 0); surface_reset_shader(); @@ -80,5 +86,5 @@ function Node_Skew(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons _outSurf = channel_apply(_data[0], _outSurf, _data[9]); return _outSurf; - } + } #endregion } \ No newline at end of file diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index a2c904437..389487cae 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1264,6 +1264,43 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru updateColor(); } resetDisplay(); #endregion + static setMappable = function(index) { #region + attributes.mapped = false; + attributes.map_index = index; + + editWidgetRaw = editWidget; + + mapButton = button(function() { + attributes.mapped = !attributes.mapped; + var val = getValue(); + if( attributes.mapped && is_numeric(val)) setValue([0, val]); + if(!attributes.mapped && is_array(val)) setValue(array_safe_get(val, 0)); + setArrayDepth(attributes.mapped); + + node.triggerRender(); + }) + .setIcon( THEME.value_use_surface, [ function() { return attributes.mapped; } ], COLORS._main_icon ) + .setTooltip("Use map"); + + mapWidget = new vectorBox(2, function(index, val) { return setValueDirect(val, index); }); + mapWidget.side_button = mapButton; + mapWidget.setMinMax(); + + editWidget.side_button = mapButton; + + return self; + } #endregion + + static mappableStep = function() { #region + editWidget = attributes.mapped? mapWidget : editWidgetRaw; + setArrayDepth(attributes.mapped); + + if(node.inputs[| attributes.map_index].visible != attributes.mapped) { + node.inputs[| attributes.map_index].visible = attributes.mapped; + node.setHeight(); + } + } #endregion + static setColor = function(col) { #region color = col; updateColor(); @@ -2447,6 +2484,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru draw_line_shift_y = struct_try_get(_map, "shift_y"); is_modified = struct_try_get(_map, "is_modified", true); + struct_append(attributes, struct_try_get(_map, "attributes")) name_custom = struct_try_get(_map, "name_custom", false); if(name_custom) name = struct_try_get(_map, "name", name); @@ -2475,9 +2513,15 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru node.input_value_map[$ internalName] = _value; } + attributeApply(); + onValidate(); } #endregion + static attributeApply = function() { #region + if(struct_has(attributes, "mapped")) mappableStep(); + } #endregion + static connect = function(log = false) { #region if(con_node == -1 || con_index == -1) return true; diff --git a/scripts/shader_functions/shader_functions.gml b/scripts/shader_functions/shader_functions.gml index 37da03625..ad509984f 100644 --- a/scripts/shader_functions/shader_functions.gml +++ b/scripts/shader_functions/shader_functions.gml @@ -1,4 +1,4 @@ -function shader_set_i(uniform, value) { +function shader_set_i(uniform, value) { #region INLINE var shader = shader_current(); @@ -19,15 +19,15 @@ function shader_set_i(uniform, value) { array[i - 1] = argument[i]; shader_set_i_array(shader, uniform, array) } -} +} #endregion -function shader_set_i_array(shader, uniform, array) { +function shader_set_i_array(shader, uniform, array) { #region INLINE shader_set_uniform_i_array(shader_get_uniform(shader, uniform), array); -} +} #endregion -function shader_set_f(uniform, value) { +function shader_set_f(uniform, value) { #region INLINE var shader = shader_current(); @@ -63,9 +63,24 @@ function shader_set_f(uniform, value) { array[i - 1] = argument[i]; shader_set_uniform_f_array(shader_get_uniform(shader, uniform), array); } -} +} #endregion -function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) { +function shader_set_f_map(uniform, value, surface, junc) { #region + INLINE + + shader_set_f( uniform, is_array(value)? value : [ value, value ]); + shader_set_i( uniform + "UseSurf", junc.attributes.mapped && is_surface(surface)); + shader_set_surface(uniform + "Surf", surface); +} #endregion + +function shader_set_f_map_s(uniform, value, surface, junc) { #region + INLINE + + shader_set_f(uniform, is_array(value)? value : [ value, value ]); + shader_set_i(uniform + "UseSurf", junc.attributes.mapped && is_surface(surface)); +} #endregion + +function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) { #region INLINE if(!is_array(array)) return; @@ -75,9 +90,9 @@ function shader_set_uniform_f_array_safe(uniform, array, max_length = 128) { if(_len > max_length) array_resize(array, max_length) shader_set_uniform_f_array(uniform, array); -} +} #endregion -function shader_set_surface(sampler, surface, linear = false, _repeat = false) { +function shader_set_surface(sampler, surface, linear = false, _repeat = false) { #region INLINE var shader = shader_current(); @@ -94,32 +109,9 @@ function shader_set_surface(sampler, surface, linear = false, _repeat = false) { gpu_set_tex_repeat_ext(t, _repeat); return t; -} +} #endregion -function shader_set_surface_i(sampler, useSampler, surface) { - INLINE - - shader_set_surface(sampler, surface); - shader_set_i(useSampler, is_surface(surface)); -} - -//function shader_set_surface_ext(sampler, surface, linear = false, _repeat = false) { -// var shader = shader_current(); -// if(!is_surface(surface)) return; - -// if (!GMD3D11_IS_SUPPORTED) { -// shader_set_surface(sampler, surface, linear, _repeat); -// return; -// } - -// var t = shader_get_sampler_index(shader, sampler); -// gpu_set_tex_filter_ext(t, linear); -// gpu_set_tex_repeat_ext(t, _repeat); - -// d3d11_texture_set_stage_ps(t, surface_get_texture(surface)); -//} - -function shader_set_surface_dimension(uniform, surface) { +function shader_set_surface_dimension(uniform, surface) { #region INLINE var shader = shader_current(); @@ -134,23 +126,22 @@ function shader_set_surface_dimension(uniform, surface) { th = 2048; shader_set_uniform_f(shader_get_uniform(shader, uniform), tw, th); -} +} #endregion -function shader_set_dim(uniform = "dimension", surf = noone) { +function shader_set_dim(uniform = "dimension", surf = noone) { #region INLINE if(!is_surface(surf)) return; - shader_set_f(uniform, surface_get_width_safe(surf), surface_get_height_safe(surf)); -} +} #endregion -function shader_set_color(uniform, col, alpha = 1) { +function shader_set_color(uniform, col, alpha = 1) { #region INLINE shader_set_f(uniform, colToVec4(col, alpha)); -} +} #endregion -function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", max_length = 128) { +function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", max_length = 128) { #region INLINE shader_set_i(amo_uni, min(max_length, array_length(pal))); @@ -161,7 +152,7 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount", if(array_length(_pal)) shader_set_f(pal_uni, _pal); -} +} #endregion #region prebuild enum BLEND { diff --git a/scripts/slider/slider.gml b/scripts/slider/slider.gml index 8da777466..6f04f458f 100644 --- a/scripts/slider/slider.gml +++ b/scripts/slider/slider.gml @@ -12,9 +12,10 @@ function slider(_min, _max, _step, _onModify = noone, _onRelease = noone) : widg current_value = 0; slide_speed = 1 / 10; - onModify = _onModify; - onRelease = _onRelease; - onApply = function(val) { + side_button = noone; + onModify = _onModify; + onRelease = _onRelease; + onApply = function(val) { if(onModify) onModify(val); if(onRelease) onRelease(); } @@ -59,6 +60,12 @@ function slider(_min, _max, _step, _onModify = noone, _onRelease = noone) : widg if(!dragging) current_value = _data; + if(side_button) { + side_button.setFocusHover(active, hover); + side_button.draw(_x + _w - ui(32), _y + _h / 2 - ui(32 / 2), ui(32), ui(32), _m, THEME.button_hide); + _w -= ui(40); + } + switch(halign) { #region case fa_left: _x = _x; break; case fa_center: _x = _x - _w / 2; break; diff --git a/scripts/vectorBox/vectorBox.gml b/scripts/vectorBox/vectorBox.gml index 7e0a3d5e6..3f398af65 100644 --- a/scripts/vectorBox/vectorBox.gml +++ b/scripts/vectorBox/vectorBox.gml @@ -51,6 +51,12 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { tb[i].slidable = true; } + static setMinMax = function() { + linkable = false; + axis = [ "min", "max" ]; + return self; + } + static setLinkInactiveColor = function(color) { link_inactive_color = color; return self; @@ -140,7 +146,7 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { for(var i = 0; i < sz; i++) { draw_set_font(f_p0); - var lw = max(ui(24), string_width(axis[i]) + ui(16)); + var lw = sz > 1? max(ui(24), string_width(axis[i]) + ui(16)) : 0; var bx = per_line? _x : _x + ww * i; var by = per_line? _y + (_h + ui(8)) * i : _y; @@ -148,8 +154,10 @@ function vectorBox(_size, _onModify, _unit = noone) : widget() constructor { tb[i].setFocusHover(active, hover); tb[i].draw(bx + lw, by, ww - lw, _h, _data[i], _m); - draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); - draw_text_add(bx + ui(8), by + _h / 2, axis[i]); + if(sz > 1) { + draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text_inner); + draw_text_add(bx + ui(8), by + _h / 2, axis[i]); + } } resetFocus(); diff --git a/shaders/sh_bw/sh_bw.fsh b/shaders/sh_bw/sh_bw.fsh index 24f5d0123..71d473fb7 100644 --- a/shaders/sh_bw/sh_bw.fsh +++ b/shaders/sh_bw/sh_bw.fsh @@ -1,22 +1,34 @@ -// -// Simple passthrough fragment shader -// varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform float brightness; -uniform float contrast; +uniform vec2 brightness; +uniform int brightnessUseSurf; +uniform sampler2D brightnessSurf; + +uniform vec2 contrast; +uniform int contrastUseSurf; +uniform sampler2D contrastSurf; void main() { - vec4 col = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord ); - vec4 col_b = col + vec4(brightness, brightness, brightness, 0.0); - vec4 col_bc = vec4(col_b.rgb * contrast, col_b.a); + float bri = brightness.x; + if(brightnessUseSurf == 1) { + vec4 _vMap = texture2D( brightnessSurf, v_vTexcoord ); + bri = mix(brightness.x, brightness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float con = contrast.x; + if(contrastUseSurf == 1) { + vec4 _vMap = texture2D( contrastSurf, v_vTexcoord ); + con = mix(contrast.x, contrast.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + vec4 col = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord ); + vec4 col_b = col + vec4(bri, bri, bri, 0.0); + vec4 col_bc = vec4(col_b.rgb * con, col_b.a); float bright = dot(col_bc.rgb, vec3(0.2126, 0.7152, 0.0722)); - if(bright > 0.5) - col_bc.rgb = vec3(1.0); - else - col_bc.rgb = vec3(0.0); + if(bright > 0.5) col_bc.rgb = vec3(1.0); + else col_bc.rgb = vec3(0.0); gl_FragColor = col_bc; } diff --git a/shaders/sh_color_adjust/sh_color_adjust.fsh b/shaders/sh_color_adjust/sh_color_adjust.fsh index fa92fed75..b35d47dd2 100644 --- a/shaders/sh_color_adjust/sh_color_adjust.fsh +++ b/shaders/sh_color_adjust/sh_color_adjust.fsh @@ -7,15 +7,28 @@ varying vec4 v_vColour; uniform int use_mask; uniform sampler2D mask; -uniform float brightness; -uniform float contrast; -uniform float exposure; -uniform float hue; -uniform float sat; -uniform float val; +uniform sampler2D param0; +uniform sampler2D param1; -uniform vec4 blend; -uniform int blendMode; +uniform vec2 brightness; +uniform int brightnessUseSurf; +uniform vec2 contrast; +uniform int contrastUseSurf; +uniform vec2 exposure; +uniform int exposureUseSurf; +uniform vec2 hue; +uniform int hueUseSurf; +uniform vec2 sat; +uniform int satUseSurf; +uniform vec2 val; +uniform int valUseSurf; +uniform vec2 alpha; +uniform int alphaUseSurf; + +uniform vec4 blend; +uniform vec2 blendAmount; +uniform int blendAmountUseSurf; +uniform int blendMode; vec3 rgb2hsv(vec3 c) { #region vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); @@ -104,22 +117,74 @@ vec3 rgb2hsl( in vec3 c ) { #region void main() { vec4 col = texture2D( gm_BaseTexture, v_vTexcoord ); + #region get param + vec2 htx = v_vTexcoord * 0.5; + + float bri = brightness.x; + if(brightnessUseSurf == 1) { + vec4 _vMap = texture2D( param0, htx ); + bri = mix(brightness.x, brightness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float exo = exposure.x; + if(exposureUseSurf == 1) { + vec4 _vMap = texture2D( param0, vec2(0.5, 0.0) + htx ); + exo = mix(exposure.x, exposure.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float con = contrast.x; + if(contrastUseSurf == 1) { + vec4 _vMap = texture2D( param0, vec2(0.0, 0.5) + htx ); + con = mix(contrast.x, contrast.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float hhe = hue.x; + if(hueUseSurf == 1) { + vec4 _vMap = texture2D( param0, vec2(0.5, 0.5) + htx ); + hhe = mix(hue.x, hue.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float sst = sat.x; + if(satUseSurf == 1) { + vec4 _vMap = texture2D( param1, htx ); + sst = mix(sat.x, sat.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float vvl = val.x; + if(valUseSurf == 1) { + vec4 _vMap = texture2D( param1, vec2(0.5, 0.0) + htx ); + vvl = mix(val.x, val.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float bld = blendAmount.x; + if(blendAmountUseSurf == 1) { + vec4 _vMap = texture2D( param1, vec2(0.0, 0.5) + htx ); + bld = mix(blendAmount.x, blendAmount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float alp = alpha.x; + if(alphaUseSurf == 1) { + vec4 _vMap = texture2D( param1, vec2(0.5, 0.5) + htx ); + alp = mix(alpha.x, alpha.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + #endregion + //contrast - vec4 col_c = .5 + (contrast * 2.) * (col - .5); + vec4 col_c = .5 + (con * 2.) * (col - .5); col_c = clamp(col_c, vec4(0.), vec4(1.)); //brightness - vec4 col_cb = col_c + vec4(brightness, brightness, brightness, 0.0); + vec4 col_cb = col_c + vec4(bri, bri, bri, 0.0); col_cb = clamp(col_cb, vec4(0.), vec4(1.)); //exposure - col_cb = clamp(col_cb * exposure, vec4(0.), vec4(1.)); + col_cb = clamp(col_cb * exo, vec4(0.), vec4(1.)); //hsv vec3 _hsv = rgb2hsv(col_cb.rgb); - _hsv.x = clamp(_hsv.x + hue, -1., 1.); - _hsv.z = clamp((_hsv.z + val) * (1. + sat * _hsv.y * .5), 0., 1.); - _hsv.y = clamp(_hsv.y * (sat + 1.), 0., 1.); + _hsv.x = clamp(_hsv.x + hhe, -1., 1.); + _hsv.z = clamp((_hsv.z + vvl) * (1. + sst * _hsv.y * .5), 0., 1.); + _hsv.y = clamp(_hsv.y * (sst + 1.), 0., 1.); vec3 _col_cbh = hsv2rgb(_hsv); vec4 col_cbh = vec4(_col_cbh.r, _col_cbh.g, _col_cbh.b, col.a); @@ -143,11 +208,11 @@ void main() { else if(blendMode == 5) bmix = lum > 0.5? (1. - (1. - 2. * (col3 - 0.5)) * (1. - bld3)) : ((2. * col3) * bld3); else if(blendMode == 6) bmix = hsv2rgb(vec3(bhsv.r, chsv.g, chsv.b)); - else if(blendMode == 7) bmix = hsv2rgb(vec3(chsv.r, mix(chsv.g, bhsv.g, blend.a), chsv.b)); + else if(blendMode == 7) bmix = hsv2rgb(vec3(chsv.r, mix(chsv.g, bhsv.g, bld), chsv.b)); else if(blendMode == 8) { vec3 chsl = rgb2hsl(col3); vec3 bhsl = rgb2hsl(bld3); - chsl.z = mix(chsl.z, bhsl.z, blend.a); + chsl.z = mix(chsl.z, bhsl.z, bld); bmix = hsl2rgb(chsl); } else if(blendMode == 9) { @@ -166,7 +231,7 @@ void main() { else if(blendMode == 12) bmix = abs(col3 - bld3); if(blendMode != 7 && blendMode != 8) - col_cbh.rgb = mix(col_cbh.rgb, bmix, blend.a); + col_cbh.rgb = mix(col_cbh.rgb, bmix, bld); else col_cbh.rgb = bmix; @@ -175,9 +240,9 @@ void main() { vec4 mas = texture2D( mask, v_vTexcoord ); mas.rgb *= mas.a; gl_FragColor = col_cbh * mas + col * (vec4(1.) - mas); - gl_FragColor.a = col.a * mix(1., v_vColour.a, mas.r); + gl_FragColor.a = col.a * mix(1., alp, mas.r); } else { gl_FragColor = col_cbh; - gl_FragColor.a = col.a * v_vColour.a; + gl_FragColor.a = col.a * alp; } } diff --git a/shaders/sh_displace/sh_displace.fsh b/shaders/sh_displace/sh_displace.fsh index 40594eb0a..ace17f3da 100644 --- a/shaders/sh_displace/sh_displace.fsh +++ b/shaders/sh_displace/sh_displace.fsh @@ -8,15 +8,15 @@ uniform sampler2D map; uniform vec2 dimension; uniform vec2 map_dimension; uniform vec2 displace; -uniform float strength; uniform float middle; uniform int iterate; uniform int use_rg; uniform int sampleMode; uniform int blendMode; +uniform vec2 strength; +uniform int strengthUseSurf; uniform sampler2D strengthSurf; -uniform int strengthUseSurf; float bright(in vec4 col) { return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * col.a; } @@ -88,11 +88,6 @@ vec2 shiftMap(in vec2 pos, in float str) { #region vec2 raw_displace = displace / dimension; float _str; - if(strengthUseSurf == 1) { - vec4 strMap = texture2Dintp( strengthSurf, pos ); - str *= (strMap.r + strMap.g + strMap.b) / 3.; - } - if(use_rg == 1) { vec2 _disp = vec2(disP.r - middle, disP.g - middle) * vec2((disP.r + disP.g + disP.b) / 3. - middle) * str; @@ -130,13 +125,23 @@ void main() { #region vec2 samPos = v_vTexcoord; vec4 ccol = sampleTexture( v_vTexcoord ), ncol; + float stren = strength.x; + float stMax = strength.x; + if(strengthUseSurf == 1) { + vec4 strMap = texture2Dintp( strengthSurf, v_vTexcoord ); + stren = mix(strength.x, strength.y, (strMap.r + strMap.g + strMap.b) / 3.); + stMax = strength.y; + } + if(iterate == 1) { - for(float i = 0.; i < strength; i++) { + for(float i = 0.; i < stMax; i++) { + if(i >= stren) break; + samPos = shiftMap(samPos, 1.); ncol = blend(ccol, sampleTexture( samPos )); } } else { - samPos = shiftMap(samPos, strength); + samPos = shiftMap(samPos, stren); ncol = sampleTexture( samPos ); } diff --git a/shaders/sh_greyscale/sh_greyscale.fsh b/shaders/sh_greyscale/sh_greyscale.fsh index 974a7c6bb..ade698121 100644 --- a/shaders/sh_greyscale/sh_greyscale.fsh +++ b/shaders/sh_greyscale/sh_greyscale.fsh @@ -4,13 +4,30 @@ varying vec2 v_vTexcoord; varying vec4 v_vColour; -uniform float brightness; -uniform float contrast; +uniform vec2 brightness; +uniform int brightnessUseSurf; +uniform sampler2D brightnessSurf; + +uniform vec2 contrast; +uniform int contrastUseSurf; +uniform sampler2D contrastSurf; void main() { + float bri = brightness.x; + if(brightnessUseSurf == 1) { + vec4 _vMap = texture2D( brightnessSurf, v_vTexcoord ); + bri = mix(brightness.x, brightness.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + float con = contrast.x; + if(contrastUseSurf == 1) { + vec4 _vMap = texture2D( contrastSurf, v_vTexcoord ); + con = mix(contrast.x, contrast.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + vec4 col = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord ); - vec4 col_b = col + vec4(brightness, brightness, brightness, 0.0); - vec4 col_bc = vec4(col_b.rgb * contrast, col_b.a); + vec4 col_b = col + vec4(bri, bri, bri, 0.0); + vec4 col_bc = vec4(col_b.rgb * con, col_b.a); col_bc.rgb = vec3(dot(col_bc.rgb, vec3(0.2126, 0.7152, 0.0722))); diff --git a/shaders/sh_skew/sh_skew.fsh b/shaders/sh_skew/sh_skew.fsh index e097cee89..acf6d0375 100644 --- a/shaders/sh_skew/sh_skew.fsh +++ b/shaders/sh_skew/sh_skew.fsh @@ -7,9 +7,12 @@ varying vec4 v_vColour; uniform vec2 dimension; uniform vec2 center; uniform int axis; -uniform float amount; -/////////////// SAMPLING /////////////// +uniform vec2 amount; +uniform int amountUseSurf; +uniform sampler2D amountSurf; + +#region /////////////// SAMPLING /////////////// const float PI = 3.14159265358979323846; uniform int interpolation; @@ -56,9 +59,9 @@ vec4 texture2Dintp( sampler2D texture, vec2 uv ) { return texture2D( texture, uv ); } -/////////////// SAMPLING /////////////// +#endregion /////////////// SAMPLING /////////////// -vec4 sampleTexture(vec2 pos) { +vec4 sampleTexture(vec2 pos) { #region if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.) return texture2Dintp(gm_BaseTexture, pos); @@ -70,16 +73,20 @@ vec4 sampleTexture(vec2 pos) { return texture2Dintp(gm_BaseTexture, fract(pos)); return vec4(0.); -} +} #endregion void main() { vec2 pos = v_vTexcoord; vec2 cnt = center / dimension; - if(axis == 0) - pos.x += (pos.y - cnt.y) * amount; - else - pos.y += (pos.x - cnt.x) * amount; + float amo = amount.x; + if(amountUseSurf == 1) { + vec4 _vMap = texture2Dintp( amountSurf, v_vTexcoord ); + amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.); + } + + if(axis == 0) pos.x += (pos.y - cnt.y) * amo; + else pos.y += (pos.x - cnt.x) * amo; gl_FragColor = sampleTexture( pos ); }