Pixel-Composer/scripts/node_glow/node_glow.gml
2024-09-04 08:57:11 +07:00

72 lines
2.1 KiB
Plaintext

function Node_Glow(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Glow";
newInput(0, nodeValue_Surface("Surface in", self));
newInput(1, nodeValue_Float("Border", self, 0))
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 4, 0.1] });
newInput(2, nodeValue_Float("Size", self, 3))
.setDisplay(VALUE_DISPLAY.slider, { range: [1, 16, 0.1] });
newInput(3, nodeValue_Float("Strength", self, 1))
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 4, 0.01 ]});
newInput(4, nodeValue_Color("Color", self, c_white));
newInput(5, nodeValue_Surface("Mask", self));
newInput(6, nodeValue_Float("Mix", self, 1))
.setDisplay(VALUE_DISPLAY.slider);
newInput(7, nodeValue_Bool("Active", self, true));
active_index = 7;
__init_mask_modifier(5); // inputs 8, 9,
newInput(10, nodeValue_Enum_Button("Mode", self, 0, [ "Greyscale", "Alpha" ]));
newInput(11, nodeValue_Bool("Draw original", self, true));
newInput(12, nodeValue_Enum_Button("Side", self, 0, [ "Outer", "Inner" ]));
input_display_list = [ 7,
["Surfaces", true], 0, 5, 6, 8, 9,
["Glow", false], 10, 12, 2, 3,
["Render", false], 4, 11,
]
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
attribute_surface_depth();
static step = function() { __step_mask_modifier(); }
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _border = _data[1];
var _size = _data[2];
var _strength = _data[3];
var _color = _data[4];
var _mode = _data[10];
var _render = _data[11];
var _side = _data[12];
surface_set_shader(_outSurf, sh_glow);
shader_set_dim("dimension", _data[0]);
shader_set_i("mode", _mode);
shader_set_f("border", _border);
shader_set_f("size", _size);
shader_set_f("strength", _strength);
shader_set_color("color", _color);
shader_set_i("render", _render);
shader_set_i("side", _side);
draw_surface_safe(_data[0]);
surface_reset_shader();
__process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[5], _data[6]);
return _outSurf;
}
}