Pixel-Composer/scripts/node_combine_rgb/node_combine_rgb.gml

58 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Combine_RGB(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2022-12-27 04:00:50 +01:00
name = "RGB Combine";
shader = sh_combine_rgb;
uniform_r = shader_get_sampler_index(shader, "samR");
uniform_g = shader_get_sampler_index(shader, "samG");
uniform_b = shader_get_sampler_index(shader, "samB");
2023-01-01 02:06:02 +01:00
uniform_a = shader_get_sampler_index(shader, "samA");
uniform_usea = shader_get_uniform(shader, "useA");
uniform_mode = shader_get_uniform(shader, "mode");
2022-12-27 04:00:50 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 0] = nodeValue("Red", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue("Green", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 2] = nodeValue("Blue", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 3] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
2023-01-01 02:06:02 +01:00
2023-02-14 05:32:32 +01:00
inputs[| 4] = nodeValue("Sampling type", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
2023-01-01 02:06:02 +01:00
.setDisplay(VALUE_DISPLAY.enum_scroll, ["Brightness", "Channel value"]);
2022-12-27 04:00:50 +01:00
2023-02-14 05:32:32 +01:00
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
2022-12-27 04:00:50 +01:00
2023-01-01 02:06:02 +01:00
input_display_list = [
["Sampling", false], 4,
2023-05-03 21:42:17 +02:00
["Output", true], 0, 1, 2, 3,
2023-01-01 02:06:02 +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-12-27 04:00:50 +01:00
var _r = _data[0];
var _g = _data[1];
var _b = _data[2];
2023-01-01 02:06:02 +01:00
var _a = _data[3];
var _mode = _data[4];
2022-12-27 04:00:50 +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-12-27 04:00:50 +01:00
shader_set(shader);
texture_set_stage(uniform_r, surface_get_texture(_r));
texture_set_stage(uniform_g, surface_get_texture(_g));
texture_set_stage(uniform_b, surface_get_texture(_b));
2023-01-01 02:06:02 +01:00
shader_set_uniform_i(uniform_mode, _mode);
shader_set_uniform_i(uniform_usea, is_surface(_a));
texture_set_stage(uniform_a, surface_get_texture(_a));
2022-12-27 04:00:50 +01:00
draw_sprite_ext(s_fx_pixel, 0, 0, 0, surface_get_width(_outSurf), surface_get_width(_outSurf), 0, c_white, 1);
shader_reset();
2023-02-14 05:32:32 +01:00
BLEND_NORMAL;
2022-12-27 04:00:50 +01:00
surface_reset_target();
return _outSurf;
}
}