Pixel-Composer/scripts/node_de_stray/node_de_stray.gml

79 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_De_Stray(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "De-Stray";
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface in", self));
2023-01-25 06:49:00 +01:00
2024-08-08 06:57:51 +02:00
inputs[1] = nodeValue_Float("Tolerance", self, 0)
.setDisplay(VALUE_DISPLAY.slider);
2022-01-13 05:24:03 +01:00
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Bool("Active", self, true));
2023-02-14 05:32:32 +01:00
active_index = 2;
2024-08-08 06:57:51 +02:00
inputs[3] = nodeValue_Int("Iteration", self, 2)
2024-03-27 11:51:14 +01:00
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Enum_Button("Strictness", self, 0, [ "Low", "High", "Stray-only" ]));
2024-03-27 11:51:14 +01:00
2024-08-18 06:16:20 +02:00
newInput(5, nodeValue_Surface("Mask", self));
2024-03-27 11:51:14 +01:00
2024-08-08 06:57:51 +02:00
inputs[6] = nodeValue_Float("Mix", self, 1)
2024-03-27 11:51:14 +01:00
.setDisplay(VALUE_DISPLAY.slider);
__init_mask_modifier(5); // inputs 7, 8,
2024-08-18 06:16:20 +02:00
newInput(9, nodeValue_Bool("Fill Empty", self, false));
2024-05-11 14:36:19 +02:00
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone);
2023-02-14 05:32:32 +01:00
2024-03-27 11:51:14 +01:00
input_display_list = [ 2,
["Surfaces", true], 0, 5, 6, 7, 8,
2024-05-11 14:36:19 +02:00
["Effect", false], 4, 1, 3, 9,
2023-02-14 05:32:32 +01:00
]
2022-01-13 05:24:03 +01:00
2023-03-19 09:17:39 +01:00
attribute_surface_depth();
2024-03-27 11:51:14 +01:00
temp_surface = [ noone, noone ];
static step = function() { #region
__step_mask_modifier();
} #endregion
2023-09-14 16:29:39 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
2024-03-27 11:51:14 +01:00
var surf = _data[0];
var _tol = _data[1];
var _itr = _data[3];
var _str = _data[4];
2024-05-11 14:36:19 +02:00
var _fil = _data[9];
2024-03-27 11:51:14 +01:00
var _sw = surface_get_width_safe(surf);
var _sh = surface_get_height_safe(surf);
for( var i = 0; i < 2; i++ ) temp_surface[i] = surface_verify(temp_surface[i], _sw, _sh);
var _bg = 0;
surface_set_shader(temp_surface[1]);
draw_surface_safe(surf);
surface_reset_shader();
repeat(_itr) {
surface_set_shader(temp_surface[_bg], sh_de_stray);
shader_set_f("dimension", _sw, _sh);
shader_set_f("tolerance", _tol);
shader_set_i("strict", _str);
2024-05-11 14:36:19 +02:00
shader_set_i("fill", _fil);
2024-03-27 11:51:14 +01:00
draw_surface_safe(temp_surface[!_bg]);
surface_reset_shader();
2022-01-13 05:24:03 +01:00
2024-03-27 11:51:14 +01:00
_bg = !_bg;
}
surface_set_shader(_outSurf);
draw_surface_safe(temp_surface[!_bg]);
2023-04-08 20:06:27 +02:00
surface_reset_shader();
2022-01-13 05:24:03 +01:00
2024-03-27 11:51:14 +01:00
__process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[5], _data[6]);
2022-01-13 05:24:03 +01:00
return _outSurf;
2023-09-14 16:29:39 +02:00
} #endregion
2022-01-13 05:24:03 +01:00
}