Pixel-Composer/scripts/node_noise_aniso/node_noise_aniso.gml

85 lines
2.8 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Noise_Aniso(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2023-01-25 06:49:00 +01:00
name = "Anisotropic Noise";
2022-01-13 05:24:03 +01:00
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Dimension(self));
2022-01-13 05:24:03 +01:00
2024-08-18 09:13:41 +02:00
newInput(1, nodeValue_Float("X Amount", self, 2))
2023-12-23 09:39:55 +01:00
.setMappable(6);
2022-01-13 05:24:03 +01:00
2024-08-18 09:13:41 +02:00
newInput(2, 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[2].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
2022-01-13 05:24:03 +01:00
2024-08-18 09:13:41 +02:00
newInput(3, nodeValue_Vec2("Position", self, [ 0, 0 ]))
2022-12-27 13:30:02 +01:00
.setUnitRef(function(index) { return getDimension(index); });
2022-01-13 05:24:03 +01:00
2024-08-18 09:13:41 +02:00
newInput(4, nodeValue_Rotation("Rotation", self, 0))
2023-12-23 09:39:55 +01:00
.setMappable(8);
2024-08-18 09:13:41 +02:00
newInput(5, nodeValue_Float("Y Amount", self, 16))
2023-12-23 09:39:55 +01:00
.setMappable(7);
//////////////////////////////////////////////////////////////////////////////////////////////////
2024-08-18 06:16:20 +02:00
newInput(6, nodeValueMap("X Amount map", self));
2023-12-23 09:39:55 +01:00
2024-08-18 06:16:20 +02:00
newInput(7, nodeValueMap("Y Amount map", self));
2023-12-23 09:39:55 +01:00
2024-08-18 06:16:20 +02:00
newInput(8, nodeValueMap("Rotation map", self));
2023-12-23 09:39:55 +01:00
//////////////////////////////////////////////////////////////////////////////////////////////////
2022-12-13 09:20:36 +01:00
2024-08-18 09:13:41 +02:00
newInput(9, nodeValue_Enum_Scroll("Render mode", self, 0, [ "Blend", "Waterfall" ] ))
newInput(10, nodeValue_Float("Color Seed", self, seed_random(6)))
.setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[2].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) });
2022-01-13 05:24:03 +01:00
input_display_list = [
["Output", false], 0,
["Noise", false], 2, 1, 6, 5, 7, 3, 4, 8,
["Render", false], 9, 10,
2022-01-13 05:24:03 +01:00
];
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
2022-01-13 05:24:03 +01:00
2023-03-19 09:17:39 +01:00
attribute_surface_depth();
2024-03-14 14:35:19 +01:00
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
2024-07-02 12:18:32 +02:00
var _hov = false;
2024-08-08 06:57:51 +02:00
var hv = inputs[3].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv;
2024-07-02 12:18:32 +02:00
return _hov;
}
static step = function() {
2024-08-08 06:57:51 +02:00
inputs[1].mappableStep();
inputs[4].mappableStep();
inputs[5].mappableStep();
}
2023-12-23 09:39:55 +01:00
2023-08-17 16:56:54 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) {
2022-12-22 03:09:55 +01:00
var _dim = _data[0];
var _pos = _data[3];
var _mod = _data[9];
inputs[10].setVisible(_mod == 0);
2022-01-13 05:24:03 +01:00
2023-03-19 09:17:39 +01:00
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
2022-01-13 05:24:03 +01:00
2023-12-23 09:39:55 +01:00
surface_set_shader(_outSurf, sh_ani_noise);
shader_set_2("dimension", _dim);
2023-12-23 09:39:55 +01:00
shader_set_f("position", _pos[0] / _dim[0], _pos[1] / _dim[1]);
shader_set_f("seed", _data[2]);
shader_set_f("colrSeed", _data[10]);
2023-12-23 09:39:55 +01:00
2024-08-08 06:57:51 +02:00
shader_set_f_map("noiseX", _data[1], _data[6], inputs[1]);
shader_set_f_map("noiseY", _data[5], _data[7], inputs[5]);
shader_set_f_map("angle", _data[4], _data[8], inputs[4]);
2022-01-13 05:24:03 +01:00
shader_set_i("mode", _mod);
2023-12-23 09:39:55 +01:00
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
surface_reset_shader();
2022-12-22 03:09:55 +01:00
return _outSurf;
2022-01-13 05:24:03 +01:00
}
}