This commit is contained in:
Tanasart 2024-11-12 09:39:57 +07:00
parent 3952101495
commit 7f15c0fbd3
11 changed files with 96 additions and 64 deletions

View File

@ -31,25 +31,29 @@ function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) construct
var data = getInputDataForce(0); var data = getInputDataForce(0);
if(data == noone) return; if(data == noone) return;
var name = getInputData(2); var _lname = getInputData(2);
setDisplayName(name); setDisplayName(_lname);
for( var i = 0, n = array_length(data.layers); i < n; i++ ) { for( var i = 0, n = array_length(data.layers); i < n; i++ ) {
if(data.layers[i].name == name) if(data.layers[i].name == _lname)
layer_object = data.layers[i]; layer_object = data.layers[i];
} }
} }
static update = function(frame = CURRENT_FRAME) { static update = function(frame = CURRENT_FRAME) {
findLayer(); findLayer();
if(layer_object == noone) return;
var data = getInputData(0); var data = getInputData(0);
var cel = layer_object.getCel(CURRENT_FRAME - data._tag_delay);
var celDim = getInputData(1); var celDim = getInputData(1);
var name = getInputData(2); var _lname = getInputData(2);
outputs[1].setValue(_lname);
if(layer_object == noone) {
logNode($"Layer name {_lname} not found.");
return;
}
var cel = layer_object.getCel(CURRENT_FRAME - data._tag_delay);
var ww = data.content[$ "Width"]; var ww = data.content[$ "Width"];
var hh = data.content[$ "Height"]; var hh = data.content[$ "Height"];
var cw = cel? cel.data[$ "Width"] : 1; var cw = cel? cel.data[$ "Width"] : 1;
@ -59,7 +63,8 @@ function Node_ASE_layer(_x, _y, _group = noone) : Node(_x, _y, _group) construct
if(celDim) surf = surface_verify(surf, cw, ch); if(celDim) surf = surface_verify(surf, cw, ch);
else surf = surface_verify(surf, ww, hh); else surf = surface_verify(surf, ww, hh);
outputs[0].setValue(surf); outputs[0].setValue(surf);
outputs[1].setValue(name);
print($"Setting layer name {_lname}");
if(cel == 0) { surface_clear(surf); return; } if(cel == 0) { surface_clear(surf); return; }

View File

@ -2143,17 +2143,30 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
cache_result = array_verify(cache_result, TOTAL_FRAMES); cache_result = array_verify(cache_result, TOTAL_FRAMES);
} }
static cacheCurrentFrame = function(_frame) { static cacheCurrentFrame = function(_surface) {
cacheArrayCheck(); cacheArrayCheck();
if(CURRENT_FRAME < 0) return; var _frame = CURRENT_FRAME;
if(CURRENT_FRAME >= array_length(cached_output)) return; if(_frame < 0) return;
if(_frame >= array_length(cached_output)) return;
surface_array_free(cached_output[CURRENT_FRAME]); if(is_array(_surface)) {
cached_output[CURRENT_FRAME] = surface_array_clone(_frame); surface_array_free(cached_output[_frame]);
cached_output[_frame] = surface_array_clone(_surface);
array_safe_set(cache_result, CURRENT_FRAME, true); } else if(surface_exists(_surface)) {
var _sw = surface_get_width(_surface);
var _sh = surface_get_height(_surface);
return cached_output[CURRENT_FRAME]; cached_output[_frame] = surface_verify(cached_output[_frame], _sw, _sh);
surface_set_target(cached_output[_frame]);
DRAW_CLEAR BLEND_OVERRIDE
draw_surface(_surface, 0, 0);
surface_reset_target();
}
array_safe_set(cache_result, _frame, true);
return cached_output[_frame];
} }
static cacheExist = function(frame = CURRENT_FRAME) { static cacheExist = function(frame = CURRENT_FRAME) {

View File

@ -60,7 +60,7 @@ function Node_Interlaced(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
var _fram = CURRENT_FRAME - _back; var _fram = CURRENT_FRAME - _back;
if(_loop) _fram = (_fram + TOTAL_FRAMES) % TOTAL_FRAMES; if(_loop) _fram = (_fram + TOTAL_FRAMES) % TOTAL_FRAMES;
var _prev = array_safe_get_fast(cached_output, _fram, noone); var _prev = getCacheFrameIndex(_array_index, _fram);
surface_set_shader(_outSurf, sh_interlaced); surface_set_shader(_outSurf, sh_interlaced);
shader_set_i("useSurf", is_surface(_prev)); shader_set_i("useSurf", is_surface(_prev));
@ -74,7 +74,7 @@ function Node_Interlaced(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
draw_surface_safe(_surf); draw_surface_safe(_surf);
surface_reset_shader(); surface_reset_shader();
cacheCurrentFrame(_surf); cacheCurrentFrameIndex(_array_index, _surf);
__process_mask_modifier(_data); __process_mask_modifier(_data);
_outSurf = mask_apply(_data[0], _outSurf, _data[2], _data[3]); _outSurf = mask_apply(_data[0], _outSurf, _data[2], _data[3]);

View File

@ -86,7 +86,6 @@ function Node_MK_Delay_Machine(_x, _y, _group = noone) : Node(_x, _y, _group) co
} }
aa = eval_curve_x(_alpC, 1 - i / _amo); aa = eval_curve_x(_alpC, 1 - i / _amo);
draw_surface_ext(_s, 0, 0, 1, 1, 0, cc, aa); draw_surface_ext(_s, 0, 0, 1, 1, 0, cc, aa);
} }

