Pixel-Composer/scripts/node_repeat_texture/node_repeat_texture.gml

48 lines
1.5 KiB
Plaintext
Raw Normal View History

2024-06-13 12:28:02 +02:00
function Node_Repeat_Texture(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Repeat Texture";
dimension_index = 1;
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface in", self));
2024-06-13 12:28:02 +02:00
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Vec2("Target dimension", self, DEF_SURF));
2024-06-13 12:28:02 +02:00
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Enum_Scroll("Type", self, 1, [ "Tile", "Scatter", "Cell" ]));
2024-06-13 12:28:02 +02:00
2024-08-18 09:13:41 +02:00
newInput(3, nodeValue_Float("Seed", self, seed_random(6)))
2024-08-08 06:57:51 +02:00
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[3].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) })
2024-06-13 12:28:02 +02:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
2024-06-13 12:28:02 +02:00
input_display_list = [ 3,
["Surfaces", false], 0,
["Repeat", false], 1, 2,
];
attribute_surface_depth();
static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
var _dim = _data[1];
var _type = _data[2];
var _seed = _data[3];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
if(!is_surface(_surf)) return _outSurf;
2024-06-13 12:28:02 +02:00
var _sdim = surface_get_dimension(_surf);
gpu_set_texrepeat(1);
surface_set_shader(_outSurf, sh_texture_repeat);
shader_set_f("seed", _seed);
shader_set_f("dimension", _dim);
shader_set_f("surfaceDimension", _sdim);
shader_set_surface("surface", _surf);
shader_set_i("type", _type);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
surface_reset_shader();
gpu_set_texrepeat(0);
return _outSurf;
}
}