Pixel-Composer/scripts/node_pixel_cloud/node_pixel_cloud.gml

98 lines
3.4 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Pixel_Cloud(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2022-01-14 02:44:58 +01:00
name = "Pixel Cloud";
2022-12-21 02:30:23 +01:00
shader = sh_pixel_cloud;
uniform_sed = shader_get_uniform(shader, "seed");
uniform_str = shader_get_uniform(shader, "strength");
uniform_dis = shader_get_uniform(shader, "dist");
2022-01-14 02:44:58 +01:00
2022-12-21 02:30:23 +01:00
uniform_map_use = shader_get_uniform(shader, "useMap");
2023-02-14 05:32:32 +01:00
uniform_map = shader_get_sampler_index(shader, "strengthMap");
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
uniform_grad_blend = shader_get_uniform(shader, "gradient_blend");
uniform_grad = shader_get_uniform(shader, "gradient_color");
uniform_grad_time = shader_get_uniform(shader, "gradient_time");
uniform_grad_key = shader_get_uniform(shader, "gradient_keys");
2022-01-14 02:44:58 +01:00
2022-12-21 02:30:23 +01:00
uniform_alpha = shader_get_uniform(shader, "alpha_curve");
2023-02-14 05:32:32 +01:00
uniform_alamo = shader_get_uniform(shader, "curve_amount");
uniform_rnd = shader_get_uniform(shader, "randomAmount");
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 1] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, irandom(100000));
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 2] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
2023-01-17 08:11:55 +01:00
.setDisplay(VALUE_DISPLAY.slider, [ 0, 2, 0.01]);
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 3] = nodeValue("Strength map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
2022-01-14 02:44:58 +01:00
2023-03-02 07:59:14 +01:00
inputs[| 4] = nodeValue("Color over lifetime", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, new gradientObject(c_white) )
2022-01-14 02:44:58 +01:00
.setDisplay(VALUE_DISPLAY.gradient);
2023-02-14 05:32:32 +01:00
inputs[| 5] = nodeValue("Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 6] = nodeValue("Alpha over lifetime", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11);
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 7] = nodeValue("Random blending", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
.setDisplay(VALUE_DISPLAY.slider, [ 0, 1, 0.01]);
inputs[| 8] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 8;
input_display_list = [ 8,
2022-01-14 02:44:58 +01:00
["Input", true], 0, 1,
["Movement", false], 5, 2, 3,
2023-02-14 05:32:32 +01:00
["Color", true], 4, 6, 7
2022-01-14 02:44:58 +01:00
]
2023-02-14 05:32:32 +01:00
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
2022-01-14 02:44:58 +01:00
2023-03-19 09:17:39 +01:00
attribute_surface_depth();
2023-01-01 02:06:02 +01:00
static process_data = function(_outSurf, _data, _output_index, _array_index) {
2022-01-14 02:44:58 +01:00
var _sed = _data[1];
var _str = _data[2];
2023-03-02 07:59:14 +01:00
var _map = _data[3];
var _gra = _data[4];
2022-01-14 02:44:58 +01:00
var _dis = _data[5];
var _alp = _data[6];
2023-02-14 05:32:32 +01:00
var _rnd = _data[7];
2022-01-14 02:44:58 +01:00
2023-03-02 07:59:14 +01:00
var _grad = _gra.toArray();
2023-02-14 05:32:32 +01:00
var _grad_color = _grad[0];
var _grad_time = _grad[1];
2022-01-14 02:44:58 +01:00
surface_set_target(_outSurf);
2023-03-19 09:17:39 +01:00
DRAW_CLEAR
2023-02-14 05:32:32 +01:00
BLEND_OVERRIDE;
2022-01-14 02:44:58 +01:00
2022-12-21 02:30:23 +01:00
shader_set(shader);
2022-01-14 02:44:58 +01:00
shader_set_uniform_f(uniform_sed, _sed);
shader_set_uniform_f(uniform_str, _str);
shader_set_uniform_f(uniform_dis, _dis);
if(is_surface(_map)) {
shader_set_uniform_i(uniform_map_use, 1);
texture_set_stage(uniform_map, surface_get_texture(_map));
} else {
shader_set_uniform_i(uniform_map_use, 0);
}
2023-03-02 07:59:14 +01:00
shader_set_uniform_i(uniform_grad_blend, _gra.type);
2023-02-14 05:32:32 +01:00
shader_set_uniform_f_array_safe(uniform_grad, _grad_color);
shader_set_uniform_f_array_safe(uniform_grad_time, _grad_time);
2023-03-02 07:59:14 +01:00
shader_set_uniform_i(uniform_grad_key, array_length(_gra.keys));
2022-01-14 02:44:58 +01:00
2023-02-14 05:32:32 +01:00
shader_set_uniform_f_array_safe(uniform_alpha, _alp);
shader_set_uniform_i(uniform_alamo, array_length(_alp));
shader_set_uniform_f(uniform_rnd, _rnd);
2022-01-14 02:44:58 +01:00
draw_surface_safe(_data[0], 0, 0);
shader_reset();
2023-02-14 05:32:32 +01:00
BLEND_NORMAL;
2022-01-14 02:44:58 +01:00
surface_reset_target();
return _outSurf;
}
}