View File

@ -411,25 +411,43 @@ function Node_Processor(_x, _y, _group = noone) : Node(_x, _y, _group) construct
///////////////////// CACHE ///////////////////// ///////////////////// CACHE /////////////////////
static cacheCurrentFrameIndex = function(_frame, index) { static cacheCurrentFrameIndex = function(_aindex, _surface) {
cacheArrayCheck(); cacheArrayCheck();
if(CURRENT_FRAME < 0) return; var _frame = CURRENT_FRAME;
if(CURRENT_FRAME >= array_length(cached_output)) return; if(_frame < 0) return;
if(_frame >= array_length(cached_output)) return;
var prev = cached_output[CURRENT_FRAME]; var _surfs = cached_output[_frame];
surface_array_free(array_safe_get_fast(prev, index)); var _cache = array_safe_get_fast(_surfs, _aindex);
cached_output[CURRENT_FRAME][index] = surface_array_clone(_frame);
array_safe_set(cache_result, CURRENT_FRAME, true); if(is_array(_surface)) {
surface_array_free(_cache);
_surfs[_aindex] = surface_array_clone(_surface);
return cached_output[CURRENT_FRAME]; } else if(surface_exists(_surface)) {
var _sw = surface_get_width(_surface);
var _sh = surface_get_height(_surface);
_cache = surface_verify(_cache, _sw, _sh);
surface_set_target(_cache);
DRAW_CLEAR BLEND_OVERRIDE
draw_surface(_surface, 0, 0);
surface_reset_target();
_surfs[_aindex] = _cache;
} }
static getCacheFrameIndex = function(frame = CURRENT_FRAME, index = 0) { cached_output[_frame] = _surfs;
if(frame < 0) return false; array_safe_set(cache_result, _frame, true);
if(!cacheExist(frame)) return noone;
var surf = array_safe_get_fast(cached_output, frame); return cached_output[_frame];
return array_safe_get_fast(surf, index); }
static getCacheFrameIndex = function(_aindex = 0, _frame = CURRENT_FRAME) {
if(_frame < 0) return false;
if(!cacheExist(_frame)) return noone;
var surf = array_safe_get_fast(cached_output, _frame);
return array_safe_get_fast(surf, _aindex, noone);
} }
} }

View File

@ -23,9 +23,7 @@ function Node_Rate_Remap(_x, _y, _group = noone) : Node_Processor(_x, _y, _group
var _step = PROJECT.animator.framerate / _rate; var _step = PROJECT.animator.framerate / _rate;
var _targ = floor(_time / _step) * _step; var _targ = floor(_time / _step) * _step;
cacheCurrentFrameIndex(_surf, _array_index); cacheCurrentFrameIndex(_array_index, _surf);
var s = getCacheFrameIndex(_targ, _array_index); return getCacheFrameIndex(_array_index, _targ);
return s;
} }
} }

View File

