- [Export] Fix animation controller stays disable when exporting image sequence.

- Fix animation not stopping after rendered.
This commit is contained in:
Tanasart 2023-11-08 19:05:24 +07:00
parent 0927b8ccfa
commit 95b2cf6464
12 changed files with 125 additions and 109 deletions

View file

@ -1,4 +1,5 @@
/// @description /// @description
active = textbox != noone;
if(textbox == noone) exit; if(textbox == noone) exit;
if(textbox != WIDGET_CURRENT) exit; if(textbox != WIDGET_CURRENT) exit;

View file

@ -1,4 +1,5 @@
/// @description /// @description
active = textbox != noone;
if(textbox == noone) exit; if(textbox == noone) exit;
if(textbox != WIDGET_CURRENT) exit; if(textbox != WIDGET_CURRENT) exit;

View file

@ -2,7 +2,7 @@
global.cache_call = 0; global.cache_call = 0;
global.cache_hit = 0; global.cache_hit = 0;
HOVERING_ELEMENT = _HOVERING_ELEMENT; HOVERING_ELEMENT = _HOVERING_ELEMENT;
_HOVERING_ELEMENT = noone; _HOVERING_ELEMENT = noone;
#region minimize #region minimize

View file

@ -24,6 +24,7 @@
is_playing = false; is_playing = false;
frame_progress = false; frame_progress = false;
play_freeze = 0; play_freeze = 0;
render_stop = false;
rendering = []; rendering = [];
playback = ANIMATOR_END.loop; playback = ANIMATOR_END.loop;
@ -31,19 +32,21 @@
static setFrame = function(frame, resetTime = true) { static setFrame = function(frame, resetTime = true) {
//if(frame == 0) resetAnimation(); //if(frame == 0) resetAnimation();
var _c = current_frame; var _c = current_frame;
frame = clamp(frame, 0, frames_total); frame = clamp(frame, 0, frames_total);
real_frame = frame; real_frame = frame;
current_frame = round(frame); current_frame = round(frame);
if(current_frame == frames_total) { if(current_frame == frames_total) {
if(array_length(rendering)) { if(render_stop) {
is_playing = false; is_playing = false;
setFrame(0); setFrame(0);
} else if(playback == ANIMATOR_END.stop) render_stop = false;
} else if(playback == ANIMATOR_END.stop) {
is_playing = false; is_playing = false;
else } else {
setFrame(0); setFrame(0);
}
} }
if(_c != current_frame) { if(_c != current_frame) {
@ -53,6 +56,8 @@
RENDER_ALL RENDER_ALL
} else } else
frame_progress = false; frame_progress = false;
if(array_length(rendering)) render_stop = true;
} }
static resetAnimation = function() { static resetAnimation = function() {

View file

@ -1,17 +1,6 @@
function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor { function Node_Displace(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Displace"; name = "Displace";
shader = sh_displace;
displace_map_sample = shader_get_sampler_index(shader, "map");
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_map_dim = shader_get_uniform(shader, "map_dimension");
uniform_position = shader_get_uniform(shader, "displace");
uniform_strength = shader_get_uniform(shader, "strength");
uniform_mid = shader_get_uniform(shader, "middle");
uniform_rg = shader_get_uniform(shader, "use_rg");
uniform_it = shader_get_uniform(shader, "iterate");
uniform_sam = shader_get_uniform(shader, "sampleMode");
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
inputs[| 1] = nodeValue("Displace map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0); inputs[| 1] = nodeValue("Displace map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
@ -45,11 +34,14 @@ If set, then strength value control how many times the effect applies on itself.
inputs[| 10] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true); inputs[| 10] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 10; active_index = 10;
inputs[| 11] = nodeValue("Blend mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Overwrite", "Min", "Max" ]);
input_display_list = [ 10, input_display_list = [ 10,
["Output", true], 0, 8, 9, ["Output", true], 0, 8, 9,
["Displace", false], 1, 3, 4, ["Displace", false], 1, 3, 4,
["Color", false], 5, 2, ["Color", false], 5, 2,
["Algorithm", true], 6 ["Algorithm", true], 6, 11,
]; ];
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);
@ -74,18 +66,18 @@ If set, then strength value control how many times the effect applies on itself.
var mw = surface_get_width_safe(_data[1]); var mw = surface_get_width_safe(_data[1]);
var mh = surface_get_height_safe(_data[1]); var mh = surface_get_height_safe(_data[1]);
surface_set_shader(_outSurf, shader); surface_set_shader(_outSurf, sh_displace);
shader_set_interpolation(_data[0]); shader_set_interpolation(_data[0]);
texture_set_stage(displace_map_sample, surface_get_texture(_data[1])); shader_set_surface("map", _data[1]);
shader_set_uniform_f_array_safe(uniform_dim, [ww, hh]); shader_set_f("dimension", [ww, hh]);
shader_set_uniform_f_array_safe(uniform_map_dim, [mw, mh]); shader_set_f("map_dimension", [mw, mh]);
shader_set_uniform_f_array_safe(uniform_position, _data[2]); shader_set_f("displace", _data[2]);
shader_set_uniform_f(uniform_strength, _data[3]); shader_set_f("strength", _data[3]);
shader_set_uniform_f(uniform_mid, _data[4]); shader_set_f("middle", _data[4]);
shader_set_uniform_i(uniform_rg, _data[5]); shader_set_i("use_rg", _data[5]);
shader_set_uniform_i(uniform_it, _data[6]); shader_set_i("iterate", _data[6]);
shader_set_uniform_i(uniform_sam, struct_try_get(attributes, "oversample")); shader_set_i("blendMode", _data[11]);
draw_surface_safe(_data[0], 0, 0); draw_surface_safe(_data[0]);
surface_reset_shader(); surface_reset_shader();
_outSurf = mask_apply(_data[0], _outSurf, _data[8], _data[9]); _outSurf = mask_apply(_data[0], _outSurf, _data[8], _data[9]);

View file

@ -687,7 +687,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
update_on_frame = true; update_on_frame = true;
playing = true; playing = true;
played = 0; played = 0;
PROJECT.animator.real_frame = -1; PROJECT.animator.real_frame = -1;
CURRENT_FRAME = -1; CURRENT_FRAME = -1;
IS_PLAYING = true; IS_PLAYING = true;
array_push(RENDERING, node_id); array_push(RENDERING, node_id);
@ -769,8 +769,12 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
export(); export();
if(CURRENT_FRAME == TOTAL_FRAMES - 1 && anim == NODE_EXPORT_FORMAT.animation) if(CURRENT_FRAME == TOTAL_FRAMES - 1) {
renderCompleted(); if(anim == NODE_EXPORT_FORMAT.sequence)
array_remove(RENDERING, node_id);
else if(anim == NODE_EXPORT_FORMAT.animation)
renderCompleted();
}
} #endregion } #endregion
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region

View file

@ -31,9 +31,9 @@ function Node_Gradient(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
inputs[| 5] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0) inputs[| 5] = nodeValue("Shift", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setDisplay(VALUE_DISPLAY.slider, { range: [-2, 2, 0.01] }); .setDisplay(VALUE_DISPLAY.slider, { range: [-2, 2, 0.01] });
inputs[| 6] = nodeValue("Center", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [DEF_SURF_W / 2, DEF_SURF_H / 2]) inputs[| 6] = nodeValue("Center", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0.5, 0.5 ])
.setDisplay(VALUE_DISPLAY.vector) .setDisplay(VALUE_DISPLAY.vector)
.setUnitRef(function(index) { return getDimension(index); }); .setUnitRef(function(index) { return getDimension(index); }, VALUE_UNIT.reference);
inputs[| 7] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false); inputs[| 7] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);

