2023-02-28 09:43:01 +01:00
|
|
|
function Node_Outline(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
name = "Outline";
|
2024-06-28 08:40:21 +02:00
|
|
|
batch_output = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-05-27 03:41:41 +02:00
|
|
|
attributes.filter = array_create(9, 1);
|
|
|
|
filtering_vl = false;
|
|
|
|
|
|
|
|
filter_button = new buttonAnchor(function(ind) {
|
2024-05-17 15:25:01 +02:00
|
|
|
if(mouse_press(mb_left))
|
|
|
|
filtering_vl = !attributes.filter[ind];
|
|
|
|
attributes.filter[ind] = filtering_vl;
|
|
|
|
triggerRender();
|
|
|
|
});
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Surface("Surface in", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(1, nodeValue_Int("Width", self, 0))
|
2024-05-17 15:25:01 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY._default, { front_button : filter_button })
|
2024-06-10 05:53:25 +02:00
|
|
|
.setValidator(VV_min(0))
|
2023-12-23 09:39:55 +01:00
|
|
|
.setMappable(15);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Color("Color", self, c_white));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(3, nodeValue_Bool("Blend", self, 0, "Blend outline color with the original color."));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(4, nodeValue_Float("Blend alpha", self, 1))
|
2023-12-23 09:39:55 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
|
|
|
.setMappable(16);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(5, nodeValue_Enum_Button("Position", self, 1, ["Inside", "Outside"]));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(6, nodeValue_Bool("Anti aliasing", self, 0));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(7, nodeValue_Enum_Scroll("Oversample mode", self, 0, [ "Empty", "Clamp", "Repeat" ]))
|
2024-08-07 11:48:39 +02:00
|
|
|
.setTooltip("How to deal with pixel outside the surface.\n - Empty: Use empty pixel\n - Clamp: Repeat edge pixel\n - Repeat: Repeat texture.");
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(8, nodeValue_Int("Start", self, 0, "Shift outline inside, outside the shape."))
|
2023-12-23 09:39:55 +01:00
|
|
|
.setMappable(17);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(9, nodeValue_Surface("Mask", self));
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(10, nodeValue_Float("Mix", self, 1))
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(11, nodeValue_Bool("Active", self, true));
|
2023-02-14 05:32:32 +01:00
|
|
|
active_index = 11;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(12, nodeValue_Bool("Crop border", self, false));
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2023-11-24 10:41:53 +01:00
|
|
|
__init_mask_modifier(9); // inputs 13, 14
|
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(15, nodeValueMap("Width map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(16, nodeValueMap("Blend alpha map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(17, nodeValueMap("Start map", self));
|
2023-12-23 09:39:55 +01:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2024-10-09 09:22:48 +02:00
|
|
|
newInput(18, nodeValue_Enum_Scroll("Profile", self, 0, [ "Circle", "Square", "Diamond" ]));
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(1, nodeValue_Output("Outline", self, VALUE_TYPE.surface, noone));
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
input_display_list = [ 11,
|
2023-11-24 10:41:53 +01:00
|
|
|
["Surfaces", true], 0, 9, 10, 13, 14,
|
2024-10-09 09:22:48 +02:00
|
|
|
["Outline", false], 18, 1, 15, 5, 8, 17, 12,
|
2024-01-09 03:39:40 +01:00
|
|
|
["Render", false], 2, 6,
|
|
|
|
["Blend", true, 3], 4, 16,
|
2023-01-01 02:06:02 +01:00
|
|
|
];
|
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attribute_surface_depth();
|
2023-03-21 03:01:53 +01:00
|
|
|
attribute_oversample();
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2024-10-09 09:22:48 +02:00
|
|
|
static step = function() {
|
2024-05-17 15:25:01 +02:00
|
|
|
var _wid = getInputData(1);
|
2023-10-23 11:39:41 +02:00
|
|
|
var _side = getInputData(5);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[12].setVisible(_side == 0);
|
2023-11-24 10:41:53 +01:00
|
|
|
|
|
|
|
__step_mask_modifier();
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1].mappableStep();
|
|
|
|
inputs[4].mappableStep();
|
|
|
|
inputs[8].mappableStep();
|
2024-05-18 04:26:19 +02:00
|
|
|
|
|
|
|
filter_button.index = attributes.filter;
|
2024-10-09 09:22:48 +02:00
|
|
|
}
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2024-10-09 09:22:48 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
2023-09-08 21:37:36 +02:00
|
|
|
var ww = surface_get_width_safe(_data[0]);
|
|
|
|
var hh = surface_get_height_safe(_data[0]);
|
2022-01-13 05:24:03 +01:00
|
|
|
var cl = _data[2];
|
|
|
|
|
|
|
|
var blend = _data[3];
|
|
|
|
var side = _data[5];
|
|
|
|
var aa = _data[6];
|
2023-06-13 14:42:06 +02:00
|
|
|
var sam = struct_try_get(attributes, "oversample");
|
2023-10-23 11:39:41 +02:00
|
|
|
var _crop = _data[12];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
surface_set_shader(_outSurf, sh_outline);
|
2023-12-23 09:39:55 +01:00
|
|
|
shader_set_f("dimension", ww, hh);
|
2024-08-08 06:57:51 +02:00
|
|
|
shader_set_f_map("borderSize", _data[1], _data[15], inputs[1]);
|
|
|
|
shader_set_f_map("borderStart", _data[8], _data[17], inputs[8]);
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_color("borderColor", cl);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-10-09 09:22:48 +02:00
|
|
|
shader_set_i("profile", _data[18]);
|
2023-12-23 09:39:55 +01:00
|
|
|
shader_set_i("side", side);
|
2024-06-10 05:53:25 +02:00
|
|
|
shader_set_i("highRes", 0);
|
2023-12-23 09:39:55 +01:00
|
|
|
shader_set_i("is_aa", aa);
|
|
|
|
shader_set_i("outline_only", _output_index);
|
|
|
|
shader_set_i("is_blend", blend);
|
2024-08-08 06:57:51 +02:00
|
|
|
shader_set_f_map("blend_alpha", _data[4], _data[16], inputs[4]);
|
2023-12-23 09:39:55 +01:00
|
|
|
shader_set_i("sampleMode", sam);
|
|
|
|
shader_set_i("crop_border", _crop);
|
2024-05-17 15:25:01 +02:00
|
|
|
shader_set_i("filter", attributes.filter);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
draw_surface_safe(_data[0]);
|
2023-10-23 11:39:41 +02:00
|
|
|
surface_reset_shader();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-24 10:41:53 +01:00
|
|
|
__process_mask_modifier(_data);
|
2023-02-14 05:32:32 +01:00
|
|
|
_outSurf = mask_apply(_data[0], _outSurf, _data[9], _data[10]);
|
|
|
|
|
2022-12-27 04:00:50 +01:00
|
|
|
return _outSurf;
|
2024-10-09 09:22:48 +02:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|