@ -18,7 +18,6 @@ function Node_Revert(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
} }
static update = function() { static update = function() {
if(!inputs[0].value_from) return; if(!inputs[0].value_from) return;
if(!inputs[0].value_from.node.renderActive) return; if(!inputs[0].value_from.node.renderActive) return;

View File

@ -2,6 +2,8 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
name = "Draw Text"; name = "Draw Text";
font = f_p0; font = f_p0;
dimension_index = -1;
newInput(0, nodeValue_Text("Text", self, "")) newInput(0, nodeValue_Text("Text", self, ""))
.setVisible(true, true); .setVisible(true, true);
@ -282,21 +284,24 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
var _use_path = _path != noone && struct_has(_path, "getPointDistance"); var _use_path = _path != noone && struct_has(_path, "getPointDistance");
var _ss = 1; var _ss = 1;
if(_use_path || _dimt == 0) { if(_use_path) {
_sw = _dim[0]; _sw = _dim[0];
_sh = _dim[1]; _sh = _dim[1];
} else if (_dimt == 0) {
_sw = _dim[0];
_sh = _dim[1];
if(_scaF) _ss = min(_sw / ww, _sh / hh);
} else { } else {
_sw = ww; _sw = ww;
_sh = hh; _sh = hh;
}
if(_dimt == 0 && !_use_path && _scaF)
_ss = min(_sw / ww, _sh / hh);
if(_wave) _sh += abs(_waveA) * 2; if(_wave) _sh += abs(_waveA) * 2;
}
_sw += _padd[PADDING.left] + _padd[PADDING.right]; _sw += _padd[PADDING.left] + _padd[PADDING.right];
_sh += _padd[PADDING.top] + _padd[PADDING.bottom]; _sh += _padd[PADDING.top] + _padd[PADDING.bottom];
_outSurf = surface_verify(_outSurf, _sw, _sh, attrDepth()); _outSurf = surface_verify(_outSurf, _sw, _sh, attrDepth());
#endregion #endregion

View File

@ -3,11 +3,6 @@ function Node_Time_Remap(_x, _y, _group = noone) : Node(_x, _y, _group) construc
use_cache = CACHE_USE.manual; use_cache = CACHE_USE.manual;
update_on_frame = true; update_on_frame = true;
shader = sh_time_remap;
uniform_map = shader_get_sampler_index(shader, "map");
uniform_min = shader_get_uniform(shader, "vMin");
uniform_max = shader_get_uniform(shader, "vMax");
newInput(0, nodeValue_Surface("Surface in", self)) newInput(0, nodeValue_Surface("Surface in", self))
.rejectArray(); .rejectArray();
@ -28,11 +23,12 @@ function Node_Time_Remap(_x, _y, _group = noone) : Node(_x, _y, _group) construc
attribute_surface_depth(); attribute_surface_depth();
static update = function(frame = CURRENT_FRAME) { #region static update = function(frame = CURRENT_FRAME) {
var _inSurf = getInputData(0); var _inSurf = getInputData(0);
var _map = getInputData(1); var _map = getInputData(1);
var _life = getInputData(2); var _life = getInputData(2);
var _loop = getInputData(3); var _loop = getInputData(3);
cacheCurrentFrame(_inSurf);
var _surf = outputs[0].getValue(); var _surf = outputs[0].getValue();
_surf = surface_verify(_surf, surface_get_width_safe(_inSurf), surface_get_height_safe(_inSurf), attrDepth()); _surf = surface_verify(_surf, surface_get_width_safe(_inSurf), surface_get_height_safe(_inSurf), attrDepth());
@ -40,26 +36,22 @@ function Node_Time_Remap(_x, _y, _group = noone) : Node(_x, _y, _group) construc
var ste = 1 / _life; var ste = 1 / _life;
surface_set_shader(_surf, shader); surface_set_shader(_surf, sh_time_remap);
texture_set_stage(uniform_map, surface_get_texture(_map)); shader_set_surface("map", _map);
for(var i = 0; i <= _life; i++) { for(var i = 0; i <= _life; i++) {
var _frame = CURRENT_FRAME - i; var _frame = CURRENT_FRAME - i;
if(_loop) if(_loop) _frame = _frame < 0? TOTAL_FRAMES - 1 + _frame : _frame;
_frame = _frame < 0? TOTAL_FRAMES - 1 + _frame : _frame; else _frame = clamp(_frame, 0, TOTAL_FRAMES - 1);
else
_frame = clamp(_frame, 0, TOTAL_FRAMES - 1);
var s = array_safe_get_fast(cached_output, _frame); var s = array_safe_get_fast(cached_output, _frame);
if(!is_surface(s)) continue; if(!is_surface(s)) continue;
shader_set_uniform_f(uniform_min, i * ste); shader_set_f("vMin", i * ste);
shader_set_uniform_f(uniform_max, i * ste + ste); shader_set_f("vMax", i * ste + ste);
draw_surface_safe(s); draw_surface_safe(s);
} }
surface_reset_shader(); surface_reset_shader();
}
cacheCurrentFrame(_inSurf);
} #endregion
} }

View File

@ -63,7 +63,11 @@ function Node_Trail(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
var _blend = getInputData(5); var _blend = getInputData(5);
var _alpha = getInputData(6); var _alpha = getInputData(6);
var cDep = attrDepth(); var cDep = attrDepth();
if(!is_surface(_surf)) return; if(!is_surface(_surf)) {
logNode($"Surface array not supported.");
return;
}
cacheCurrentFrame(_surf); cacheCurrentFrame(_surf);
for( var i = 0, n = array_length(temp_surface); i < n; i++ ) { for( var i = 0, n = array_length(temp_surface); i < n; i++ ) {

View File

@ -31,7 +31,6 @@
nodeNameMap = ds_map_create(); nodeNameMap = ds_map_create();
composer = noone; composer = noone;
animator = new AnimationManager(); animator = new AnimationManager();
globalNode = new Node_Global(); globalNode = new Node_Global();
nodeController = new __Node_Controller(self); nodeController = new __Node_Controller(self);