2023-02-28 09:43:01 +01:00
|
|
|
function Node_Level(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
name = "Level";
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Surface("Surface in", self));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Slider_Range("White in", self, [0, 1]));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Slider_Range("Red in", self, [0, 1]));
|
2022-12-27 04:00:50 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(3, nodeValue_Slider_Range("Green in", self, [0, 1]));
|
2022-12-27 04:00:50 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(4, nodeValue_Slider_Range("Blue in", self, [0, 1]));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(5, nodeValue_Slider_Range("Alpha in", self, [0, 1]));
|
2023-01-01 02:06:02 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(6, nodeValue_Surface("Mask", self));
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[7] = nodeValue_Float("Mix", self, 1)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(8, nodeValue_Bool("Active", self, true));
|
2023-02-14 05:32:32 +01:00
|
|
|
active_index = 8;
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(9, nodeValue_Toggle("Channel", self, 0b1111, { data: array_create(4, THEME.inspector_channel) }));
|
2023-11-09 04:02:41 +01:00
|
|
|
|
2023-11-24 10:41:53 +01:00
|
|
|
__init_mask_modifier(6); // inputs 10, 11
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(12, nodeValue_Slider_Range("White out", self, [0, 1]));
|
2024-01-30 15:04:56 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(13, nodeValue_Slider_Range("Red out", self, [0, 1]));
|
2024-01-30 15:04:56 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(14, nodeValue_Slider_Range("Green out", self, [0, 1]));
|
2024-01-30 15:04:56 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(15, nodeValue_Slider_Range("Blue out", self, [0, 1]));
|
2024-01-30 15:04:56 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(16, nodeValue_Slider_Range("Alpha out", self, [0, 1]));
|
2024-01-30 15:04:56 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[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();
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
level_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region
|
2022-09-23 13:28:42 +02:00
|
|
|
var _h = 128;
|
|
|
|
var x0 = _x;
|
|
|
|
var x1 = _x + _w;
|
|
|
|
var y0 = _y;
|
|
|
|
var y1 = _y + _h;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.node_level_shade);
|
2023-10-02 08:57:44 +02:00
|
|
|
var _wh = getInputData(1);
|
2022-12-27 04:00:50 +01:00
|
|
|
var _wmin = min(_wh[0], _wh[1]);
|
|
|
|
var _wmax = max(_wh[0], _wh[1]);
|
|
|
|
|
|
|
|
draw_rectangle(x0, y0, x0 + max(0, _wmin) * _w, y1, false);
|
|
|
|
draw_rectangle(x0 + min(1, _wmax) * _w, y0, x1, y1, false);
|
2022-09-23 13:28:42 +02:00
|
|
|
|
|
|
|
for( var i = 0; i < 4; i++ ) {
|
|
|
|
var _bx = x1 - 20 - i * 24;
|
2022-11-03 11:44:49 +01:00
|
|
|
var _by = y0;
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
if(buttonInstant(THEME.button_hide, _bx, _by, 20, 20, _m, _focus, _hover) == 2)
|
2022-09-23 13:28:42 +02:00
|
|
|
histShow[i] = !histShow[i];
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_sprite_ui_uniform(THEME.circle, 0, _bx + 10, _by + 10, 1, COLORS.histogram[i], 0.5 + histShow[i] * 0.5);
|
2022-09-23 13:28:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(histMax > 0)
|
|
|
|
histogramDraw(x0, y1, _w, _h);
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS.node_level_outline);
|
2022-09-23 13:28:42 +02:00
|
|
|
draw_rectangle(x0, y0, x1, y1, true);
|
2023-01-04 02:30:04 +01:00
|
|
|
|
|
|
|
return _h;
|
2023-09-14 16:29:39 +02:00
|
|
|
}); #endregion
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2023-11-09 04:02:41 +01:00
|
|
|
input_display_list = [ 8, 9,
|
2022-09-23 13:28:42 +02:00
|
|
|
level_renderer,
|
2023-11-24 10:41:53 +01:00
|
|
|
["Surfaces", true], 0, 6, 7, 10, 11,
|
2024-01-30 15:04:56 +01:00
|
|
|
["Brightness", false], 1, 12,
|
|
|
|
["Red", false], 2, 13,
|
|
|
|
["Green", false], 3, 14,
|
|
|
|
["Blue", false], 4, 15,
|
|
|
|
["Alpha", false], 5, 16,
|
2022-09-23 13:28:42 +02:00
|
|
|
];
|
|
|
|
histogramInit();
|
|
|
|
|
|
|
|
static onInspect = function() {
|
|
|
|
if(array_length(current_data) > 0)
|
|
|
|
histogramUpdate(current_data[0]);
|
|
|
|
}
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static onValueFromUpdate = function(index) { #region
|
2022-09-23 13:28:42 +02:00
|
|
|
if(index == 0) {
|
2023-03-28 06:58:28 +02:00
|
|
|
doUpdate();
|
2022-09-23 13:28:42 +02:00
|
|
|
if(array_length(current_data) > 0)
|
|
|
|
histogramUpdate(current_data[0]);
|
|
|
|
}
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2022-09-23 13:28:42 +02:00
|
|
|
|
2023-11-24 10:41:53 +01:00
|
|
|
static step = function() { #region
|
|
|
|
__step_mask_modifier();
|
|
|
|
} #endregion
|
|
|
|
|
2023-09-14 16:29:39 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
2024-01-30 15:04:56 +01:00
|
|
|
var _wi = _data[1];
|
|
|
|
var _ri = _data[2];
|
|
|
|
var _gi = _data[3];
|
|
|
|
var _bi = _data[4];
|
|
|
|
var _ai = _data[5];
|
|
|
|
|
|
|
|
var _wo = _data[12];
|
|
|
|
var _ro = _data[13];
|
|
|
|
var _go = _data[14];
|
|
|
|
var _bo = _data[15];
|
|
|
|
var _ao = _data[16];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-01-09 03:39:40 +01:00
|
|
|
surface_set_shader(_outSurf, sh_level);
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("lwi", _wi);
|
|
|
|
shader_set_2("lri", _ri);
|
|
|
|
shader_set_2("lgi", _gi);
|
|
|
|
shader_set_2("lbi", _bi);
|
|
|
|
shader_set_2("lai", _ai);
|
2024-01-30 15:04:56 +01:00
|
|
|
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("lwo", _wo);
|
|
|
|
shader_set_2("lro", _ro);
|
|
|
|
shader_set_2("lgo", _go);
|
|
|
|
shader_set_2("lbo", _bo);
|
|
|
|
shader_set_2("lao", _ao);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-01-09 03:39:40 +01:00
|
|
|
draw_surface_safe(_data[0]);
|
|
|
|
surface_reset_shader();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-24 10:41:53 +01:00
|
|
|
__process_mask_modifier(_data);
|
2023-02-14 05:32:32 +01:00
|
|
|
_outSurf = mask_apply(_data[0], _outSurf, _data[6], _data[7]);
|
2023-11-09 04:02:41 +01:00
|
|
|
_outSurf = channel_apply(_data[0], _outSurf, _data[9]);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
return _outSurf;
|
2023-09-14 16:29:39 +02:00
|
|
|
} #endregion
|
2022-09-23 13:28:42 +02:00
|
|
|
}
|