Pixel-Composer/scripts/node_atlas_draw/node_atlas_draw.gml

43 lines
1.1 KiB
Text
Raw Permalink Normal View History

function Node_Atlas_Draw(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2023-04-16 15:26:52 +02:00
name = "Draw Atlas";
previewable = true;
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Dimension(self));
2023-04-16 15:26:52 +02:00
newInput(1, nodeValue_Atlas("Atlas", self))
.setArrayDepth(1)
2023-04-16 15:26:52 +02:00
.setVisible(true, true);
newInput(2, nodeValue_Bool("Combine", self, true))
.rejectArray()
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface", self, VALUE_TYPE.surface, noone));
2023-04-16 15:26:52 +02:00
attribute_interpolation(true);
input_display_list = [
0, 1, 2,
];
static preGetInputs = function() {
var _comb = getSingleValue(2);
inputs[1].setArrayDepth(_comb);
}
static processData = function(_outSurf, _data, _output_index, _array_index = 0) {
var dim = _data[0];
var atl = _data[1];
2023-04-16 15:26:52 +02:00
surface_set_shader(_outSurf);
if(!is_array(atl)) {
if(is(atl, Atlas)) { shader_set_interpolation(atl.getSurface()); atl.draw(); }
} else {
for( var i = 0, n = array_length(atl); i < n; i++ )
if(is(atl[i], Atlas)) { shader_set_interpolation(atl[i].getSurface()); atl[i].draw(); }
}
2023-04-16 15:26:52 +02:00
surface_reset_shader();
return _outSurf;
2023-04-16 15:26:52 +02:00
}
}