Camera rework and audio

This commit is contained in:
Tanasart 2024-04-03 14:40:37 +07:00
parent 7826e5d9c3
commit f878ff994f
23 changed files with 273 additions and 231 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -437,6 +437,15 @@ event_inherited();
})
));
ds_list_add(pref_appr, new __Panel_Linear_Setting_Item_Preference(
__txtx("panel_graph_group_require_shift", "Hold Shift to enter group"),
"panel_graph_group_require_shift",
new checkBox(function() {
PREFERENCES.panel_graph_group_require_shift = !PREFERENCES.panel_graph_group_require_shift;
PREF_SAVE();
})
));
ds_list_add(pref_appr, __txt("Inspector"));
ds_list_add(pref_appr, new __Panel_Linear_Setting_Item_Preference(

View file

@ -34,6 +34,7 @@
}
function get_asset(key) {
if(!ds_map_exists(global.ASSET_MAP, key)) return noone;
if(ds_map_exists(global.ASSET_CACHE, key)) {
@ -49,7 +50,7 @@
var spr = global.ASSET_MAP[? key].getSpr();
global.ASSET_CACHE[? key] = surface_create_from_sprite(spr);
return global.ASSET_CACHE[? key];
}
#endregion

View file

@ -2,43 +2,32 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
name = "Camera";
preview_alpha = 0.5;
inputs[| 0] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
onSurfaceSize = function() { return surface_get_dimension(getInputData(0)); };
inputs[| 1] = nodeValue("Focus area", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_AREA)
inputs[| 0] = nodeValue("Focus area", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_AREA)
.setDisplay(VALUE_DISPLAY.area, { onSurfaceSize, useShape : false });
inputs[| 2] = nodeValue("Zoom", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
inputs[| 1] = nodeValue("Zoom", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0.01, 4, 0.01 ] });
inputs[| 3] = nodeValue("Oversample mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0, "How to deal with pixel outside the surface.\n - Empty: Use empty pixel\n - Clamp: Repeat edge pixel\n - Repeat: Repeat texture.")
.setDisplay(VALUE_DISPLAY.enum_scroll, [ new scrollItem("Empty ", s_node_camera_repeat, 0),
new scrollItem("Repeat ", s_node_camera_repeat, 1),
new scrollItem("Repeat X", s_node_camera_repeat, 2),
new scrollItem("Repeat Y", s_node_camera_repeat, 3), ]);
inputs[| 2] = nodeValue("Depth of Field", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 4] = nodeValue("Fix background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 3] = nodeValue("Focal distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 5] = nodeValue("Depth of Field", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
inputs[| 4] = nodeValue("Defocus", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 6] = nodeValue("Focal distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 7] = nodeValue("Defocus", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1);
inputs[| 8] = nodeValue("Focal range", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
inputs[| 5] = nodeValue("Focal range", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Background", true], 0, 4, 3,
["Camera", false], 1, 2,
["Depth Of Field", true, 5], 6, 8, 7,
["Camera", false], 0, 1,
["Depth Of Field", true, 2], 3, 5, 4,
["Elements", true],
];
attribute_surface_depth();
setIsDynamicInput(3);
setIsDynamicInput(6);
temp_surface = [ noone, noone ];
@ -46,19 +35,30 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var index = ds_list_size(inputs);
var _s = floor((index - input_fix_len) / data_length);
if(_s) array_push(input_display_list, new Inspector_Spacer(20, true));
inputs[| index + 0] = nodeValue($"Element {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| index + 1] = nodeValue($"Parallax {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ] )
inputs[| index + 1] = nodeValue($"Positioning {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, false)
.setDisplay(VALUE_DISPLAY.enum_button, [ "Space", "Camera" ]);
inputs[| index + 2] = nodeValue($"Position {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
.setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(index); });
inputs[| index + 2] = nodeValue($"Oversample {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
inputs[| index + 3] = nodeValue($"Oversample {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ new scrollItem("Empty ", s_node_camera_repeat, 0),
new scrollItem("Repeat ", s_node_camera_repeat, 1),
new scrollItem("Repeat X", s_node_camera_repeat, 2),
new scrollItem("Repeat Y", s_node_camera_repeat, 3), ]);
array_append(input_display_list, [ index + 0, index + 1, index + 2 ]);
inputs[| index + 4] = nodeValue($"Parallax {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
inputs[| index + 5] = nodeValue($"Depth {_s}", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0);
for( var i = 0; i < data_length; i++ ) array_push(input_display_list, index + i);
} if(!LOADING && !APPENDING) createNewInput(); #endregion
static refreshDynamicInput = function() { #region
@ -69,19 +69,21 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
array_resize(input_display_list, input_display_len);
var sep = false;
for( var i = input_fix_len; i < ds_list_size(inputs); i += data_length ) {
if(inputs[| i].value_from) {
ds_list_add(_in, inputs[| i + 0]);
ds_list_add(_in, inputs[| i + 1]);
ds_list_add(_in, inputs[| i + 2]);
if(sep) array_push(input_display_list, new Inspector_Spacer(20, true));
sep = true;
for( var j = 0; j < data_length; j++ ) {
ds_list_add(_in, inputs[| i + j]);
array_push(input_display_list, i + j);
}
array_push(input_display_list, i + 0);
array_push(input_display_list, i + 1);
array_push(input_display_list, i + 2);
} else {
delete inputs[| i + 0];
delete inputs[| i + 1];
delete inputs[| i + 2];
for( var j = 0; j < data_length; j++ )
delete inputs[| i + j];
}
}
@ -101,20 +103,23 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
refreshDynamicInput();
} #endregion
static getPreviewValues = function() { return getInputData(0); }
static getPreviewValues = function() { return getInputData(input_fix_len); }
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, _params) { #region
if(array_length(current_data) == 0) return;
var _out = outputs[| 0].getValue();
var _area = current_data[1];
var _zoom = current_data[2];
var _out = outputs[| 0].getValue();
if(is_array(_out)) _out = _out[preview_index];
var _area = current_data[0];
var _zoom = current_data[1];
var _cam_x = _x + (_area[0] - _area[2] * _zoom) * _s;
var _cam_y = _y + (_area[1] - _area[3] * _zoom) * _s;
draw_surface_ext_safe(_out, _cam_x, _cam_y, _s * _zoom, _s * _zoom);
inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
if(PANEL_PREVIEW.getNodePreview() == self)
draw_surface_ext_safe(_out, _cam_x, _cam_y, _s * _zoom, _s * _zoom);
inputs[| 0].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
draw_set_color(COLORS._main_accent);
var x0 = _cam_x;
@ -126,18 +131,17 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
} #endregion
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
if(!is_surface(_data[0])) return;
var _area = _data[1];
var _zoom = _data[2];
var _samp = _data[3];
var _fix = _data[4];
if(!is_surface(_data[input_fix_len])) return;
var _dof = _data[5];
var _dof_dist = _data[6];
var _dof_stop = _data[7];
var _dof_rang = _data[8];
var _area = _data[0];
var _zoom = _data[1];
var cDep = attrDepth();
var _dof = _data[2];
var _dof_dist = _data[3];
var _dof_stop = _data[4];
var _dof_rang = _data[5];
var cDep = attrDepth();
var _cam_x = round(_area[0]);
var _cam_y = round(_area[1]);
@ -146,88 +150,83 @@ function Node_Camera(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
var _surf_w = round(surface_valid_size(_cam_w * 2));
var _surf_h = round(surface_valid_size(_cam_h * 2));
var ppInd = 0;
_outSurf = surface_verify(_outSurf, _surf_w, _surf_h, cDep);
temp_surface[0] = surface_verify(temp_surface[0], _surf_w, _surf_h, cDep);
temp_surface[1] = surface_verify(temp_surface[1], _surf_w, _surf_h, cDep);
for( var i = 0, n = array_length(temp_surface); i < n; i++ ) {
temp_surface[i] = surface_verify(temp_surface[i], _surf_w, _surf_h, cDep);
surface_clear(temp_surface[i]);
}
var amo = (ds_list_size(inputs) - input_fix_len) / data_length - 1;
surface_set_target(temp_surface[0]);
DRAW_CLEAR
surface_reset_target();
surface_set_target(temp_surface[1]);
DRAW_CLEAR
surface_reset_target();
shader_set(sh_camera);
shader_set_f("camDimension", _surf_w, _surf_h);
shader_set_f("zoom", _zoom);
var _surface, sx, sy, sz, _samp;
var px, py;
var _scnW, _scnH;
for( var i = -1; i < amo; i++ ) {
var ppInd = 0;
for( var i = 0; i < amo; i++ ) {
var ind = input_fix_len + i * data_length;
var _surf = _data[ind + 0];
var _sposT = _data[ind + 1];
var _spos = _data[ind + 2];
var _samp = _data[ind + 3];
var _paral = _data[ind + 4];
var _sdof = _data[ind + 5];
if(!is_surface(_surf)) continue;
ppInd = !ppInd;
surface_set_target(temp_surface[ppInd]);
if(i == -1) {
_surface = _data[0];
sx = _fix? 0 : _cam_x;
sy = _fix? 0 : _cam_y;
sz = 0;
_samp = _data[3];
px = sx;
py = sy;
} else {
var ind = input_fix_len + i * data_length;
var sx = _spos[0] + _paral[0] * _cam_x;
var sy = _spos[1] + _paral[1] * _cam_y;
_surface = _data[ind];
sz = _data[ind + 1][2];
sx = _data[ind + 1][0] * sz * _cam_x;
sy = _data[ind + 1][1] * sz * _cam_y;
_samp = _data[ind + 2];
px = _cam_x + sx;
py = _cam_y + sy;
var px, py;
if(_sposT == 0) {
px = _cam_x - sx;
py = _cam_y - sy;
} else {
px = -sx;
py = -sy;
}
_scnW = surface_get_width_safe(_surface);
_scnH = surface_get_height_safe(_surface);
var _scnW = surface_get_width_safe(_surf);
var _scnH = surface_get_height_safe(_surf);
px /= _scnW;
py /= _scnH;
shader_set_i("bg", i == -1? 1 : 0);
shader_set_i("sampleMode", _samp);
shader_set_f("scnDimension", _scnW, _scnH);
shader_set_f("position", px, py);
shader_set_f("bokehStrength", 0);
if(_dof) {
var _x = max(abs(sz - _dof_dist) - _dof_rang, 0);
var _x = max(abs(_sdof - _dof_dist) - _dof_rang, 0);
_x = _x * tanh(_x / 10);
shader_set_f("bokehStrength", _x * _dof_stop);
} else shader_set_f("bokehStrength", 0);
}
shader_set_surface("backg", temp_surface[!ppInd]); //prev surface
shader_set_surface("scene", _surface); //surface to draw
shader_set_surface("backg", temp_surface[!ppInd]); //prev surface
shader_set_surface("scene", _surf); //surface to draw
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _surf_w, _surf_h);
surface_set_target(temp_surface[ppInd]);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _surf_w, _surf_h);
surface_reset_target();
}
shader_reset();
surface_set_target(_outSurf);
DRAW_CLEAR
BLEND_OVERRIDE;
draw_surface_safe(temp_surface[ppInd], 0, 0);
BLEND_NORMAL;
surface_reset_target();
surface_set_shader(_outSurf, noone);
draw_surface_safe(temp_surface[ppInd]);
surface_reset_shader();
return _outSurf;
} #endregion
static processDeserialize = function() { #region
if(LOADING_VERSION < 11690)
ds_list_clear(load_map.inputs);
} #endregion
}

View file

@ -330,6 +330,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
return nextNodes;
} #endregion
static clearTopoSorted = function() { INLINE topoSorted = false; for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) { nodes[| i].clearTopoSorted(); } }
static setRenderStatus = function(result) { #region
LOG_BLOCK_START();
LOG_IF(global.FLAG.render == 1, $"Set render status for {INAME} : {result}");
@ -468,7 +470,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
for( var i = 0; i < _olen; i++ )
array_push_unique(_oarr, i);
for( var i = array_length(_oarr) - 1; i >= 0; i-- ) {
if(is_array(_iarr[i])) continue;
if(is_array(_oarr[i])) continue;
if(_oarr[i] >= _olen) array_delete(_oarr, i, 1);
}
output_display_list = attributes.output_display_list;
@ -548,6 +550,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
} #endregion
static onDoubleClick = function(panel) { #region
if(PREFERENCES.panel_graph_group_require_shift && !key_mod_press(SHIFT)) return false;
__temp_panel = panel;
if(PREFERENCES.graph_open_group_in_tab)
@ -557,6 +561,8 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
if(ononDoubleClick != noone)
ononDoubleClick(panel);
return true;
} #endregion
static ononDoubleClick = noone;
@ -646,11 +652,6 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
var _inarr = {};
var _dilst = [];
//for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ ) {
// if(struct_has(inputs[| i], "from"))
// array_push(_dilst, inputs[| i].from.node_id);
//}
if(APPENDING)
for( var i = 0, n = array_length(_ilist); i < n; i++ )
_ilist[i] = ds_map_try_get(APPEND_MAP, _ilist[i], _ilist[i]);
@ -671,13 +672,6 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
ds_list_add(inputs, _inarr[$ _ilist[i]]);
}
//var custom_input_list = [];
//for( var i = custom_input_index, n = ds_list_size(inputs); i < n; i++ ) {
// if(struct_has(inputs[| i], "from"))
// array_push(custom_input_list, inputs[| i].from.node_id);
//}
//print($"\n\ti: {_ilist}\n\td: {_dilst}\n\to: {custom_input_list}\n");
}
if(struct_has(attr, "custom_output_list")) {
@ -703,6 +697,7 @@ function Node_Collection(_x, _y, _group = noone) : Node(_x, _y, _group) construc
ds_list_add(outputs, _inarr[$ _ilist[i]]);
}
}
} #endregion

