Pixel-Composer/scripts/node_tile_random/node_tile_random.gml

39 lines
1.1 KiB
Text
Raw Normal View History

2023-12-10 14:55:05 +01:00
function Node_Tile_Random(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Tile Random";
dimension_index = -1;
2024-08-08 06:57:51 +02:00
inputs[0] = nodeValue_Surface("Surface in", self);
2023-12-10 14:55:05 +01:00
2024-08-08 06:57:51 +02:00
inputs[1] = nodeValue_Dimension(self);
2023-12-10 14:55:05 +01:00
2024-08-08 06:57:51 +02:00
inputs[2] = nodeValue_Float("Randomness", self, 0.5)
2023-12-10 14:55:05 +01:00
.setDisplay(VALUE_DISPLAY.slider);
2024-08-08 06:57:51 +02:00
outputs[0] = nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone);
2023-12-10 14:55:05 +01:00
input_display_list = [ 1,
["Surfaces", true], 0,
["Tiling", false], 2,
];
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
var dim = _data[1];
var rand = _data[2];
var _sw = surface_get_width_safe(_surf);
var _sh = surface_get_height_safe(_surf);
_outSurf = surface_verify(_outSurf, dim[0], dim[1]);
surface_set_shader(_outSurf, sh_tile_random);
shader_set_surface("surface", _surf);
shader_set_f("blend", rand);
shader_set_f("scale", dim[0] / _sw, dim[1] / _sh);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, dim[0], dim[1]);
surface_reset_shader();
return _outSurf;
}
}