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";
|
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
shader = sh_outline;
|
|
|
|
uniform_dim = shader_get_uniform(shader, "dimension");
|
2023-01-01 02:06:02 +01:00
|
|
|
uniform_border_start = shader_get_uniform(shader, "borderStart");
|
2022-12-21 02:30:23 +01:00
|
|
|
uniform_border_size = shader_get_uniform(shader, "borderSize");
|
|
|
|
uniform_border_color = shader_get_uniform(shader, "borderColor");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
uniform_blend = shader_get_uniform(shader, "is_blend");
|
|
|
|
uniform_blend_alpha = shader_get_uniform(shader, "blend_alpha");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
uniform_side = shader_get_uniform(shader, "side");
|
|
|
|
uniform_aa = shader_get_uniform(shader, "is_aa");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
uniform_out_only = shader_get_uniform(shader, "outline_only");
|
2023-01-01 02:06:02 +01:00
|
|
|
uniform_sam = shader_get_uniform(shader, "sampleMode");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
|
|
|
inputs[| 1] = nodeValue("Width", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0);
|
|
|
|
inputs[| 2] = nodeValue("Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 3] = nodeValue("Blend", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, 0, "Blend outline color with the original color.");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 4] = nodeValue("Blend alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 5] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1)
|
2022-01-19 03:05:13 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.enum_button, ["Inside", "Outside"]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 6] = nodeValue("Anti alising", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, 0);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 7] = nodeValue("Oversample mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "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
|
|
|
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Empty", "Clamp", "Repeat" ]);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 8] = nodeValue("Start", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "Shift outline inside, outside the shape.");
|
|
|
|
|
|
|
|
inputs[| 9] = nodeValue("Mask", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
|
|
|
|
|
|
|
inputs[| 10] = nodeValue("Mix", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 11] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
|
|
|
active_index = 11;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
|
|
|
outputs[| 1] = nodeValue("Outline", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
|
|
|
input_display_list = [ 11,
|
2023-05-03 21:42:17 +02:00
|
|
|
["Output", true], 0, 9, 10,
|
2023-03-21 03:01:53 +01:00
|
|
|
["Outline", false], 1, 5, 8,
|
2023-01-01 02:06:02 +01:00
|
|
|
["Render", false], 2, 3, 4, 6,
|
|
|
|
];
|
|
|
|
|
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
|
|
|
|
2023-08-17 16:56:54 +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 wd = _data[1];
|
|
|
|
var cl = _data[2];
|
|
|
|
|
|
|
|
var blend = _data[3];
|
|
|
|
var alpha = _data[4];
|
|
|
|
var side = _data[5];
|
|
|
|
var aa = _data[6];
|
2023-06-13 14:42:06 +02:00
|
|
|
var sam = struct_try_get(attributes, "oversample");
|
2023-01-01 02:06:02 +01:00
|
|
|
var bst = _data[8];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
surface_set_target(_outSurf);
|
2023-03-19 09:17:39 +01:00
|
|
|
DRAW_CLEAR
|
2023-02-14 05:32:32 +01:00
|
|
|
BLEND_OVERRIDE;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-12-21 02:30:23 +01:00
|
|
|
shader_set(shader);
|
2023-02-14 05:32:32 +01:00
|
|
|
shader_set_uniform_f_array_safe(uniform_dim, [ww, hh]);
|
2023-01-01 02:06:02 +01:00
|
|
|
shader_set_uniform_f(uniform_border_start, bst);
|
2022-01-13 05:24:03 +01:00
|
|
|
shader_set_uniform_f(uniform_border_size, wd);
|
2023-02-14 05:32:32 +01:00
|
|
|
shader_set_uniform_f_array_safe(uniform_border_color, [color_get_red(cl) / 255, color_get_green(cl) / 255, color_get_blue(cl) / 255, 1.0]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
shader_set_uniform_i(uniform_side, side);
|
|
|
|
shader_set_uniform_i(uniform_aa, aa);
|
|
|
|
shader_set_uniform_i(uniform_out_only, _output_index);
|
|
|
|
shader_set_uniform_i(uniform_blend, blend);
|
|
|
|
shader_set_uniform_f(uniform_blend_alpha, alpha);
|
2023-01-01 02:06:02 +01:00
|
|
|
shader_set_uniform_i(uniform_sam, sam);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
draw_surface_safe(_data[0], 0, 0);
|
|
|
|
shader_reset();
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
BLEND_NORMAL;
|
2022-01-13 05:24:03 +01:00
|
|
|
surface_reset_target();
|
|
|
|
|
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;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
static step = function() {
|
2023-10-02 08:57:44 +02:00
|
|
|
var blend = getInputData(3);
|
2022-01-19 06:11:17 +01:00
|
|
|
inputs[| 4].setVisible(blend);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|