View file

@ -625,7 +625,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
for(var i = 0; i < ds_list_size(inputs); i++) {
if(!is_instanceof(inputs[| i], NodeValue)) continue;
var val = inputs[| i].getValue(frame,,, false);
var val = inputs[| i].getValue(frame);
setInputData(i, val);
}
} #endregion
@ -1067,7 +1067,6 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
static drawNodeName = function(xx, yy, _s) { #region
draw_name = false;
var _name = renamed? display_name : name;
if(_name == "") return;
@ -1278,10 +1277,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(show_output_name) {
for(var i = 0; i < ds_list_size(outputs); i++)
outputs[| i].drawNameBG(_s);
if(outputs[| i].visible) outputs[| i].drawNameBG(_s);
for(var i = 0; i < ds_list_size(outputs); i++)
outputs[| i].drawName(_s, _mx, _my);
if(outputs[| i].visible) outputs[| i].drawName(_s, _mx, _my);
}
if(NODE_HAS_INSP1 && PANEL_GRAPH.pHOVER && point_in_circle(_mx, _my, inspectInput1.x, inspectInput1.y, 10)) {
@ -1387,10 +1386,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
return noone;
} #endregion
__preview_surf = noone;
__preview_surf = false;
__preview_sw = noone;
__preview_sh = noone;
static setPreview = function(_surf) { #region
preview_surface = _surf;
__preview_surf = is_surface(_surf);
} #endregion
static drawPreview = function(xx, yy, _s) { #region
var surf = getGraphPreviewSurface();
if(surf == noone) return;
@ -1410,8 +1414,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
surf = surf[preview_index];
}
preview_surface = surf;
if(!is_surface(preview_surface)) return;
setPreview(surf);
if(!__preview_surf) return;
__preview_sw = surface_get_width(preview_surface);
__preview_sh = surface_get_height(preview_surface);
@ -1424,13 +1428,10 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
var _sh = __preview_sh;
var _ss = min(bbox.w / _sw, bbox.h / _sh);
draw_surface_ext(preview_surface, bbox.xc - _sw * _ss / 2, bbox.yc - _sh * _ss / 2, _ss, _ss, 0, c_white, 1);
//draw_surface_bbox(preview_surface, bbox, c_white, aa * graph_preview_alpha);
} #endregion
static getNodeDimension = function(showFormat = true) { #region
if(!is_surface(preview_surface))
return preview_array;
if(!__preview_surf) return preview_array;
var pw = surface_get_width_safe(preview_surface);
var ph = surface_get_height_safe(preview_surface);
@ -1466,7 +1467,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(struct_get(display_parameter, "show_dimension")) {
var txt = string(getNodeDimension(_s > 0.65));
draw_text(round(tx), round(ty), txt);
ty += string_height(txt) - 2;
ty += line_get_height(f_p2) - 2;
}
draw_set_font(f_p3);
@ -1537,8 +1538,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
if(show_parameter)
drawJunctionWidget(xx, yy, _mx, _my, _s, _hover, _focus);
if(_s >= 0.75)
drawNodeName(xx, yy, _s);
draw_name = false;
if(_s >= 0.75) drawNodeName(xx, yy, _s);
if(active_draw_index > -1) {
draw_sprite_stretched_ext(bg_sel_spr, 0, xx, yy, round(w * _s), round(h * _s), active_draw_index > 1? COLORS.node_border_file_drop : COLORS._main_accent, 1);
@ -2125,8 +2126,8 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
struct_append(attributes, attr);
} #endregion
static postDeserialize = function() {}
static processDeserialize = function() {}
static postDeserialize = function() {}
static applyDeserialize = function(preset = false) { #region
preApplyDeserialize();

View file

@ -200,7 +200,7 @@ function Node_Display_Text(_x, _y, _group = noone) : Node(_x, _y, _group) constr
draw_set_color(COLORS._main_accent);
if(point_in_rectangle(_mx, _my, _tx - 4, _y - 4, _tx + _tw + 4, _y + _th + 4)) {
if(PANEL_GRAPH.node_hovering == self && point_in_rectangle(_mx, _my, _tx - 4, _y - 4, _tx + _tw + 4, _y + _th + 4)) {
draw_sprite_stretched_points(THEME.ui_panel_fg, 1, _tx - 4, _y - 4, _tx + _tw + 4, _y + _th + 4, COLORS._main_accent, 1);
switch(string_lower(_c[1])) {

View file

@ -122,10 +122,8 @@ function Node_Group_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constru
onSetDisplayName = function() { attributes.inherit_name = false; }
outputs[| 0].onSetTo = function(juncTo) {
if(attributes.inherit_name) {
if(attributes.inherit_name && !LOADING && !APPENDING)
setDisplayName(juncTo.name);
attributes.inherit_name = false;
}
if(!attributes.inherit_type) return;
attributes.inherit_type = false;

View file

@ -17,10 +17,8 @@ function Node_Group_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constr
onSetDisplayName = function() { attributes.inherit_name = false; }
inputs[| 0].onSetFrom = function(juncFrom) {
if(attributes.inherit_name) {
if(attributes.inherit_name && !LOADING && !APPENDING)
setDisplayName(juncFrom.name);
attributes.inherit_name = false;
}
}
static setRenderStatus = function(result) { #region

View file

@ -28,9 +28,7 @@ function Node_Rigid_Render(_x, _y, _group = noone) : Node(_x, _y, _group) constr
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
preview_surface = noone;
static onInspector2Update = function() { clearCache(); }
static createNewInput = function() { #region

View file

@ -38,6 +38,7 @@ function Node_Scale(_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 scale = _data[1];
var mode = _data[2];
var targ = _data[3];
@ -47,7 +48,7 @@ function Node_Scale(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
inputs[| 1].setVisible(mode == 0);
inputs[| 3].setVisible(mode == 1);
var isAtlas = is_instanceof(_data[0], SurfaceAtlas);
var isAtlas = is_instanceof(surf, SurfaceAtlas);
if(isAtlas && !is_instanceof(_outSurf, SurfaceAtlas))
_outSurf = _data[0].clone(true);
var _surf = isAtlas? _outSurf.getSurface() : _outSurf;
@ -57,12 +58,12 @@ function Node_Scale(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
case 0 :
scx = scale;
scy = scale;
ww = scale * surface_get_width_safe(_data[0]);
hh = scale * surface_get_height_safe(_data[0]);
ww = scale * surface_get_width_safe(surf);
hh = scale * surface_get_height_safe(surf);
break;
case 1 :
scx = targ[0] / surface_get_width_safe(_data[0]);
scy = targ[1] / surface_get_height_safe(_data[0]);
scx = targ[0] / surface_get_width_safe(surf);
scy = targ[1] / surface_get_height_safe(surf);
ww = targ[0];
hh = targ[1];
break;
@ -77,11 +78,11 @@ function Node_Scale(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) con
if(isAtlas) {
if(_atlS) {
_outSurf.x = _data[0].x * scx;
_outSurf.y = _data[0].y * scy;
_outSurf.x = surf.x * scx;
_outSurf.y = surf.y * scy;
} else {
_outSurf.x = _data[0].x;
_outSurf.y = _data[0].y;
_outSurf.x = surf.x;
_outSurf.y = surf.y;
}
_outSurf.setSurface(_surf);

View file

@ -63,7 +63,7 @@ function Node_Transform(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 13] = nodeValue("Echo amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 8);
inputs[| 14] = nodeValue("Opacity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
inputs[| 14] = nodeValue("Alpha", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
.setDisplay(VALUE_DISPLAY.slider);
input_display_list = [ 11, 0,

View file

@ -650,6 +650,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
draw_junction_index = type;
junction_drawing = [ THEME.node_junctions_single, type ];
hover_in_graph = false;
drag_type = 0;
drag_mx = 0;
@ -1639,13 +1640,13 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var val = array_verify(val, array_length(animators));
for( var i = 0, n = array_length(animators); i < n; i++ )
val[i] = animators[i].values[| 0].value;
val[i] = animators[i].processType(animators[i].values[| 0].value);
return val;
}
if(ds_list_empty(animator.values)) return 0;
return animator.values[| 0].value;
return animator.processType(animator.values[| 0].value);
}
if(sep_axis) {
@ -1743,15 +1744,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static getValueRecursive = function(arr = __curr_get_val, _time = CURRENT_FRAME) { #region
if(type == VALUE_TYPE.trigger && connect_type == JUNCTION_CONNECT.output) { //trigger event will not propagate from input to output, need to be done manually
arr[@ 0] = ds_list_empty(animator.values)? 0 : animator.values[| 0].value;
arr[@ 1] = self;
return;
}
arr[@ 0] = __getAnimValue(_time);
arr[@ 1] = self;
if(type == VALUE_TYPE.trigger && connect_type == JUNCTION_CONNECT.output) //trigger event will not propagate from input to output, need to be done manually
return;
if(value_from_loop && value_from_loop.bypassConnection() && value_from_loop.junc_out)
value_from_loop.getValue(arr);
@ -1854,7 +1852,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
static showValue = function() { #region
INLINE
var val = animator.values[| 0].value;
var val = 0;
if(value_from != noone || is_anim || expUse)
val = getValue(CURRENT_FRAME, false, 0, true, true);
@ -1862,9 +1860,10 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
else if(sep_axis) {
show_val = array_verify(show_val, array_length(animators));
for( var i = 0, n = array_length(animators); i < n; i++ )
show_val[i] = animators[i].values[| 0].value;
show_val[i] = ds_list_empty(animators[i].values)? 0 : animators[i].processType(animators[i].values[| 0].value);
val = show_val;
}
} else
val = ds_list_empty(animator.values)? 0 : animator.processType(animator.values[| 0].value);
return val;
} #endregion
@ -1895,7 +1894,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return false;
}
if(array_depth == 0 && !typeArray(display_type)) { //Value is not an array by default, and no array depth enforced
if(array_depth == 0 && !typeArray(display_type)) { // Value is not an array by default, and no array depth enforced
if(_cac) cache_array[1] = true;
return true;
}
@ -2304,7 +2303,8 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
var hov = PANEL_GRAPH.pHOVER && (PANEL_GRAPH.node_hovering == noone || PANEL_GRAPH.node_hovering == node);
var _d = 12 * _s;
var is_hover = hov && point_in_rectangle(_mx, _my, x - _d, y - _d, x + _d, y + _d);
var is_hover = hov && point_in_rectangle(_mx, _my, x - _d, y - _d, x + _d, y + _d);
hover_in_graph = is_hover;
var _bgS = THEME.node_junctions_bg;
var _fgS = is_hover? THEME.node_junctions_outline_hover : THEME.node_junctions_outline;
@ -2351,22 +2351,25 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} #endregion
static drawName = function(_s, _mx, _my) { #region
var _hover = PANEL_GRAPH.pHOVER && point_in_circle(_mx, _my, x, y, 10 * _s);
var _draw_cc = _hover? COLORS._main_text : COLORS._main_text_sub;
var _draw_cc = hover_in_graph? COLORS._main_text : COLORS._main_text_sub;
draw_set_text(f_p1, fa_left, fa_center, _draw_cc);
if(type == VALUE_TYPE.action) {
var tx = x;
draw_set_text(f_p1, fa_center, fa_center, _draw_cc);
draw_text_int(tx, y - (line_get_height() + 16) / 2, name);
} else if(connect_type == JUNCTION_CONNECT.input) {
var tx = x - 12 * _s;
draw_set_halign(fa_right);
draw_text_int(tx, y, name);
} else {
var tx = x + 12 * _s;
draw_set_halign(fa_left);
draw_text_int(tx, y, name);
}
} #endregion

View file

@ -1,7 +1,7 @@
function Node_Vector_Split(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { #region
name = "Vector Split";
color = COLORS.node_blend_number;
setDimension(96);
setDimension(96, 0);
draw_padding = 4;

View file

@ -42,12 +42,12 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
drag_my = 0;
drag_s = [[0, 0], [0, 0]];
attributes[? "initalset"] = LOADING || APPENDING;
attributes.initalset = LOADING || APPENDING;
warp_surface = array_create(2);
static onValueFromUpdate = function(index) { #region
if(index == 0 && attributes[? "initalset"] == false) {
if(index == 0 && attributes.initalset == false) {
var _surf = getInputData(0);
if(!is_surface(_surf)) return;
@ -59,7 +59,7 @@ function Node_Warp(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
inputs[| 3].setValue([ 0, _sh ]);
inputs[| 4].setValue([ _sw, _sh ]);
attributes[? "initalset"] = true;
attributes.initalset = true;
}
} if(!LOADING && !APPENDING) run_in(1, function() { onValueFromUpdate(0); }) #endregion

View file

@ -186,9 +186,11 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(!attributes.play) return;
if(IS_FIRST_FRAME) { audio_stop_sound(preview_audio); }
if(PROJECT.animator.is_playing) {
var dur = CURRENT_FRAME / PROJECT.animator.framerate - attributes.preview_shift;
if(!audio_is_playing(preview_audio))
preview_id = audio_play_sound(preview_audio, 1, false, attributes.preview_gain, dur);
}

View file

@ -912,10 +912,12 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(node_hovering != noone)
_HOVERING_ELEMENT = node_hovering;
if(node_hovering != noone && pFOCUS && struct_has(node_hovering, "onDoubleClick") && DOUBLE_CLICK) {
node_hovering.onDoubleClick(self);
DOUBLE_CLICK = false;
node_hovering = noone;
if(node_hovering != noone && pFOCUS && DOUBLE_CLICK && struct_has(node_hovering, "onDoubleClick")) {
if(node_hovering.onDoubleClick(self)) {
DOUBLE_CLICK = false;
node_hovering = noone;
}
}
if(node_hovering) node_hovering.onDrawHover(gr_x, gr_y, mx, my, graph_s);

View file

@ -29,6 +29,8 @@ function Inspector_Custom_Renderer(drawFn, registerFn = noone) : widget() constr
function Inspector_Sprite(spr) constructor { self.spr = spr; }
function Inspector_Spacer(height, line = false) constructor { self.h = height; self.line = line; }
function Panel_Inspector() : PanelContent() constructor {
#region ---- main ----
title = __txt("Inspector");
@ -523,7 +525,19 @@ function Panel_Inspector() : PanelContent() constructor {
} else {
if(i >= array_length(_inspecting.input_display_list)) break;
var jun_disp = _inspecting.input_display_list[i];
if(is_instanceof(jun_disp, Inspector_Sprite)) { // SPRITE
if(is_instanceof(jun_disp, Inspector_Spacer)) { // SPACER
var _hh = ui(jun_disp.h);
var _yy = yy + _hh / 2 - ui(2);
if(jun_disp.line) {
draw_set_color(COLORS.panel_inspector_key_separator);
draw_line(ui(8), _yy, con_w - ui(8), _yy);
}
hh += _hh;
continue;
} else if(is_instanceof(jun_disp, Inspector_Sprite)) { // SPRITE
var _spr = jun_disp.spr;
var _sh = sprite_get_height(_spr);
@ -532,7 +546,7 @@ function Panel_Inspector() : PanelContent() constructor {
hh += _sh + ui(8);
continue;
} if(is_array(jun_disp)) { // LABEL
} else if(is_array(jun_disp)) { // LABEL
var pad = i && _colsp == false? ui(4) : 0
_colsp = false;
yy += pad;

View file

@ -40,6 +40,7 @@
PREFERENCES.panel_layout_file = "Vertical";
PREFERENCES.panel_graph_dragging = MOD_KEY.alt;
PREFERENCES.panel_graph_group_require_shift = true;
PREFERENCES.panel_preview_dragging = MOD_KEY.alt;
PREFERENCES.inspector_focus_on_double_click = true;

View file

@ -51,6 +51,8 @@ function ResetAllNodesRender() { #region
} #endregion
function NodeTopoSort() { #region
//print($"======================= RESET TOPO =======================")
var _key = ds_map_find_first(PROJECT.nodeMap);
var amo = ds_map_size(PROJECT.nodeMap);
var _t = get_timer();
@ -67,29 +69,34 @@ function NodeTopoSort() { #region
LOG_IF(global.FLAG.render == 1, $"+++++++ Topo Sort Completed: {ds_list_size(PROJECT.nodeTopo)} nodes sorted in {(get_timer() - _t) / 1000} ms +++++++");
} #endregion
function NodeListSort(_list, _nodeList) { #region
for( var i = 0, n = ds_list_size(_list); i < n; i++ )
_list[| i].clearTopoSorted();
ds_list_clear(_list);
__topoSort(_list, _nodeList);
} #endregion
function __sortNode(_list, _node) { #region
if(_node.topoSorted) return;
var _childs = [];
var _prev = _node.getPreviousNodes();
var _parents = [];
var _prev = _node.getPreviousNodes();
for( var i = 0, n = array_length(_prev); i < n; i++ ) {
var _in = _prev[i];
if(_in == noone || _in.topoSorted) continue;
array_push(_childs, _in);
array_push(_parents, _in);
}
//print($" > Checking {_node.name}: {array_length(_childs)}");
//print($" > Checking {_node.name}: {array_length(_parents)}");
if(array_empty(_childs)) {
if(is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder)
__topoSort(_list, _node.nodes);
} else {
for( var i = 0, n = array_length(_childs); i < n; i++ )
__sortNode(_list, _childs[i]);
}
if(is_instanceof(_node, Node_Collection) && !_node.managedRenderOrder)
__topoSort(_list, _node.nodes);
for( var i = 0, n = array_length(_parents); i < n; i++ )
__sortNode(_list, _parents[i]);
if(!_node.topoSorted) {
ds_list_add(_list, _node);
@ -100,12 +107,12 @@ function __sortNode(_list, _node) { #region
} #endregion
function __topoSort(_list, _nodeList) { #region
var _root = [];
var _leaf = [];
var _leftOver = [];
for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ ) {
var _node = _nodeList[| i];
var _isRoot = true;
var _isLeaf = true;
if(is_instanceof(_node, Node_Collection_Inline) && !_node.is_root) {
array_push(_leftOver, _node);
@ -117,19 +124,19 @@ function __topoSort(_list, _nodeList) { #region
for( var k = 0, p = array_length(_to); k < p; k++ ) {
if(ds_list_exist(_nodeList, _to[k].node)) {
_isRoot = false;
_isLeaf = false;
break;
}
}
if(!_isRoot) break;
if(!_isLeaf) break;
}
if(_isRoot) array_push(_root, _node);
if(_isLeaf) array_push(_leaf, _node);
}
for( var i = 0, n = array_length(_root); i < n; i++ )
__sortNode(_list, _root[i]);
for( var i = 0, n = array_length(_leaf); i < n; i++ )
__sortNode(_list, _leaf[i]);
for( var i = 0, n = array_length(_leftOver); i < n; i++ ) {
if(!_leftOver[i].topoSorted)
@ -137,14 +144,6 @@ function __topoSort(_list, _nodeList) { #region
}
} #endregion
function NodeListSort(_list, _nodeList) { #region
for( var i = 0, n = ds_list_size(_nodeList); i < n; i++ )
_nodeList[| i].topoSorted = false;
ds_list_clear(_list);
__topoSort(_list, _nodeList);
} #endregion
function __nodeIsRenderLeaf(_node) { #region
if(is_undefined(_node)) { LOG_IF(global.FLAG.render == 1, $"Skip undefiend [{_node}]"); return false; }
if(!is_instanceof(_node, Node)) { LOG_IF(global.FLAG.render == 1, $"Skip non-node [{_node}]"); return false; }

View file

@ -35,29 +35,42 @@ function file_read_wav(path) {
}
wav_file_load_time = current_time;
var _buffer_size = buffer_get_size(wav_file_reader);
//RIFF
var debug_str = "";
var debug_str = $">> READING WAV [{path}] <<\n";
debug_str += $"Buffer size: {_buffer_size}\n\n";
debug_str += "-- RIFF --\n";
var b = file_read_ASCII(wav_file_reader, 4); debug_str += $"{b}\n";
var l = buffer_read(wav_file_reader, buffer_u32); debug_str += $"Packages: {l}\n";
var w = file_read_ASCII(wav_file_reader, 4); debug_str += $"{w}\n";
if(b != "RIFF" || w != "WAVE") {
printIf(global.FLAG.wav_import, debug_str);
noti_warning("Not a valid .wav file.");
return noone;
}
if(buffer_get_size(wav_file_reader) != l + 8)
noti_warning(".wav file has different size than the package header. This may cause reading error.");
//FORMAT
debug_str += "-- FORMAT --\n";
var b = file_read_ASCII(wav_file_reader, 4); debug_str += $"{b}\n";
var l = buffer_read(wav_file_reader, buffer_u32); debug_str += $"Length: {l}\n";
if(l != 16) {
noti_warning("File format not supported, the audio file need to be 8, 16 bit PCM wav with no extension.");
printIf(global.FLAG.wav_import, debug_str);
noti_warning("File format not supported, the audio file need to be 8, 16 bit uncompressed PCM wav with no extension.");
return noone;
}
var l = buffer_read(wav_file_reader, buffer_u16); debug_str += $"0x01: {l}\n";
var l = buffer_read(wav_file_reader, buffer_u16); debug_str += $"Linear quantize: {l}\n";
var ch = buffer_read(wav_file_reader, buffer_u16); debug_str += $"Channels: {ch}\n";
var sm = buffer_read(wav_file_reader, buffer_u32); debug_str += $"Sample: {sm}\n";
var l = buffer_read(wav_file_reader, buffer_u32); debug_str += $"BPS: {l}\n";
var br = buffer_read(wav_file_reader, buffer_u16); debug_str += $"Bitrate: {br}\n";
var br = buffer_read(wav_file_reader, buffer_u16); debug_str += $"Byterate: {br}\n";
var l = buffer_read(wav_file_reader, buffer_u16); debug_str += $"Bit/Sam: {l}\n";
//DATA
@ -75,13 +88,19 @@ function file_read_wav(path) {
debug_str += $"BPC: {bpc * 8}\n";
debug_str += $"bits: {bits}\n";
debug_str += $"samples: {sm}\n";
debug_str += $"duration: {real(bits) / real(sm)}\n";
debug_str += $"duration: {real(bits) / real(sm)}s\n";
for( var j = 0; j < ch; j++ )
data[j] = array_create(bits);
wav_file_range = [0, 0];
var _buffer_left = _buffer_size - buffer_tell(wav_file_reader);
if(_buffer_left < l) {
noti_warning($"The file is smaller than the definded length. ({_buffer_left} < {l})");
bits = floor(_buffer_left / br);
}
content = new audioObject(sm, ch);
content.sound = data;
content.soundF = dataF;
@ -96,6 +115,7 @@ function file_read_wav(path) {
function file_read_wav_step() {
if(!wav_file_reading) return false;
if(!content) return false;
var t = current_time;
var bf_type, lim;
@ -104,11 +124,15 @@ function file_read_wav_step() {
else if(content.bit_depth == 32) { bf_type = buffer_s32; lim = 2_147_483_648; }
for(; wav_file_prg < content.packet; wav_file_prg++ ) {
var ch = 0;
for( var j = 0; j < content.channels; j++ ) {
var ch = 0;
var cha = content.channels;
var j = 0;
repeat( cha ) {
var b = buffer_read(wav_file_reader, bf_type) / lim;
ch += b;
content.sound[j][wav_file_prg] = b;
j++;
}
content.soundF[0][wav_file_prg] = ch / content.channels;

View file

@ -1,6 +1,3 @@
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
@ -9,20 +6,19 @@ uniform sampler2D scene;
uniform vec2 scnDimension;
uniform vec2 camDimension;
uniform vec2 position;
uniform vec2 position;
uniform float zoom;
uniform int sampleMode;
uniform int bg;
uniform int sampleMode;
uniform float bokehStrength;
const float GoldenAngle = 2.39996323;
const float Iterations = 400.0;
const float ContrastAmount = 150.0;
const vec3 ContrastFactor = vec3(9.0);
const vec3 ContrastFactor = vec3(9.0);
const float Smooth = 2.0;
vec4 sampleTexture(sampler2D samp, vec2 pos) {
vec4 sampleTexture(sampler2D samp, vec2 pos) { #region
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2D(samp, pos);
@ -39,14 +35,14 @@ vec4 sampleTexture(sampler2D samp, vec2 pos) {
return texture2D(samp, vec2(pos.x, fract(pos.y)));
return vec4(0.);
}
} #endregion
vec4 bokeh(sampler2D tex, vec2 uv, float radius) { //ref. sh_blur_bokeh
vec3 num, weight;
vec4 bokeh(sampler2D tex, vec2 uv, float radius) { #region ref. sh_blur_bokeh
vec3 num, weight;
float alpha = 0.;
float rec = 1.0; // reciprocal
vec2 horizontalAngle = vec2(0.0, radius * 0.01 / sqrt(Iterations));
vec2 aspect = vec2(scnDimension.y / scnDimension.x, 1.0);
float rec = 1.0; // reciprocal
vec2 horizontalAngle = vec2(0.0, radius * 0.01 / sqrt(Iterations));
vec2 aspect = vec2(scnDimension.y / scnDimension.x, 1.0);
mat2 Rotation = mat2(
cos(GoldenAngle), sin(GoldenAngle),
@ -70,19 +66,20 @@ vec4 bokeh(sampler2D tex, vec2 uv, float radius) { //ref. sh_blur_bokeh
weight += bokeh;
}
return vec4(num / weight, alpha / ((weight.r + weight.g + weight.b) / 3.));
}
float _a = alpha / ((weight.r + weight.g + weight.b) / 3.);
return vec4(num / weight, pow(_a, 3.));
} #endregion
void main() {
void main() { #region
vec2 pos = position + (v_vTexcoord - vec2(.5)) * (camDimension / scnDimension) * zoom;
//if(bg == 1) pos = position + (v_vTexcoord - vec2(.5)) * (camDimension / scnDimension);
vec4 _col0 = sampleTexture( backg, v_vTexcoord );
vec4 _col0 = sampleTexture( backg, v_vTexcoord );
vec4 _col1 = bokeh( scene, pos, bokehStrength );
float al = _col1.a + _col0.a * (1. - _col1.a);
vec4 res = _col0 * _col0.a * (1. - _col1.a) + _col1 * _col1.a;
res /= al;
res.a = al;
res /= al;
res.a = al;
gl_FragColor = res;
}
} #endregion