Pixel-Composer/scripts/node_blend_edge/node_blend_edge.gml

85 lines
2.5 KiB
Text
Raw Normal View History

2024-02-01 05:26:02 +01:00
function Node_Blend_Edge(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Blend Edge";
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface in", self));
2024-02-01 05:26:02 +01:00
2024-08-18 09:13:41 +02:00
newInput(1, nodeValue_Float("Width", self, 0.1))
2024-02-01 05:26:02 +01:00
.setDisplay(VALUE_DISPLAY.slider)
.setMappable(5);
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Enum_Button("Types",self, 0, [ "Both", "Horizontal", "Vertical" ]));
2024-02-01 05:26:02 +01:00
2024-08-18 06:16:20 +02:00
newInput(3, nodeValue_Bool("Active", self, true));
2024-02-01 05:26:02 +01:00
active_index = 3;
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Toggle("Channel", self, 0b1111, { data: array_create(4, THEME.inspector_channel) }));
2024-02-01 05:26:02 +01:00
/////////////////////////////////////////////////////////////////////////////////////////////////////
2024-08-18 09:13:41 +02:00
newInput(5, nodeValue_Surface("Width map", self))
2024-02-01 05:26:02 +01:00
.setVisible(false, false);
/////////////////////////////////////////////////////////////////////////////////////////////////////
2024-08-18 09:13:41 +02:00
newInput(6, nodeValue_Float("Blending", self, 1))
2024-02-01 05:26:02 +01:00
.setDisplay(VALUE_DISPLAY.slider);
2024-08-18 09:13:41 +02:00
newInput(7, nodeValue_Float("Smoothness", self, 0))
2024-06-12 10:06:17 +02:00
.setDisplay(VALUE_DISPLAY.slider);
2024-02-01 05:26:02 +01:00
input_display_list = [ 3, 4,
["Surfaces", true], 0,
2024-06-12 10:06:17 +02:00
["Blend", false], 2, 1, 5, 6, 7,
2024-02-01 05:26:02 +01:00
]
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone);
2024-02-01 05:26:02 +01:00
temp_surface = array_create(1);
attribute_surface_depth();
static step = function() { #region
2024-08-08 06:57:51 +02:00
inputs[1].mappableStep();
2024-02-01 05:26:02 +01:00
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _sw = surface_get_width_safe(_data[0]);
var _sh = surface_get_height_safe(_data[0]);
for( var i = 0, n = array_length(temp_surface); i < n; i++ )
temp_surface[i] = surface_verify(temp_surface[i], _sw, _sh);
2024-06-12 10:06:17 +02:00
var _edg = _data[2];
2024-02-01 05:26:02 +01:00
2024-06-12 10:06:17 +02:00
if(_edg == 0) {
surface_set_shader(temp_surface[0], sh_blend_edge);
shader_set_f("dimension", _sw, _sh);
2024-08-08 06:57:51 +02:00
shader_set_f_map("width", _data[1], _data[5], inputs[1]);
2024-06-12 10:06:17 +02:00
shader_set_i("edge" , 0);
shader_set_f("blend" , clamp(_data[6], 0.001, 0.999));
shader_set_f("smooth" , _data[7]);
draw_surface_safe(_data[0]);
2024-06-12 10:06:17 +02:00
surface_reset_shader();
surface_set_shader(_outSurf, sh_blend_edge);
shader_set_i("edge" , 1);
draw_surface_safe(temp_surface[0]);
2024-06-12 10:06:17 +02:00
surface_reset_shader();
} else {
surface_set_shader(_outSurf, sh_blend_edge);
shader_set_f("dimension", _sw, _sh);
2024-08-08 06:57:51 +02:00
shader_set_f_map("width", _data[1], _data[5], inputs[1]);
2024-06-12 10:06:17 +02:00
shader_set_i("edge" , _edg - 1);
shader_set_f("blend" , clamp(_data[6], 0.001, 0.999));
draw_surface_safe(_data[0]);
2024-06-12 10:06:17 +02:00
surface_reset_shader();
}
2024-02-01 05:26:02 +01:00
return _outSurf;
}
}