mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 06:26:42 +01:00
- Array processor are now use batched output by default (doesn't mean anything functionally).
This commit is contained in:
parent
89cbd946a7
commit
3d4fe3447f
9 changed files with 76 additions and 80 deletions
Binary file not shown.
|
@ -74,9 +74,7 @@ function __Node_3D_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
|
|||
attributes.auto_update = true;
|
||||
|
||||
array_push(attributeEditors, ["Auto Update", function() { return attributes.auto_update; },
|
||||
new checkBox(function() {
|
||||
attribute[? "auto_update"] = !attribute[? "auto_update"];
|
||||
}, false)]);
|
||||
new checkBox(function() { attribute[? "auto_update"] = !attribute[? "auto_update"]; }, false)]);
|
||||
|
||||
vertexObjects = [];
|
||||
_3d_node_init(1, /*Transform*/ 4, 5, 1, 2, 3);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
function Node_Average(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
attribute_surface_depth();
|
||||
|
||||
colors = [];
|
||||
|
||||
static step = function() { #region
|
||||
static step = function() {
|
||||
__step_mask_modifier();
|
||||
} #endregion
|
||||
}
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
||||
var inSurf = _data[0];
|
||||
if(!is_surface(inSurf)) return _outSurf;
|
||||
static processData = function(_outData, _data, _output_index, _array_index) {
|
||||
var inSurf = _data[0];
|
||||
var _outSurf = _outData[0];
|
||||
|
||||
if(_output_index == 1)
|
||||
return array_safe_get_fast(colors, _array_index);
|
||||
|
||||
var side = max(surface_get_width_safe(inSurf), surface_get_height_safe(inSurf));
|
||||
var lop = ceil(log2(side));
|
||||
if(!is_surface(inSurf)) return [ _outSurf, c_black ];
|
||||
|
||||
var lop = ceil(log2(max(surface_get_width_safe(inSurf), surface_get_height_safe(inSurf))));
|
||||
var side = power(2, lop);
|
||||
var cc;
|
||||
side = power(2, lop);
|
||||
|
||||
if(side / 2 >= 1) {
|
||||
var _Surf = [ surface_create_valid(side, side), surface_create_valid(side, side) ];
|
||||
var _ind = 1;
|
||||
|
||||
surface_set_target(_Surf[0]);
|
||||
DRAW_CLEAR
|
||||
BLEND_OVERRIDE;
|
||||
draw_surface_stretched_safe(inSurf, 0, 0, side, side);
|
||||
BLEND_NORMAL;
|
||||
surface_reset_target();
|
||||
surface_set_shader(_Surf[0], noone);
|
||||
draw_surface_stretched_safe(inSurf, 0, 0, side, side);
|
||||
surface_reset_shader();
|
||||
|
||||
shader_set(sh_average);
|
||||
for( var i = 0; i <= lop; i++ ) {
|
||||
shader_set_uniform_f(uniform_dim, side);
|
||||
|
||||
surface_set_target(_Surf[_ind]);
|
||||
DRAW_CLEAR
|
||||
draw_surface_safe(_Surf[!_ind], 0, 0);
|
||||
surface_reset_target();
|
||||
surface_set_shader(_Surf[_ind], sh_average);
|
||||
shader_set_f("dimension", side);
|
||||
draw_surface_safe(_Surf[!_ind], 0, 0);
|
||||
surface_reset_shader();
|
||||
|
||||
_ind = !_ind;
|
||||
side /= 2;
|
||||
}
|
||||
shader_reset();
|
||||
|
||||
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);
|
||||
|
||||
surface_set_target(_outSurf);
|
||||
draw_clear(cc);
|
||||
draw_clear(cc);
|
||||
surface_reset_target();
|
||||
|
||||
__process_mask_modifier(_data);
|
||||
_outSurf = mask_apply(_data[0], _outSurf, _data[1], _data[2]);
|
||||
_outSurf = channel_apply(_data[0], _outSurf, _data[4]);
|
||||
colors[_array_index] = cc;
|
||||
|
||||
return _outSurf;
|
||||
} #endregion
|
||||
return [ _outSurf, cc ];
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
||||
attribute_surface_depth();
|
||||
temp_surface = [ 0 ];
|
||||
|
||||
attribute_surface_depth();
|
||||
surface_blur_init();
|
||||
|
||||
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
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
var _surf = _data[0];
|
||||
var _size = _data[1];
|
||||
var _tole = _data[2];
|
||||
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 _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);
|
||||
shader_set_f("size", _size);
|
||||
shader_set_f("tolerance", _tole);
|
||||
|
||||
shader_set_i("useMask", is_surface(_mask));
|
||||
shader_set_i("useMask", is_surface(_mask));
|
||||
shader_set_surface("mask", _mask);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
draw_surface_safe(_surf);
|
||||
surface_reset_shader();
|
||||
|
||||
var pass1blur;
|
||||
|
||||
if(_type == 0) pass1blur = surface_apply_gaussian( pass1, _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);
|
||||
|
||||
surface_free(pass1);
|
||||
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(temp_surface[0], _size, _zoom[0], _zoom[1], 2, 1);
|
||||
|
||||
surface_set_shader(_outSurf, sh_blend_add_alpha_adj);
|
||||
shader_set_surface("fore", pass1blur);
|
||||
shader_set_f("opacity", _stre);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
draw_surface_safe(_surf);
|
||||
surface_reset_shader();
|
||||
|
||||
__process_mask_modifier(_data);
|
||||
_outSurf = mask_apply(_data[0], _outSurf, _data[5], _data[6]);
|
||||
_outSurf = channel_apply(_data[0], _outSurf, _data[8]);
|
||||
_outSurf = mask_apply(_surf, _outSurf, _data[5], _data[6]);
|
||||
_outSurf = channel_apply(_surf, _outSurf, _data[8]);
|
||||
|
||||
return _outSurf;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
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[| 2] = nodeValue("Blue", 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[| 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[| 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[| 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[| 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[| 7] = nodeValue("Alpha", 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);
|
||||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
var _c = _data[0];
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
function Node_Line(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Draw Line";
|
||||
batch_output = true;
|
||||
|
||||
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
|
||||
.setDisplay(VALUE_DISPLAY.vector);
|
||||
|
|
|
@ -217,26 +217,31 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
|
|||
} #endregion
|
||||
|
||||
static processBatchOutput = function() { #region
|
||||
var _is = ds_list_size(inputs);
|
||||
var _os = ds_list_size(outputs);
|
||||
var _is = ds_list_size(inputs);
|
||||
var _os = ds_list_size(outputs);
|
||||
var _dep = attrDepth();
|
||||
|
||||
var _outVal = array_create(_os);
|
||||
for(var i = 0; i < _os; i++)
|
||||
_outVal[i] = outputs[| i].getValue();
|
||||
var data;
|
||||
var _out = array_create(_os);
|
||||
for(var i = 0; i < _os; i++) _out[i] = outputs[| i].getValue();
|
||||
|
||||
if(process_amount == 1) {
|
||||
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) {
|
||||
data = processData(_out[0], inputs_data, 0, 0);
|
||||
outputs[| 0].setValue(data);
|
||||
|
||||
} else {
|
||||
for(var i = 0; i < _os; i++) {
|
||||
var _outp = array_safe_get_fast(data, i, undefined);
|
||||
if(_outp == undefined) continue;
|
||||
outputs[| i].setValue(_outp);
|
||||
}
|
||||
data = processData(_out, inputs_data, 0, 0);
|
||||
for(var i = 0; i < _os; i++) outputs[| i].setValue(data[i]);
|
||||
}
|
||||
|
||||
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 i = 0; i < _is; i++)
|
||||
_inputs[i] = all_inputs[i][l];
|
||||
for(var i = 0; i < _is; i++) _inputs[i] = all_inputs[i][l];
|
||||
if(l == 0 || l == preview_index) current_data = _inputs;
|
||||
|
||||
if(l == 0 || l == preview_index)
|
||||
current_data = _inputs;
|
||||
var _dim = getDimension(l);
|
||||
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;
|
||||
else for(var i = 0; i < _os; i++) _outputs[i][l] = data[i];
|
||||
if(_os == 1) {
|
||||
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++ )
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
function Node_RM(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "RM";
|
||||
is_3D = NODE_3D.sdf;
|
||||
batch_output = true;
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@ enum OUTPUT_SCALING {
|
|||
|
||||
function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "Transform";
|
||||
batch_output = true;
|
||||
|
||||
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
||||
|
||||
|
|
Loading…
Reference in a new issue