- Array processor are now use batched output by default (doesn't mean anything functionally).

This commit is contained in:
Tanasart 2024-06-28 14:48:48 +07:00
parent 89cbd946a7
commit 3d4fe3447f
9 changed files with 76 additions and 80 deletions

Binary file not shown.

View file

@ -74,9 +74,7 @@ function __Node_3D_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
attributes.auto_update = true; attributes.auto_update = true;
array_push(attributeEditors, ["Auto Update", function() { return attributes.auto_update; }, array_push(attributeEditors, ["Auto Update", function() { return attributes.auto_update; },
new checkBox(function() { new checkBox(function() { attribute[? "auto_update"] = !attribute[? "auto_update"]; }, false)]);
attribute[? "auto_update"] = !attribute[? "auto_update"];
}, false)]);
vertexObjects = []; vertexObjects = [];
_3d_node_init(1, /*Transform*/ 4, 5, 1, 2, 3); _3d_node_init(1, /*Transform*/ 4, 5, 1, 2, 3);

View file

@ -1,9 +1,5 @@
function Node_Average(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Average(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Average"; name = "Average";
batch_output = false;
shader = sh_average;
uniform_dim = shader_get_uniform(shader, "dimension");
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
@ -29,49 +25,38 @@ function Node_Average(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
outputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, c_black); outputs[| 1] = nodeValue("Color", self, JUNCTION_CONNECT.output, VALUE_TYPE.color, c_black);
attribute_surface_depth(); attribute_surface_depth();
colors = [];
static step = function() { #region static step = function() {
__step_mask_modifier(); __step_mask_modifier();
} #endregion }
static processData = function(_outSurf, _data, _output_index, _array_index) { #region static processData = function(_outData, _data, _output_index, _array_index) {
var inSurf = _data[0]; var inSurf = _data[0];
if(!is_surface(inSurf)) return _outSurf; var _outSurf = _outData[0];
if(_output_index == 1) if(!is_surface(inSurf)) return [ _outSurf, c_black ];
return array_safe_get_fast(colors, _array_index);
var lop = ceil(log2(max(surface_get_width_safe(inSurf), surface_get_height_safe(inSurf))));
var side = max(surface_get_width_safe(inSurf), surface_get_height_safe(inSurf)); var side = power(2, lop);
var lop = ceil(log2(side));
var cc; var cc;
side = power(2, lop);
if(side / 2 >= 1) { if(side / 2 >= 1) {
var _Surf = [ surface_create_valid(side, side), surface_create_valid(side, side) ]; var _Surf = [ surface_create_valid(side, side), surface_create_valid(side, side) ];
var _ind = 1; var _ind = 1;
surface_set_target(_Surf[0]); surface_set_shader(_Surf[0], noone);
DRAW_CLEAR draw_surface_stretched_safe(inSurf, 0, 0, side, side);
BLEND_OVERRIDE; surface_reset_shader();
draw_surface_stretched_safe(inSurf, 0, 0, side, side);
BLEND_NORMAL;
surface_reset_target();
shader_set(sh_average);
for( var i = 0; i <= lop; i++ ) { for( var i = 0; i <= lop; i++ ) {
shader_set_uniform_f(uniform_dim, side); surface_set_shader(_Surf[_ind], sh_average);
shader_set_f("dimension", side);
surface_set_target(_Surf[_ind]); draw_surface_safe(_Surf[!_ind], 0, 0);
DRAW_CLEAR surface_reset_shader();
draw_surface_safe(_Surf[!_ind], 0, 0);
surface_reset_target();
_ind = !_ind; _ind = !_ind;
side /= 2; side /= 2;
} }
shader_reset();
cc = surface_get_pixel(_Surf[!_ind], 0, 0); cc = surface_get_pixel(_Surf[!_ind], 0, 0);
@ -81,14 +66,13 @@ function Node_Average(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
cc = surface_get_pixel(inSurf, 0, 0); cc = surface_get_pixel(inSurf, 0, 0);
surface_set_target(_outSurf); surface_set_target(_outSurf);
draw_clear(cc); draw_clear(cc);
surface_reset_target(); surface_reset_target();
__process_mask_modifier(_data); __process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[1], _data[2]); _outSurf = mask_apply(_data[0], _outSurf, _data[1], _data[2]);
_outSurf = channel_apply(_data[0], _outSurf, _data[4]); _outSurf = channel_apply(_data[0], _outSurf, _data[4]);
colors[_array_index] = cc;
return _outSurf; return [ _outSurf, cc ];
} #endregion }
} }

View file

@ -47,8 +47,9 @@ function Node_Bloom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone); outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
attribute_surface_depth(); temp_surface = [ 0 ];
attribute_surface_depth();
surface_blur_init(); surface_blur_init();
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
@ -68,6 +69,7 @@ function Node_Bloom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
} #endregion } #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { static processData = function(_outSurf, _data, _output_index, _array_index) {
var _surf = _data[0];
var _size = _data[1]; var _size = _data[1];
var _tole = _data[2]; var _tole = _data[2];
var _stre = _data[3]; var _stre = _data[3];
@ -78,36 +80,37 @@ function Node_Bloom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
var _angle = _data[12]; var _angle = _data[12];
var _zoom = _data[14]; var _zoom = _data[14];
var pass1 = surface_create_valid(surface_get_width_safe(_outSurf), surface_get_height_safe(_outSurf), attrDepth()); var _sw = surface_get_width_safe(_surf);
var _sh = surface_get_height_safe(_surf);
surface_set_shader(pass1, sh_bloom_pass); temp_surface[0] = surface_verify(temp_surface[0], _sw, _sh);
surface_set_shader(temp_surface[0], sh_bloom_pass);
draw_clear_alpha(c_black, 1); draw_clear_alpha(c_black, 1);
shader_set_f("size", _size); shader_set_f("size", _size);
shader_set_f("tolerance", _tole); shader_set_f("tolerance", _tole);
shader_set_i("useMask", is_surface(_mask)); shader_set_i("useMask", is_surface(_mask));
shader_set_surface("mask", _mask); shader_set_surface("mask", _mask);
draw_surface_safe(_data[0]); draw_surface_safe(_surf);
surface_reset_shader(); surface_reset_shader();
var pass1blur; var pass1blur;
if(_type == 0) pass1blur = surface_apply_gaussian( pass1, _size, true, c_black, 1, noone, false, _ratio, _angle); if(_type == 0) pass1blur = surface_apply_gaussian( temp_surface[0], _size, true, c_black, 1, noone, false, _ratio, _angle);
else if(_type == 1) pass1blur = surface_apply_blur_zoom(pass1, _size, _zoom[0], _zoom[1], 2, 1); else if(_type == 1) pass1blur = surface_apply_blur_zoom(temp_surface[0], _size, _zoom[0], _zoom[1], 2, 1);
surface_free(pass1);
surface_set_shader(_outSurf, sh_blend_add_alpha_adj); surface_set_shader(_outSurf, sh_blend_add_alpha_adj);
shader_set_surface("fore", pass1blur); shader_set_surface("fore", pass1blur);
shader_set_f("opacity", _stre); shader_set_f("opacity", _stre);
draw_surface_safe(_data[0]); draw_surface_safe(_surf);
surface_reset_shader(); surface_reset_shader();
__process_mask_modifier(_data); __process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[5], _data[6]); _outSurf = mask_apply(_surf, _outSurf, _data[5], _data[6]);
_outSurf = channel_apply(_data[0], _outSurf, _data[8]); _outSurf = channel_apply(_surf, _outSurf, _data[8]);
return _outSurf; return _outSurf;
} }

