Pixel-Composer/scripts/node_combine_hsv/node_combine_hsv.gml

65 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Combine_HSV(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
2022-12-27 04:00:50 +01:00
name = "HSV Combine";
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Hue", self));
newInput(1, nodeValue_Surface("Saturation", self));
newInput(2, nodeValue_Surface("Value", self));
newInput(3, nodeValue_Surface("Alpha", self));
2024-03-17 14:24:24 +01:00
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Bool("Array Input", self, false));
2024-03-17 14:24:24 +01:00
2024-08-18 09:13:41 +02:00
newInput(5, nodeValue_Surface("HSV Array", self, []))
2024-03-17 14:24:24 +01:00
.setArrayDepth(1);
2022-12-27 04:00:50 +01:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
2022-12-27 04:00:50 +01:00
2024-03-17 14:24:24 +01:00
input_display_list = [
["Surfaces", true], 4, 0, 1, 2, 3, 5,
]
2023-03-19 09:17:39 +01:00
attribute_surface_depth();
2024-03-17 14:24:24 +01:00
static step = function() { #region
var _arr = getInputData(4);
2024-08-08 06:57:51 +02:00
inputs[0].setVisible(!_arr, !_arr);
inputs[1].setVisible(!_arr, !_arr);
inputs[2].setVisible(!_arr, !_arr);
inputs[3].setVisible(!_arr, !_arr);
2024-03-17 14:24:24 +01:00
2024-08-08 06:57:51 +02:00
inputs[5].setVisible(_arr, _arr);
2024-03-17 14:24:24 +01:00
} #endregion
2023-09-14 16:29:39 +02:00
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
2024-03-17 14:24:24 +01:00
var _arr = _data[4];
2022-12-27 04:00:50 +01:00
2024-03-31 05:36:11 +02:00
var _h = _arr? array_safe_get_fast(_data[5], 0) : _data[0];
var _s = _arr? array_safe_get_fast(_data[5], 1) : _data[1];
var _v = _arr? array_safe_get_fast(_data[5], 2) : _data[2];
var _a = _arr? array_safe_get_fast(_data[5], 3) : _data[3];
2022-12-27 04:00:50 +01:00
2024-03-19 09:49:29 +01:00
var _baseS = is_surface(_h)? _h : (is_surface(_s)? _s : _v);
if(!is_surface(_baseS)) return _outSurf;
var _ww = surface_get_width_safe(_baseS);
var _hh = surface_get_height_safe(_baseS);
_outSurf = surface_verify(_outSurf, _ww, _hh);
2024-03-17 14:24:24 +01:00
surface_set_shader(_outSurf, sh_combine_hsv);
shader_set_surface("samH", _h);
shader_set_surface("samS", _s);
shader_set_surface("samV", _v);
shader_set_surface("samA", _a);
2022-12-27 04:00:50 +01:00
2024-03-17 14:24:24 +01:00
shader_set_i("useH", is_surface(_h));
shader_set_i("useS", is_surface(_s));
shader_set_i("useV", is_surface(_v));
shader_set_i("useA", is_surface(_a));
2024-03-19 09:49:29 +01:00
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _ww, _hh);
2024-03-17 14:24:24 +01:00
surface_reset_shader();
2022-12-27 04:00:50 +01:00
return _outSurf;
2023-09-14 16:29:39 +02:00
} #endregion
2022-12-27 04:00:50 +01:00
}