- [Surface Replace] Fix output not showing up in graph and preview panels.

This commit is contained in:
Tanasart 2024-05-05 09:42:54 +07:00
parent 09f9b5ee20
commit ddf0de00d0
2 changed files with 16 additions and 17 deletions

View File

@ -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;

View File

@ -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;
}
}