Pixel-Composer/scripts/node_override_channel/node_override_channel.gml

48 lines
1.4 KiB
Plaintext
Raw Normal View History

2024-01-19 09:33:37 +01:00
function Node_Override_Channel(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Override Channel";
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface", self));
2024-01-19 09:33:37 +01:00
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Surface("Red", self));
newInput(2, nodeValue_Surface("Green", self));
newInput(3, nodeValue_Surface("Blue", self));
newInput(4, nodeValue_Surface("Alpha", self));
2024-01-19 09:33:37 +01:00
2024-08-18 06:16:20 +02:00
newInput(5, nodeValue_Enum_Scroll("Sampling type", self, 0, ["Brightness", "Channel value"]));
2024-01-19 09:33:37 +01:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
2024-01-19 09:33:37 +01:00
input_display_list = [ 0,
["Sampling", false], 5,
["Surfaces", true], 1, 2, 3, 4,
]
attribute_surface_depth();
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
var _s = _data[0];
var _r = _data[1];
var _g = _data[2];
var _b = _data[3];
var _a = _data[4];
var _m = _data[5];
surface_set_shader(_outSurf, sh_override_channel);
shader_set_surface("samplerR", _r);
shader_set_surface("samplerG", _g);
shader_set_surface("samplerB", _b);
shader_set_surface("samplerA", _a);
shader_set_i("useR", is_surface(_r));
shader_set_i("useG", is_surface(_g));
shader_set_i("useB", is_surface(_b));
shader_set_i("useA", is_surface(_a));
shader_set_i("mode", _m);
draw_surface_safe(_s);
surface_reset_shader();
return _outSurf;
} #endregion
}