Pixel-Composer/scripts/node_interlaced/node_interlaced.gml

85 lines
2.3 KiB
Plaintext
Raw Normal View History

2024-06-28 11:54:13 +02:00
function Node_Interlaced(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Interlace";
update_on_frame = true;
use_cache = CACHE_USE.manual;
clearCacheOnChange = false;
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface in", self));
2024-06-28 11:54:13 +02:00
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Bool("Active", self, true));
2024-06-28 11:54:13 +02:00
active_index = 1;
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Surface("Mask", self));
2024-06-28 11:54:13 +02:00
2024-08-18 09:13:41 +02:00
newInput(3, nodeValue_Float("Mix", self, 1))
2024-06-28 11:54:13 +02:00
.setDisplay(VALUE_DISPLAY.slider);
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Toggle("Channel", self, 0b1111, { data: array_create(4, THEME.inspector_channel) }));
2024-06-28 11:54:13 +02:00
__init_mask_modifier(2); // inputs 5, 6
2024-08-18 06:16:20 +02:00
newInput(7, nodeValue_Enum_Button("Axis", self, 0, [ "X", "Y" ]));
2024-06-28 11:54:13 +02:00
2024-08-18 06:16:20 +02:00
newInput(8, nodeValue_Float("Size", self, 1));
2024-06-28 11:54:13 +02:00
2024-08-18 06:16:20 +02:00
newInput(9, nodeValue_Bool("Invert", self, false));
2024-06-28 11:54:13 +02:00
newInput(10, nodeValue_Int("Delay", self, 1));
newInput(11, nodeValue_Bool("Loop", self, false));
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
2024-06-28 11:54:13 +02:00
input_display_list = [ 1,
["Surface", false], 0, 2, 3, 4,
["Frame", false], 10, 11,
["Pattern", false], 7, 8, 9,
2024-06-28 11:54:13 +02:00
];
attribute_surface_depth();
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
static onInspector2Update = function() { clearCache(); }
static step = function() {
2024-06-28 11:54:13 +02:00
__step_mask_modifier();
}
2024-06-28 11:54:13 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[ 0];
var _axis = _data[ 7];
var _size = _data[ 8];
var _invt = _data[ 9];
var _back = _data[10];
var _loop = _data[11];
2024-06-28 11:54:13 +02:00
var _dim = surface_get_dimension(_surf);
var _fram = CURRENT_FRAME - _back;
if(_loop) _fram = (_fram + TOTAL_FRAMES) % TOTAL_FRAMES;
var _prev = array_safe_get_fast(cached_output, _fram, noone);
2024-06-28 11:54:13 +02:00
surface_set_shader(_outSurf, sh_interlaced);
shader_set_i("useSurf", is_surface(_prev));
shader_set_surface("prevFrame", _prev);
2024-06-28 11:54:13 +02:00
shader_set_2("dimension", _dim);
shader_set_i("axis", _axis);
shader_set_i("invert", _invt);
shader_set_f("size", _size);
draw_surface_safe(_surf);
surface_reset_shader();
cacheCurrentFrame(_surf);
2024-06-28 11:54:13 +02:00
__process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[2], _data[3]);
_outSurf = channel_apply(_data[0], _outSurf, _data[4]);
return _outSurf;
}
2024-06-28 11:54:13 +02:00
}