View file

@ -50,7 +50,7 @@ function Node_Threshold(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _bright = _data[1]; var _bright = _data[1];
var _brightThreshold = _data[2]; var _brightThreshold = _data[2];
var _brightSmooth = _data[3]; var _brightSmooth = _data[3];
var _alpha = _data[7]; var _alpha = _data[7];
var _alphaThreshold = _data[8]; var _alphaThreshold = _data[8];
var _alphaSmooth = _data[9]; var _alphaSmooth = _data[9];

View file

@ -136,37 +136,37 @@ function Panel_Animation() : PanelContent() constructor {
function() { return __txt("Stop"); }, function() { return __txt("Stop"); },
function() { return 4; }, function() { return 4; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; }, function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { return; PROJECT.animator.stop(); } function() { PROJECT.animator.stop(); }
], ],
[ [
function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play"); }, function() { return PROJECT.animator.is_playing? __txt("Pause") : __txt("Play"); },
function() { return !PROJECT.animator.is_playing; }, function() { return !PROJECT.animator.is_playing; },
function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; }, function() { return PROJECT.animator.is_playing? COLORS._main_accent : COLORS._main_icon; },
function() { return; if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); } function() { if(PROJECT.animator.is_playing) PROJECT.animator.pause(); else PROJECT.animator.resume(); }
], ],
[ [
function() { return __txtx("panel_animation_go_to_first_frame", "Go to first frame"); }, function() { return __txtx("panel_animation_go_to_first_frame", "Go to first frame"); },
function() { return 3; }, function() { return 3; },
function() { return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(0); } function() { PROJECT.animator.setFrame(0); }
], ],
[ [
function() { return __txtx("panel_animation_go_to_last_frame", "Go to last frame"); }, function() { return __txtx("panel_animation_go_to_last_frame", "Go to last frame"); },
function() { return 2; }, function() { return 2; },
function() { return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(TOTAL_FRAMES - 1); } function() { PROJECT.animator.setFrame(TOTAL_FRAMES - 1); }
], ],
[ [
function() { return __txtx("panel_animation_previous_frame", "Previous frame"); }, function() { return __txtx("panel_animation_previous_frame", "Previous frame"); },
function() { return 5; }, function() { return 5; },
function() { return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); } function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame - 1); }
], ],
[ [
function() { return __txtx("panel_animation_next_frame", "Next frame"); }, function() { return __txtx("panel_animation_next_frame", "Next frame"); },
function() { return 6; }, function() { return 6; },
function() { return COLORS._main_icon; }, function() { return COLORS._main_icon; },
function() { return; PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); } function() { PROJECT.animator.setFrame(PROJECT.animator.real_frame + 1); }
], ],
]; ];
#endregion #endregion
@ -1838,8 +1838,6 @@ function Panel_Animation() : PanelContent() constructor {
var row = ceil(amo / col); var row = ceil(amo / col);
if(col < 1) return; if(col < 1) return;
var _act = !IS_RENDERING;
for( var i = 0; i < row; i++ ) { for( var i = 0; i < row; i++ ) {
var colAmo = min(amo - i * col, col); var colAmo = min(amo - i * col, col);
if(mini) if(mini)
@ -1851,10 +1849,10 @@ function Panel_Animation() : PanelContent() constructor {
var but = control_buttons[ind]; var but = control_buttons[ind];
var txt = but[0](); var txt = but[0]();
var ind = but[1](); var ind = but[1]();
var cc = _act? but[2]() : COLORS._main_icon_dark; var cc = IS_RENDERING? COLORS._main_icon_dark : but[2]();
var fnc = but[3]; var fnc = but[3];
if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && _act, pHOVER && _act, txt, THEME.sequence_control, ind, cc) == 2) if(buttonInstant(THEME.button_hide, bx, by, ui(32), ui(32), [mx, my], pFOCUS && !IS_RENDERING, pHOVER && !IS_RENDERING, txt, THEME.sequence_control, ind, cc) == 2)
fnc(); fnc();
bx += ui(36); bx += ui(36);

View file

@ -1223,10 +1223,7 @@ function Panel_Preview() : PanelContent() constructor {
if(!_node) return; if(!_node) return;
if(tool_current != noone) { #region tool settings if(tool_current != noone) { #region tool settings
var settings = _node.getToolSettings(); var settings = array_merge(_node.getToolSettings(), tool_current.settings);
var len = array_length(settings);
for( var i = 0, n = array_length(tool_current.settings); i < n; i++ )
settings[len + i] = tool_current.settings[i];
tool_x = lerp_float(tool_x, tool_x_to, 5); tool_x = lerp_float(tool_x, tool_x_to, 5);
var tolx = tool_x + ui(16); var tolx = tool_x + ui(16);

View file

@ -107,7 +107,8 @@ function textArea(_input, _onModify) : textInput(_input, _onModify) constructor
var data = autocomplete_server(pmt, localParams, autocomplete_context); var data = autocomplete_server(pmt, localParams, autocomplete_context);
if(array_length(data)) { if(array_length(data)) {
o_dialog_textbox_autocomplete.data = data; o_dialog_textbox_autocomplete.data = data;
o_dialog_textbox_autocomplete.prompt = pmt;
o_dialog_textbox_autocomplete.activate(self); o_dialog_textbox_autocomplete.activate(self);
} }

View file

@ -13,72 +13,71 @@ uniform float middle;
uniform int iterate; uniform int iterate;
uniform int use_rg; uniform int use_rg;
uniform int sampleMode; uniform int sampleMode;
uniform int blendMode;
float bright(in vec4 col) { float bright(in vec4 col) { return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * col.a; }
return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * col.a;
}
/////////////// SAMPLING /////////////// #region /////////////// SAMPLING ///////////////
const float PI = 3.14159265358979323846; const float PI = 3.14159265358979323846;
uniform int interpolation; uniform int interpolation;
uniform vec2 sampleDimension; uniform vec2 sampleDimension;
const int RSIN_RADIUS = 1; const int RSIN_RADIUS = 1;
float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); } float sinc ( float x ) { return x == 0.? 1. : sin(x * PI) / (x * PI); }
vec4 texture2D_rsin( sampler2D texture, vec2 uv ) { vec4 texture2D_rsin( sampler2D texture, vec2 uv ) {
vec2 tx = 1.0 / sampleDimension; vec2 tx = 1.0 / sampleDimension;
vec2 p = uv * sampleDimension - vec2(0.5); vec2 p = uv * sampleDimension - vec2(0.5);
vec4 sum = vec4(0.0); vec4 sum = vec4(0.0);
float weights = 0.; float weights = 0.;
for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++) for (int x = -RSIN_RADIUS; x <= RSIN_RADIUS; x++)
for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) { for (int y = -RSIN_RADIUS; y <= RSIN_RADIUS; y++) {
float a = length(vec2(float(x), float(y))) / float(RSIN_RADIUS); float a = length(vec2(float(x), float(y))) / float(RSIN_RADIUS);
if(a > 1.) continue; if(a > 1.) continue;
float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y); float w = sinc(a * PI * tx.x) * sinc(a * PI * tx.y);
vec2 offset = vec2(float(x), float(y)) * tx; vec2 offset = vec2(float(x), float(y)) * tx;
vec4 sample = texture2D(texture, (p + offset + vec2(0.5)) / sampleDimension); vec4 sample = texture2D(texture, (p + offset + vec2(0.5)) / sampleDimension);
sum += w * sample; sum += w * sample;
weights += w; weights += w;
} }
return sum / weights; return sum / weights;
} }
vec4 texture2D_bicubic( sampler2D texture, vec2 uv ) { vec4 texture2D_bicubic( sampler2D texture, vec2 uv ) {
uv = uv * sampleDimension + 0.5; uv = uv * sampleDimension + 0.5;
vec2 iuv = floor( uv ); vec2 iuv = floor( uv );
vec2 fuv = fract( uv ); vec2 fuv = fract( uv );
uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv); uv = iuv + fuv * fuv * (3.0 - 2.0 * fuv);
uv = (uv - 0.5) / sampleDimension; uv = (uv - 0.5) / sampleDimension;
return texture2D( texture, uv ); return texture2D( texture, uv );
} }
vec4 texture2Dintp( sampler2D texture, vec2 uv ) { vec4 texture2Dintp( sampler2D texture, vec2 uv ) {
if(interpolation == 2) return texture2D_bicubic( texture, uv ); if(interpolation == 2) return texture2D_bicubic( texture, uv );
else if(interpolation == 3) return texture2D_rsin( texture, uv ); else if(interpolation == 3) return texture2D_rsin( texture, uv );
return texture2D( texture, uv ); return texture2D( texture, uv );
} }
/////////////// SAMPLING /////////////// vec4 sampleTexture(vec2 pos) {
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
vec4 sampleTexture(vec2 pos) { return texture2Dintp(gm_BaseTexture, pos);
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
return texture2Dintp(gm_BaseTexture, pos); if(sampleMode == 0)
return vec4(0.);
if(sampleMode == 1)
return texture2Dintp(gm_BaseTexture, clamp(pos, 0., 1.));
if(sampleMode == 2)
return texture2Dintp(gm_BaseTexture, fract(pos));
if(sampleMode == 0)
return vec4(0.); return vec4(0.);
if(sampleMode == 1) }
return texture2Dintp(gm_BaseTexture, clamp(pos, 0., 1.));
if(sampleMode == 2) #endregion /////////////// SAMPLING ///////////////
return texture2Dintp(gm_BaseTexture, fract(pos));
return vec4(0.);
}
vec2 shiftMap(in vec2 pos, in float str) { vec2 shiftMap(in vec2 pos, in float str) {
vec4 disP = texture2Dintp( map, pos ); vec4 disP = texture2Dintp( map, pos );
@ -104,16 +103,34 @@ vec2 shiftMap(in vec2 pos, in float str) {
return sam_pos; return sam_pos;
} }
vec4 blend(in vec4 c0, in vec4 c1) {
if(blendMode == 0) return c1;
else if(blendMode == 1) {
float b0 = bright(c0);
float b1 = bright(c1);
return b0 < b1? c0 : c1;
} else if(blendMode == 2) {
float b0 = bright(c0);
float b1 = bright(c1);
return b0 > b1? c0 : c1;
}
return c1;
}
void main() { void main() {
vec2 samPos = v_vTexcoord; vec2 samPos = v_vTexcoord;
vec4 ccol = sampleTexture( v_vTexcoord ), ncol;
if(iterate == 1) { if(iterate == 1) {
for(float i = 0.; i < strength; i++) for(float i = 0.; i < strength; i++) {
samPos = shiftMap(samPos, 1.); samPos = shiftMap(samPos, 1.);
} else ncol = blend(ccol, sampleTexture( samPos ));
}
} else {
samPos = shiftMap(samPos, strength); samPos = shiftMap(samPos, strength);
ncol = sampleTexture( samPos );
}
vec4 col = sampleTexture( samPos ); gl_FragColor = blend(ccol, ncol);
gl_FragColor = col;
} }