Pixel-Composer/scripts/node_de_stray/node_de_stray.gml

79 lines
2.3 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-07 11:48:39 +02:00
inputs[| 0] = nodeValue_Surface("Surface in", self);
2023-01-25 06:49:00 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 1] = nodeValue("Tolerance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider);
2022-01-13 05:24:03 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 2;
2024-03-27 11:51:14 +01:00
inputs[| 3] = nodeValue("Iteration", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 2)
2024-08-07 11:48:39 +02:00
inputs[| 4] = nodeValue_Enum_Button("Strictness", self, 0, [ "Low", "High", "Stray-only" ]);
2024-03-27 11:51:14 +01:00
2024-08-07 11:48:39 +02:00
inputs[| 5] = nodeValue_Surface("Mask", self);
2024-03-27 11:51:14 +01:00
inputs[| 6] = nodeValue("Mix", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider);
__init_mask_modifier(5); // inputs 7, 8,
2024-05-11 14:36:19 +02:00
inputs[| 9] = nodeValue("Fill Empty", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
2023-02-14 05:32:32 +01:00
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
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
}