From ddf0de00d063e634ad2961a7fcbddc5873713d84 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 5 May 2024 09:42:54 +0700 Subject: [PATCH] - [Surface Replace] Fix output not showing up in graph and preview panels. --- scripts/nodeValue_drawer/nodeValue_drawer.gml | 8 +++--- .../node_surface_replace.gml | 25 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/scripts/nodeValue_drawer/nodeValue_drawer.gml b/scripts/nodeValue_drawer/nodeValue_drawer.gml index 742a4b350..8993d346e 100644 --- a/scripts/nodeValue_drawer/nodeValue_drawer.gml +++ b/scripts/nodeValue_drawer/nodeValue_drawer.gml @@ -104,8 +104,8 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc } draw_set_text(_font, fa_left, fa_center, cc); - var lb_w = string_width(_name) + ui(48); - var lb_x = xx + ui(40); + var lb_w = ui(40 + 16) + string_width(_name); + var lb_x = ui(40) + xx; if(jun.color != -1) { #region draw_sprite_ext(THEME.timeline_color, 1, lb_x + ui(8), lb_y, 1, 1, 0, jun.color, 1); @@ -147,7 +147,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc } else draw_sprite_ui(THEME.info, 0, tx, ty,,,, COLORS._main_icon_light, 0.75); - lb_w += ui(56); + lb_w += ui(32); } #endregion @@ -262,7 +262,7 @@ function drawWidget(xx, yy, ww, _m, jun, global_var = true, _hover = false, _foc var _hsy = yy + lb_h; var padd = ui(8); - var labelWidth = max(lb_w, min(ui(80) + ww * 0.2, ui(200))); + var labelWidth = max(lb_w, min(ww * 0.4, ui(200))); var editBoxX = xx + !breakLine * labelWidth; var editBoxY = breakLine? _hsy : yy; diff --git a/scripts/node_surface_replace/node_surface_replace.gml b/scripts/node_surface_replace/node_surface_replace.gml index ba4da62da..188275893 100644 --- a/scripts/node_surface_replace/node_surface_replace.gml +++ b/scripts/node_surface_replace/node_surface_replace.gml @@ -1,6 +1,5 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { name = "Replace Image"; - preview_channel = 1; inputs[| 0] = nodeValue("Base Image", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); @@ -36,14 +35,13 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _ temp_surface = [ surface_create(1, 1) ]; static matchTemplate = function(_index, _surf, _base, _target, _cthr, _pthr, _fst) { + surface_set_shader(_surf, _fst? sh_surface_replace_fast_find : sh_surface_replace_find, false); shader_set_f("dimension", surface_get_width_safe(_base), surface_get_height_safe(_base)); shader_set_surface("target", _target); shader_set_f("targetDimension", surface_get_width_safe(_target), surface_get_height_safe(_target)); - //print($"{surface_get_width_safe(_base)}, {surface_get_height_safe(_base)} | {surface_get_width_safe(_target)}, {surface_get_height_safe(_target)}"); - shader_set_f("colorThreshold", _cthr); shader_set_f("pixelThreshold", _pthr); shader_set_f("index", _index); @@ -61,6 +59,7 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _ } static replaceTemplate = function(_index, _surf, _base, _res, _replace, _fst) { + surface_set_shader(_surf, _fst? sh_surface_replace_fast_replace : sh_surface_replace_replace, false, BLEND.normal); shader_set_f("dimension", surface_get_width_safe(_base), surface_get_height_safe(_base)); shader_set_surface("replace", _replace); @@ -90,25 +89,25 @@ function Node_Surface_Replace(_x, _y, _group = noone) : Node_Processor(_x, _y, _ if(!is_array(_tar)) _tar = [ _tar ]; if(!is_array(_rep)) _rep = [ _rep ]; - temp_surface[0] = surface_verify(temp_surface[0], surface_get_width_safe(_bas), surface_get_height_safe(_bas)); - surface_set_target(temp_surface[0]); - DRAW_CLEAR - surface_reset_target(); + var _sw = surface_get_width_safe(_bas); + var _sh = surface_get_height_safe(_bas); + + temp_surface[0] = surface_verify(temp_surface[0], _sw, _sh); + surface_clear(temp_surface[0]); var amo = array_length(_tar); - for( var i = 0; i < amo; i++ ) - matchTemplate(i / amo, temp_surface[0], _bas, _tar[i], _cthr, _pthr, _fst); - //return temp_surface[0]; + for( var i = 0; i < amo; i++ ) matchTemplate(i / amo, temp_surface[0], _bas, _tar[i], _cthr, _pthr, _fst); + return temp_surface[0]; - _outSurf = surface_verify(_outSurf, surface_get_width_safe(_bas), surface_get_height_safe(_bas)); + _outSurf = surface_verify(_outSurf, _sw, _sh); surface_set_target(_outSurf); DRAW_CLEAR if(_drw) draw_surface_safe(_bas); surface_reset_target(); var amo = array_length(_rep); - for( var i = 0; i < amo; i++ ) - replaceTemplate(i / amo, _outSurf, _bas, temp_surface[0], _rep[i], _fst, _drw); + for( var i = 0; i < amo; i++ ) replaceTemplate(i / amo, _outSurf, _bas, temp_surface[0], _rep[i], _fst); + return _outSurf; } } \ No newline at end of file