mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 22:43:53 +01:00
Add option to set some attributes (interpolation, oversample, format) to "group" which will inherit the value from the parent group.
This commit is contained in:
parent
87a9b3ae05
commit
f2e919d6be
@ -38,7 +38,7 @@ function Node_(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) construc
|
||||
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
|
||||
|
||||
surface_set_shader(_outSurf, SHADER, true, BLEND.over);
|
||||
shader_set_i("sampleMode", attributes.oversample);
|
||||
shader_set_i("sampleMode", getAttribute("oversample"));
|
||||
shader_set_2("dimension", _dim);
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
LATEST_VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_01_0;
|
||||
SAVE_VERSION = 1_18_01_0;
|
||||
SAVE_VERSION = 1_18_02_0;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.2.0077";
|
||||
BUILD_NUMBER = 1_18_01_0;
|
||||
|
||||
|
@ -108,7 +108,7 @@ function Node_3D_Transform_Image(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y,
|
||||
camera_set_view_mat(camera, viewMat);
|
||||
camera_set_proj_mat(camera, projMat);
|
||||
camera_apply(camera);
|
||||
gpu_set_texfilter(attributes.interpolate);
|
||||
gpu_set_texfilter(getAttribute("interpolate"));
|
||||
|
||||
object.transform.submitMatrix();
|
||||
matrix_set(matrix_world, matrix_stack_top());
|
||||
|
@ -167,8 +167,8 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
|
||||
];
|
||||
|
||||
attributes.layer_visible = [];
|
||||
attributes.interpolate = 0;
|
||||
attributes.oversample = 0;
|
||||
attributes.interpolate = 1;
|
||||
attributes.oversample = 1;
|
||||
|
||||
edit_time = 0;
|
||||
attributes.file_checker = true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#region attribute
|
||||
global.SURFACE_INTERPOLATION = [
|
||||
"-Group",
|
||||
"Pixel",
|
||||
"Bilinear",
|
||||
"Bicubic",
|
||||
@ -7,6 +8,7 @@
|
||||
];
|
||||
|
||||
global.SURFACE_OVERSAMPLE = [
|
||||
"-Group",
|
||||
"Empty",
|
||||
"Clamp",
|
||||
"Repeat",
|
||||
@ -15,6 +17,8 @@
|
||||
|
||||
function __initSurfaceFormat() {
|
||||
var surface_format = [
|
||||
-1,
|
||||
-2,
|
||||
surface_rgba4unorm,
|
||||
surface_rgba8unorm,
|
||||
surface_rgba16float,
|
||||
@ -25,6 +29,8 @@
|
||||
];
|
||||
|
||||
var surface_format_name = [
|
||||
"-Input",
|
||||
"-Group",
|
||||
"4 bit RGBA",
|
||||
"8 bit RGBA",
|
||||
"16 bit RGBA",
|
||||
@ -38,59 +44,67 @@
|
||||
global.SURFACE_FORMAT_NAME = [];
|
||||
|
||||
for( var i = 0, n = array_length(surface_format); i < n; i++ ) {
|
||||
var sup = surface_format_is_supported(surface_format[i]);
|
||||
array_push(global.SURFACE_FORMAT, surface_format[i]);
|
||||
array_push(global.SURFACE_FORMAT_NAME, (sup? "" : "-") + surface_format_name[i]);
|
||||
var _form = surface_format[i];
|
||||
var _supp = _form < 0 || surface_format_is_supported(_form);
|
||||
|
||||
if(!sup) log_message("WARNING", "Surface format [" + surface_format_name[i] + "] not supported in this device.");
|
||||
array_push(global.SURFACE_FORMAT, _form);
|
||||
array_push(global.SURFACE_FORMAT_NAME, (_supp? "" : "-") + surface_format_name[i]);
|
||||
|
||||
if(!_supp) log_message("WARNING", $"Surface format [{surface_format_name[i]}] not supported in this device.");
|
||||
}
|
||||
}
|
||||
|
||||
function __attribute_set(node, key, value) {
|
||||
node.attributes[$ key] = value;
|
||||
node.triggerRender();
|
||||
}
|
||||
|
||||
function attribute_set(key, value) {
|
||||
if(PANEL_INSPECTOR == noone) return;
|
||||
|
||||
global.SURFACE_FORMAT_NAME_PROCESS = [ "Input" ];
|
||||
global.SURFACE_FORMAT_NAME_PROCESS = array_append(global.SURFACE_FORMAT_NAME_PROCESS, global.SURFACE_FORMAT_NAME);
|
||||
if(PANEL_INSPECTOR.inspecting)
|
||||
__attribute_set(PANEL_INSPECTOR.inspecting, key, value);
|
||||
|
||||
if(PANEL_INSPECTOR.inspectGroup == 1)
|
||||
for( var i = 0, n = array_length(PANEL_INSPECTOR.inspectings); i < n; i++ )
|
||||
__attribute_set(PANEL_INSPECTOR.inspectings[i], key, value);
|
||||
}
|
||||
|
||||
function attribute_surface_depth(label = true) {
|
||||
var depth_array = inputs[0].type == VALUE_TYPE.surface? global.SURFACE_FORMAT_NAME_PROCESS : global.SURFACE_FORMAT_NAME;
|
||||
attributes.color_depth = array_find(depth_array, "8 bit RGBA");
|
||||
attr_depth_array = global.SURFACE_FORMAT_NAME;
|
||||
if(!array_empty(inputs) && inputs[0].type == VALUE_TYPE.surface)
|
||||
attr_depth_array[0] = "Input";
|
||||
|
||||
attributes.color_depth = 3;
|
||||
|
||||
if(label) array_push(attributeEditors, "Surface");
|
||||
array_push(attributeEditors, ["Color depth", function() { return attributes.color_depth; },
|
||||
new scrollBox(depth_array, function(val) {
|
||||
attributes.color_depth = val;
|
||||
triggerRender();
|
||||
}, false)]);
|
||||
array_push(attributeEditors, ["Color depth", function() /*=>*/ {return attributes.color_depth},
|
||||
new scrollBox(attr_depth_array, function(val) /*=>*/ { attribute_set("color_depth", val); }, false), "color_depth"]);
|
||||
}
|
||||
|
||||
function attribute_interpolation(label = false) {
|
||||
attributes.interpolate = 0;
|
||||
attributes.oversample = 0;
|
||||
attributes.interpolate = 1;
|
||||
attributes.oversample = 1;
|
||||
|
||||
if(label) array_push(attributeEditors, "Surface");
|
||||
array_push(attributeEditors, ["Texture interpolation", function() { return attributes.interpolate; },
|
||||
new scrollBox(global.SURFACE_INTERPOLATION, function(val) {
|
||||
attributes.interpolate = val;
|
||||
triggerRender();
|
||||
}, false)]);
|
||||
array_push(attributeEditors, ["Texture interpolation", function() /*=>*/ {return attributes.interpolate},
|
||||
new scrollBox(global.SURFACE_INTERPOLATION, function(val) /*=>*/ { attribute_set("interpolate", val); }, false), "interpolate"]);
|
||||
}
|
||||
|
||||
function attribute_oversample(label = false) {
|
||||
attributes.interpolate = 0;
|
||||
attributes.oversample = 0;
|
||||
attributes.interpolate = 1;
|
||||
attributes.oversample = 1;
|
||||
|
||||
if(label) array_push(attributeEditors, "Surface");
|
||||
array_push(attributeEditors, ["Oversample", function() { return attributes.oversample; },
|
||||
new scrollBox(global.SURFACE_OVERSAMPLE, function(val) {
|
||||
attributes.oversample = val;
|
||||
triggerRender();
|
||||
}, false)]);
|
||||
array_push(attributeEditors, ["Oversample", function() /*=>*/ {return attributes.oversample},
|
||||
new scrollBox(global.SURFACE_OVERSAMPLE, function(val) /*=>*/ { attribute_set("oversample", val); }, false), "oversample"]);
|
||||
}
|
||||
|
||||
function attribute_auto_execute(label = false) {
|
||||
attributes.auto_exe = false;
|
||||
|
||||
if(label) array_push(attributeEditors, "Node");
|
||||
array_push(attributeEditors, ["Auto execute", function() { return attributes.auto_exe; },
|
||||
new checkBox(function() {
|
||||
attributes.auto_exe = !attributes.auto_exe;
|
||||
})]);
|
||||
array_push(attributeEditors, ["Auto execute", function() /*=>*/ {return attributes.auto_exe},
|
||||
new checkBox(function() /*=>*/ { attribute_set("auto_exe", !attributes.auto_exe); })]);
|
||||
}
|
||||
#endregion
|
@ -248,7 +248,7 @@ function Node_Bend(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
||||
|
||||
var n = array_length(mesh);
|
||||
|
||||
gpu_set_texfilter(attributes.interpolate);
|
||||
gpu_set_texfilter(getAttribute("interpolate"));
|
||||
for( var k = 0; k < n; k += 100 ) {
|
||||
draw_primitive_begin_texture(pr_trianglelist, surface_get_texture(_surf));
|
||||
|
||||
|
@ -220,9 +220,16 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||
|
||||
onNewInputFromGraph = noone;
|
||||
|
||||
/////========== Attributes ===========
|
||||
|
||||
attribute_surface_depth();
|
||||
attribute_interpolation();
|
||||
attribute_oversample();
|
||||
|
||||
tool_node = noone;
|
||||
draw_input_overlay = true;
|
||||
|
||||
array_push(attributeEditors, "Group IO");
|
||||
array_push(attributeEditors, ["Lock Input", function() /*=>*/ {return attributes.lock_input}, new checkBox(function() /*=>*/ { attributes.lock_input = !attributes.lock_input }) ]);
|
||||
array_push(attributeEditors, ["Edit Input Display", function() /*=>*/ {return 0}, button(function() /*=>*/ { dialogCall(o_dialog_group_input_order).setNode(self, CONNECT_TYPE.input); }) ]);
|
||||
array_push(attributeEditors, ["Edit Output Display", function() /*=>*/ {return 0}, button(function() /*=>*/ { dialogCall(o_dialog_group_input_order).setNode(self, CONNECT_TYPE.output); }) ]);
|
||||
@ -279,6 +286,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||
|
||||
recordAction(ACTION_TYPE.group_added, self, _node);
|
||||
_node.group = self;
|
||||
_node.checkGroup();
|
||||
|
||||
will_refresh = true;
|
||||
node_length = array_length(nodes);
|
||||
@ -305,7 +313,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
|
||||
|
||||
if(_hide) _node.disable();
|
||||
else _node.group = group;
|
||||
|
||||
_node.checkGroup();
|
||||
|
||||
will_refresh = true;
|
||||
node_length = array_length(nodes);
|
||||
onRemove(_node);
|
||||
|
@ -49,7 +49,7 @@ function Node_Convolution(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou
|
||||
_ker = array_verify(_ker, _siz * _siz);
|
||||
|
||||
surface_set_shader(_outSurf, sh_convolution, true, BLEND.over);
|
||||
shader_set_i("sampleMode", attributes.oversample);
|
||||
shader_set_i("sampleMode", getAttribute("oversample"));
|
||||
shader_set_dim("dimension", _outSurf);
|
||||
shader_set_f("kernel", _ker);
|
||||
shader_set_i("size", _siz);
|
||||
|
@ -2385,6 +2385,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||
|
||||
static attributeDeserialize = function(attr) {
|
||||
struct_append(attributes, attr);
|
||||
|
||||
if(LOADING_VERSION < 1_18_02_0) {
|
||||
if(struct_has(attributes, "color_depth")) attributes.color_depth += inputs[0].type == VALUE_TYPE.surface? 1 : 2;
|
||||
if(struct_has(attributes, "interpolate")) attributes.interpolate++;
|
||||
if(struct_has(attributes, "oversample")) attributes.oversample++;
|
||||
}
|
||||
}
|
||||
|
||||
static processDeserialize = function() {}
|
||||
@ -2656,21 +2662,81 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
|
||||
|
||||
static resetAnimation = function() {}
|
||||
|
||||
static attrDepth = function() {
|
||||
if(struct_has(attributes, "color_depth")) {
|
||||
var form = attributes.color_depth;
|
||||
if(inputs[0].type == VALUE_TYPE.surface)
|
||||
form--;
|
||||
if(form >= 0)
|
||||
return array_safe_get_fast(global.SURFACE_FORMAT, form, surface_rgba8unorm);
|
||||
static getAttribute = function(_key) {
|
||||
var _val = struct_try_get(attributes, _key, 0);
|
||||
|
||||
switch(_key) {
|
||||
case "interpolate" :
|
||||
case "oversample" :
|
||||
if(group && _val == 0) return group.getAttribute(_key);
|
||||
_val--;
|
||||
break;
|
||||
}
|
||||
|
||||
var _s = getInputData(0);
|
||||
while(is_array(_s) && array_length(_s)) _s = _s[0];
|
||||
if(!is_surface(_s))
|
||||
return surface_rgba8unorm;
|
||||
return surface_get_format(_s);
|
||||
return _val;
|
||||
}
|
||||
|
||||
static attrDepth = function() {
|
||||
var form = -1;
|
||||
|
||||
if(struct_has(attributes, "color_depth")) {
|
||||
form = global.SURFACE_FORMAT[attributes.color_depth];
|
||||
if(form >= 0) return form;
|
||||
}
|
||||
|
||||
if(form == -1) { // input
|
||||
var _s = getInputData(0);
|
||||
while(is_array(_s) && array_length(_s)) _s = _s[0];
|
||||
if(is_surface(_s)) return surface_get_format(_s);
|
||||
}
|
||||
|
||||
if(form == -2 && group != noone) // group
|
||||
return group.attrDepth();
|
||||
|
||||
return surface_rgba8unorm;
|
||||
}
|
||||
|
||||
static checkGroup = function() {
|
||||
|
||||
if(group == noone) {
|
||||
for( var i = 0, n = array_length(attributeEditors); i < n; i++ ) {
|
||||
var _att = attributeEditors[i];
|
||||
if(!is_array(_att)) continue;
|
||||
|
||||
var _wid = _att[2];
|
||||
|
||||
if(is(_wid, scrollBox)) {
|
||||
var _l = _wid.data_list;
|
||||
var _lin = array_get_index(_l, "Group");
|
||||
|
||||
if(_lin != -1) {
|
||||
_wid.data_list[_lin] = "-Group";
|
||||
var _key = _att[3];
|
||||
|
||||
if(attributes[$ _key] == _lin)
|
||||
attributes[$ _key] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
for( var i = 0, n = array_length(attributeEditors); i < n; i++ ) {
|
||||
var _att = attributeEditors[i];
|
||||
if(!is_array(_att)) continue;
|
||||
|
||||
var _wid = _att[2];
|
||||
|
||||
if(is(_wid, scrollBox)) {
|
||||
var _l = _wid.data_list;
|
||||
var _lin = array_get_index(_l, "-Group");
|
||||
|
||||
if(_lin != -1) _wid.data_list[_lin] = "Group";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} checkGroup();
|
||||
|
||||
static toString = function() { return $"Node [{internalName}]: {node_id}"; }
|
||||
}
|
@ -41,7 +41,7 @@ function Node_High_Pass(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
|
||||
|
||||
surface_set_shader(_outSurf, sh_high_pass, true, BLEND.over);
|
||||
shader_set_i("sampleMode", attributes.oversample);
|
||||
shader_set_i("sampleMode", getAttribute("oversample"));
|
||||
shader_set_2("dimension", _dim);
|
||||
shader_set_f("radius", _rad);
|
||||
shader_set_f("intensity", _int);
|
||||
|
@ -15,7 +15,6 @@ function Node_Sampler(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
||||
newOutput(0, nodeValue_Output("Color", self, VALUE_TYPE.color, c_white));
|
||||
|
||||
attribute_oversample(true);
|
||||
attributes.oversample = 1;
|
||||
|
||||
static getPreviewValues = function() { return getInputData(0); }
|
||||
|
||||
@ -70,7 +69,7 @@ function Node_Sampler(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
||||
var py = _pos[1] + j;
|
||||
|
||||
if(px < 0 || py < 0 || px >= ww || py >= hh) {
|
||||
switch(attributes.oversample) {
|
||||
switch(getAttribute("oversample")) {
|
||||
case 0 : continue;
|
||||
|
||||
case 1 :
|
||||
|
@ -373,7 +373,7 @@ function Node_Scatter(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) c
|
||||
#endregion
|
||||
|
||||
surface_set_target(_outSurf);
|
||||
gpu_set_tex_filter(attributes.interpolate);
|
||||
gpu_set_tex_filter(getAttribute("interpolate"));
|
||||
|
||||
DRAW_CLEAR
|
||||
switch(blend) {
|
||||
|
@ -53,7 +53,7 @@ function Node_Spherize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
attribute_oversample();
|
||||
attribute_interpolation();
|
||||
|
||||
attributes.oversample = 2;
|
||||
attributes.oversample = 3;
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
||||
PROCESSOR_OVERLAY_CHECK
|
||||
|
@ -1505,7 +1505,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
||||
}
|
||||
}
|
||||
|
||||
static setValueInspector = function(_val = 0, index = noone, time = CURRENT_FRAME) {
|
||||
static setValueInspector = function(_val = 0, index = noone, time = CURRENT_FRAME) { // This should be in panel_graph not here.
|
||||
INLINE
|
||||
|
||||
var res = false;
|
||||
|
@ -640,7 +640,7 @@ function Panel_Inspector() : PanelContent() constructor {
|
||||
var lby = yy + ui(12);
|
||||
draw_set_alpha(0.5);
|
||||
draw_set_text(f_p1, fa_center, fa_center, COLORS._main_text_sub);
|
||||
draw_text(xc, lby, edt);
|
||||
draw_text_add(xc, lby, edt);
|
||||
|
||||
var lbw = string_width(edt) / 2;
|
||||
draw_set_color(COLORS._main_text_sub);
|
||||
@ -667,7 +667,7 @@ function Panel_Inspector() : PanelContent() constructor {
|
||||
}
|
||||
|
||||
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
|
||||
draw_text(ui(8), yy + hg / 2, edt[0]);
|
||||
draw_text_add(ui(8), yy + hg / 2, edt[0]);
|
||||
|
||||
var _param = new widgetParam(wx0, yy, ww, hg, val, {}, _m, x + contentPane.x, y + contentPane.y);
|
||||
_param.s = hg;
|
||||
@ -1085,7 +1085,7 @@ function Panel_Inspector() : PanelContent() constructor {
|
||||
tb_node_name.setFocusHover(pFOCUS, pHOVER);
|
||||
|
||||
var txt = inspecting.renamed? inspecting.display_name : inspecting.name;
|
||||
if(inspectGroup == 1) txt = $"[{array_length(PANEL_GRAPH.nodes_selecting)}] {txt}";
|
||||
if(inspectGroup == 1) txt = $"[{array_length(PANEL_GRAPH.nodes_selecting)}] {txt}";
|
||||
else if(inspectGroup == -1) txt = $"[{array_length(PANEL_GRAPH.nodes_selecting)}] Multiple nodes";
|
||||
|
||||
tb_node_name.draw(ui(64), ui(14), w - ui(128), ui(32), txt, [ mx, my ]);
|
||||
|
@ -76,8 +76,7 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor
|
||||
if(is_numeric(_val)) _selVal = array_safe_get_fast(data, _val);
|
||||
|
||||
var _text = is_instanceof(_selVal, scrollItem)? _selVal.name : _selVal;
|
||||
if(is_string(_text))
|
||||
_text = string_trim_start(_text, ["-", ">", " "]);
|
||||
if(is_string(_text)) _text = string_trim_start(_text, ["-", ">", " "]);
|
||||
curr_text = _text;
|
||||
|
||||
w = _w;
|
||||
@ -106,9 +105,8 @@ function scrollBox(_data, _onModify, update_hover = true) : widget() constructor
|
||||
if(mouse_press(mb_left, active))
|
||||
trigger();
|
||||
|
||||
if(mouse_click(mb_left, active)) {
|
||||
if(mouse_click(mb_left, active))
|
||||
draw_sprite_stretched_ext(THEME.textbox, 2, _x, _y, w, _h, COLORS._main_accent, 1);
|
||||
}
|
||||
|
||||
if(is_array(data_list) && key_mod_press(SHIFT)) {
|
||||
var ind = array_find(data_list, _text);
|
||||
|
@ -186,10 +186,10 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount",
|
||||
function shader_preset_interpolation(shader = sh_sample) {
|
||||
INLINE
|
||||
|
||||
var intp = attributes.interpolate;
|
||||
var intp = getAttribute("interpolate");
|
||||
|
||||
shader_set_uniform_i(shader_get_uniform(shader, "interpolation"), intp);
|
||||
shader_set_uniform_i(shader_get_uniform(shader, "sampleMode"), attributes.oversample);
|
||||
shader_set_uniform_i(shader_get_uniform(shader, "sampleMode"), getAttribute("oversample"));
|
||||
}
|
||||
|
||||
function shader_postset_interpolation() {
|
||||
@ -207,11 +207,11 @@ function shader_set_palette(pal, pal_uni = "palette", amo_uni = "paletteAmount",
|
||||
function shader_set_interpolation(surface, _dim = noone) {
|
||||
INLINE
|
||||
|
||||
var intp = attributes.interpolate;
|
||||
var intp = getAttribute("interpolate");
|
||||
|
||||
shader_set_i("interpolation", intp);
|
||||
shader_set_f("sampleDimension", _dim == noone? surface_get_dimension(surface) : _dim);
|
||||
shader_set_i("sampleMode", attributes.oversample);
|
||||
shader_set_i("sampleMode", getAttribute("oversample"));
|
||||
}
|
||||
|
||||
function surface_set_shader(surface, shader = sh_sample, clear = true, blend = BLEND.alpha) {
|
||||
|
Loading…
Reference in New Issue
Block a user