View file

@ -8,17 +8,16 @@ function Node_Color_Data(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
inputs[| 1] = nodeValue("Normalize", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); inputs[| 1] = nodeValue("Normalize", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
outputs[| 0] = nodeValue("Red", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0); outputs[| 0] = nodeValue("Red", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
outputs[| 1] = nodeValue("Green", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0); outputs[| 1] = nodeValue("Green", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
outputs[| 2] = nodeValue("Blue", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0); outputs[| 2] = nodeValue("Blue", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
outputs[| 3] = nodeValue("Hue", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false); outputs[| 3] = nodeValue("Hue", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false);
outputs[| 4] = nodeValue("Saturation", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false); outputs[| 4] = nodeValue("Saturation", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false);
outputs[| 5] = nodeValue("Value", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false); outputs[| 5] = nodeValue("Value", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false);
outputs[| 6] = nodeValue("Brightness", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false); outputs[| 6] = nodeValue("Brightness", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false);
outputs[| 7] = nodeValue("Alpha", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false);
outputs[| 7] = nodeValue("Alpha", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0).setVisible(false);
static processData = function(_output, _data, _output_index, _array_index = 0) { static processData = function(_output, _data, _output_index, _array_index = 0) {
var _c = _data[0]; var _c = _data[0];

View file

@ -1,6 +1,5 @@
function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Draw Line"; name = "Draw Line";
batch_output = true;
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF ) inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector); .setDisplay(VALUE_DISPLAY.vector);

View file

@ -217,26 +217,31 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
} #endregion } #endregion
static processBatchOutput = function() { #region static processBatchOutput = function() { #region
var _is = ds_list_size(inputs); var _is = ds_list_size(inputs);
var _os = ds_list_size(outputs); var _os = ds_list_size(outputs);
var _dep = attrDepth();
var _outVal = array_create(_os); var data;
for(var i = 0; i < _os; i++) var _out = array_create(_os);
_outVal[i] = outputs[| i].getValue(); for(var i = 0; i < _os; i++) _out[i] = outputs[| i].getValue();
if(process_amount == 1) { if(process_amount == 1) {
current_data = inputs_data; current_data = inputs_data;
var data = processData(_outVal, inputs_data, 0, 0);
var _dim = getDimension();
for(var i = 0; i < _os; i++) {
if(outputs[| i].type == VALUE_TYPE.surface)
_out[i] = surface_verify(_out[i], _dim[0], _dim[1], _dep);
}
if(_os == 1) { if(_os == 1) {
data = processData(_out[0], inputs_data, 0, 0);
outputs[| 0].setValue(data); outputs[| 0].setValue(data);
} else { } else {
for(var i = 0; i < _os; i++) { data = processData(_out, inputs_data, 0, 0);
var _outp = array_safe_get_fast(data, i, undefined); for(var i = 0; i < _os; i++) outputs[| i].setValue(data[i]);
if(_outp == undefined) continue;
outputs[| i].setValue(_outp);
}
} }
return; return;
@ -247,16 +252,26 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
for( var l = 0; l < process_amount; l++ ) { for( var l = 0; l < process_amount; l++ ) {
for(var i = 0; i < _is; i++) for(var i = 0; i < _is; i++) _inputs[i] = all_inputs[i][l];
_inputs[i] = all_inputs[i][l]; if(l == 0 || l == preview_index) current_data = _inputs;
if(l == 0 || l == preview_index) var _dim = getDimension(l);
current_data = _inputs; var _outa = array_create(_os);
var data = processData(_outVal, _inputs, 0, l); for(var i = 0; i < _os; i++) {
_outa[i] = array_safe_get(_out[i], l);
if(outputs[| i].type == VALUE_TYPE.surface)
_outa[i] = surface_verify(_outa[i], _dim[0], _dim[1], _dep);
}
if(_os == 1) _outputs[0][l] = data; if(_os == 1) {
else for(var i = 0; i < _os; i++) _outputs[i][l] = data[i]; data = processData(_outa[0], _inputs, 0, l);
_outputs[0][l] = data;
} else {
data = processData(_outa, _inputs, 0, l);
for(var i = 0; i < _os; i++) _outputs[i][l] = data[i];
}
} }
for( var i = 0, n = _os; i < n; i++ ) for( var i = 0, n = _os; i < n; i++ )

View file

@ -1,6 +1,5 @@
function Node_RM(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_RM(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "RM"; name = "RM";
is_3D = NODE_3D.sdf; is_3D = NODE_3D.sdf;
batch_output = true;
} }

View file

@ -7,7 +7,6 @@ enum OUTPUT_SCALING {
function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Transform"; name = "Transform";
batch_output = true;
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone); inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);