[Composite/Armature bind] Now use alpha-compensated blending.

This commit is contained in:
Tanasart 2023-08-11 21:08:02 +02:00
parent 4c9eb2f4b2
commit f515e01260
24 changed files with 174 additions and 123 deletions

View file

@ -237,6 +237,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Horizontal.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Preview.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Side menu.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Vertical Ext.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Vertical.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"en.zip","CopyToMask":-1,"filePath":"datafiles/data/locale",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"config.json","CopyToMask":-1,"filePath":"datafiles/data/locale/en",},
@ -600,11 +601,6 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_textbox.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/widget",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"s_widget_highlight.png","CopyToMask":-1,"filePath":"datafiles/data/themes/default/graphics/widget",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"values.json","CopyToMask":-1,"filePath":"datafiles/data/themes/default",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Horizontal.json","CopyToMask":-1,"filePath":"datafiles/data/themes/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Preview.json","CopyToMask":-1,"filePath":"datafiles/data/themes/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Side menu.json","CopyToMask":-1,"filePath":"datafiles/data/themes/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Vertical Ext.json","CopyToMask":-1,"filePath":"datafiles/data/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Vertical.json","CopyToMask":-1,"filePath":"datafiles/data/themes/layouts",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"tooltip.zip","CopyToMask":3035426170322551022,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"0 introduction.png","CopyToMask":-1,"filePath":"datafiles/Getting started",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"0 introduction.pxc","CopyToMask":-1,"filePath":"datafiles/Getting started",},

Binary file not shown.

View file

@ -355,8 +355,8 @@ event_inherited();
con_thumb = attachment[? con_thumb.id];
var tx = ui(8);
var ty = _y + ui(64);
hh = ui(64);
var ty = _y + ui(68);
hh = ui(68);
var tw = sp_contest.surface_w - ui(16);
var th = 0;
@ -451,7 +451,7 @@ event_inherited();
draw_text_add(ch_x, ch_y, hearts);
var _w = string_width(hearts);
draw_sprite_ui(THEME.heart, 0, ch_x - _w - ui(16), ch_y + ui(10), 1, 1,, CDEF.red);
draw_sprite_ui(THEME.heart, 0, ch_x - _w - ui(16), ch_y + ui(10),,,, COLORS._main_icon_light);
grid_ys[_col] += grid_h + label_h + ui(8);
}
@ -461,7 +461,7 @@ event_inherited();
//banner
banner_alpha = lerp_float(banner_alpha, _y < 0, 5);
banner_alpha = lerp_float(banner_alpha, _y < 0, 3);
draw_sprite_stretched_ext(THEME.shadow_drop_down_24, 0, 0, ui(56), sp_contest.surface_w, ui(20), c_white, banner_alpha);
draw_set_color(COLORS.panel_bg_clear);
draw_rectangle(0, 0, sp_contest.surface_w, ui(64), false);

View file

@ -3,15 +3,15 @@
#endregion
#region macro
#macro BLEND_NORMAL gpu_set_blendmode(bm_normal)
#macro BLEND_ADD gpu_set_blendmode(bm_add)
#macro BLEND_OVERRIDE gpu_set_blendmode_ext(bm_one, bm_zero)
#macro BLEND_NORMAL gpu_set_blendmode(bm_normal)
#macro BLEND_ADD gpu_set_blendmode(bm_add)
#macro BLEND_OVERRIDE gpu_set_blendmode_ext(bm_one, bm_zero)
#macro BLEND_ALPHA gpu_set_blendmode_ext_sepalpha(bm_one, bm_inv_src_alpha, bm_one, bm_one)
#macro BLEND_ALPHA gpu_set_blendmode_ext_sepalpha(bm_one, bm_inv_src_alpha, bm_one, bm_one)
#macro BLEND_ALPHA_MULP gpu_set_blendmode_ext_sepalpha(bm_src_alpha, bm_inv_src_alpha, bm_one, bm_one)
#macro BLEND_MULTIPLY gpu_set_blendmode_ext(bm_dest_colour, bm_zero)
#macro BLEND_SUBTRACT gpu_set_blendmode(bm_subtract)
#macro BLEND_MULTIPLY gpu_set_blendmode_ext(bm_dest_colour, bm_zero)
#macro BLEND_SUBTRACT gpu_set_blendmode(bm_subtract)
#macro DRAW_CLEAR draw_clear_alpha(0, 0)
#endregion

View file

@ -23,7 +23,7 @@
rendering = false;
playback = ANIMATOR_END.loop;
static setFrame = function(frame) {
static setFrame = function(frame, resetTime = true) {
//if(frame == 0) resetAnimation();
var _c = current_frame;
@ -45,7 +45,8 @@
if(_c != current_frame) {
frame_progress = true;
time_since_last_frame = 0;
if(resetTime)
time_since_last_frame = 0;
UPDATE |= RENDER_TYPE.full;
} else
frame_progress = false;
@ -105,8 +106,10 @@
if(is_playing && play_freeze == 0) {
time_since_last_frame += framerate * (delta_time / 1000000);
if(time_since_last_frame >= 1)
setFrame(real_frame + 1);
if(time_since_last_frame >= 1) {
setFrame(real_frame + 1, false);
time_since_last_frame -= 1;
}
} else {
frame_progress = false;
//setFrame(real_frame);

View file

@ -1,7 +1,7 @@
globalvar BLEND_TYPES;
BLEND_TYPES = [ "Normal", "Add", "Subtract", "Multiply", "Screen", "Overlay", "Hue", "Saturation", "Luminosity", "Maximum", "Minimum", "Replace", "Difference" ];
function draw_surface_blend(background, foreground, blend, alpha, _pre_alp = true, _mask = 0, tile = 0) {
function draw_surface_blend(background, foreground, blend = 0, alpha = 1, _pre_alp = true, _mask = 0, tile = 0) {
if(!is_surface(background)) return;
var sh = sh_blend_normal
@ -50,4 +50,17 @@ function draw_surface_blend(background, foreground, blend, alpha, _pre_alp = tru
draw_surface_stretched_safe(background, 0, 0, surf_w, surf_h);
BLEND_NORMAL
shader_reset();
}
function draw_surface_blend_ext(bg, fg, _x, _y, _sx = 1, _sy = 1, _rot = 0, _col = c_white, _alpha = 1, _blend = 0) {
var _tmpS = surface_create_size(bg);
surface_set_shader(_tmpS);
shader_set_interpolation(fg);
draw_surface_ext(fg, _x, _y, _sx, _sy, _rot, _col, 1);
surface_reset_shader();
draw_surface_blend(bg, _tmpS, _blend, _alpha, false);
surface_free(_tmpS);
}

View file

@ -1,4 +1,7 @@
function draw_tooltip_text(txt) {
if(string_length(txt) > 1024)
txt = string_copy(txt, 1, 1024) + "...";
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
var tw = min(WIN_W - ui(32), string_width(txt));

View file

@ -9,7 +9,7 @@ function FFT(array_in) {
var fq = _FFT(array_in);
array_resize(fq, array_length(fq) / 2 + 1);
//fq = array_reverse(fq)
fq = array_reverse(fq)
return fq;
}

View file

@ -44,7 +44,7 @@ function fontScrollBox(_onModify) : widget() constructor {
if(open) {
resetFocus();
return;
return h;
}
draw_sprite_stretched(THEME.textbox, 3, _x, _y, w, _h);
@ -60,6 +60,8 @@ function fontScrollBox(_onModify) : widget() constructor {
if(mouse_press(mb_left)) deactivate();
}
_text = filename_name_only(_text);
draw_set_text(f_p0, align, fa_center, COLORS._main_text);
draw_set_alpha(0.5 + 0.5 * interactable);
if(align == fa_center)

View file

@ -66,8 +66,8 @@
}
attributeEditor = [
[ "Default Surface", "surface_dimension", new vectorBox(2, function(ind, val) { attributes.surface_dimension[ind] = val; }) ],
[ "Palette", "palette", new buttonPalette(function(pal) { attributes.palette = pal; }) ],
[ "Default Surface", "surface_dimension", new vectorBox(2, function(ind, val) { attributes.surface_dimension[ind] = val; return true; }) ],
[ "Palette", "palette", new buttonPalette(function(pal) { attributes.palette = pal; return true; }) ],
]
static cleanup = function() {
@ -104,7 +104,7 @@
VERSION = 11485;
SAVE_VERSION = 11482;
VERSION_STRING = "1.15rc5";
BUILD_NUMBER = 11485;
BUILD_NUMBER = 11486;
globalvar APPEND_MAP;
APPEND_MAP = ds_map_create();

View file

@ -73,7 +73,7 @@ function MetaDataManager() constructor {
var _h = 0;
if(type == FILE_TYPE.assets) {
draw_set_font(f_p0);
draw_set_font(f_p1);
_h = string_height(name);
_w = string_width(name);
@ -83,7 +83,7 @@ function MetaDataManager() constructor {
draw_sprite_stretched(THEME.textbox, 3, mx, my, _w + ui(16), _h + ui(16));
draw_sprite_stretched(THEME.textbox, 0, mx, my, _w + ui(16), _h + ui(16));
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
draw_text(mx + ui(8), my + ui(8), name);
return;
}
@ -95,18 +95,17 @@ function MetaDataManager() constructor {
_h += string_height_ext(name, -1, ww) - ui(4);
_w = max(_w, string_width_ext(name, -1, ww));
draw_set_font(f_p0b);
draw_set_font(f_p1);
_h += string_height_ext(_aut, -1, ww);
_w = max(_w, string_width_ext(_aut, -1, ww));
if(contact != "") {
draw_set_font(f_p2);
_h += ui(-4);
_h += string_height_ext(contact, -1, ww);
_h += string_height_ext(contact, -1, ww) + ui(-2);
_w = max(_w, string_width_ext(contact, -1, ww));
}
draw_set_font(f_p0);
draw_set_font(f_p1);
_h += ui(8);
_h += string_height_ext(description, -1, ww);
_w = max(_w, string_width_ext(description, -1, ww));
@ -126,10 +125,10 @@ function MetaDataManager() constructor {
}
if(array_length(tags)) {
draw_set_font(f_p0);
draw_set_font(f_p1);
_h += ui(8);
var tx = 0;
var hh = line_get_height(f_p0, ui(4));
var hh = line_get_height(f_p1, ui(4));
var th = hh;
for( var i = 0, n = array_length(tags); i < n; i++ ) {
var ww = string_width(tags[i]) + ui(16);
@ -156,19 +155,19 @@ function MetaDataManager() constructor {
draw_text_line(mx + ui(8), ty, name, -1, _w);
ty += string_height_ext(name, -1, _w) - ui(4);
draw_set_text(f_p0b, fa_left, fa_top, COLORS._main_text_sub);
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text_sub);
draw_text_line(mx + ui(8), ty, _aut, -1, _w);
ty += string_height_ext(_aut, -1, _w);
if(contact != "") {
ty += ui(-4);
ty += ui(-2);
draw_set_text(f_p2, fa_left, fa_top, COLORS._main_text_sub);
draw_text_line(mx + ui(8), ty, contact, -1, _w);
ty += string_height_ext(contact, -1, _w);
}
ty += ui(8);
draw_set_text(f_p0, fa_left, fa_top, COLORS._main_text);
draw_set_text(f_p1, fa_left, fa_top, COLORS._main_text);
draw_text_line(mx + ui(8), ty, description, -1, _w);
ty += string_height_ext(description, -1, _w);
@ -187,10 +186,10 @@ function MetaDataManager() constructor {
}
if(array_length(tags)) {
draw_set_text(f_p0, fa_left, fa_center, COLORS._main_text);
draw_set_text(f_p1, fa_left, fa_center, COLORS._main_text);
ty += ui(8);
var tx = 0;
var hh = line_get_height(f_p0, ui(4));
var hh = line_get_height(f_p1, ui(4));
for( var i = 0, n = array_length(tags); i < n; i++ ) {
var ww = string_width(tags[i]) + ui(16);

View file

@ -697,7 +697,11 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
if(mouse_press(mb_left, active))
surface_selecting = hovering;
if(surface_selecting != noone) {
var a = array_safe_get(anchors, surface_selecting, noone);
if(!is_struct(a)) surface_selecting = noone;
}
if(hovering != noone) {
var a = anchors[hovering];
@ -787,14 +791,9 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
overlay_w = _dim[0];
overlay_h = _dim[1];
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], cDep);
for(var i = 0; i < 2; i++) {
temp_surface[i] = surface_verify(temp_surface[i], surface_get_width(_outSurf), surface_get_height(_outSurf), cDep);
surface_set_target(temp_surface[i]);
DRAW_CLEAR
surface_reset_target();
temp_surface[i] = surface_verify(temp_surface[i], _dim[0], _dim[1], cDep);
surface_clear(temp_surface[i]);
}
var use_data = _bind != noone;
@ -802,8 +801,7 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
var bg = 0;
var imageAmo = use_data? array_length(_bind) : (ds_list_size(inputs) - input_fix_len) / data_length;
var _vis = attributes.layer_visible;
surface_set_shader(_outSurf, sh_sample, true, BLEND.alphamulp);
var _bg = 0;
for(var i = 0; i < imageAmo; i++) {
var vis = array_safe_get(_vis, i, true);
@ -847,8 +845,6 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
(_anc.y * _dsca) + _cen[1] + _mov[1] + _dpos[1]
];
shader_set_interpolation(_s);
array_push(atlas_data, new SurfaceAtlas(_s, _pos, _rot, _sca));
array_push(bind_data, {
surface: new Surface(_s),
@ -859,9 +855,18 @@ function Node_Armature_Bind(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr
applySca: _asca,
applyScal: _psca,
});
draw_surface_ext_safe(_s, _pos[0], _pos[1], _sca[0], _sca[1], _rot);
surface_set_shader(temp_surface[_bg], sh_sample, true, BLEND.over);
draw_surface_blend_ext(temp_surface[!_bg], _s, _pos[0], _pos[1], _sca[0], _sca[1], _rot);
surface_reset_shader();
_bg = !_bg;
}
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], cDep);
surface_set_shader(_outSurf);
draw_surface_safe(temp_surface[!_bg]);
surface_reset_shader();
return _outSurf;

View file

@ -676,7 +676,11 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
if(mouse_press(mb_left, active))
surface_selecting = hovering;
if(surface_selecting != noone) {
var a = array_safe_get(anchors, surface_selecting, noone);
if(!is_struct(a)) surface_selecting = noone;
}
if(hovering != noone) {
var a = anchors[hovering];
@ -774,8 +778,6 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
overlay_w = ww;
overlay_h = hh;
_outSurf = surface_verify(_outSurf, ww, hh, cDep);
for(var i = 0; i < 2; i++) {
temp_surface[i] = surface_verify(temp_surface[i], ww, hh, cDep);
surface_clear(temp_surface[i]);
@ -784,8 +786,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var res_index = 0, bg = 0;
var imageAmo = (ds_list_size(inputs) - input_fix_len) / data_length;
var _vis = attributes.layer_visible;
surface_set_shader(_outSurf, sh_sample, true, BLEND.alphamulp);
var _bg = 0;
for(var i = 0; i < imageAmo; i++) {
var vis = _vis[i];
@ -809,11 +810,19 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
var _d0 = point_rotate(cx - _sw / 2, cy - _sh / 2, cx, cy, _rot);
shader_set_interpolation(_s);
array_push(atlas_data, new SurfaceAtlas(_s, [ _d0[0], _d0[1] ], _rot, [ _sca[0], _sca[1] ]));
draw_surface_ext_safe(_s, _d0[0], _d0[1], _sca[0], _sca[1], _rot);
surface_set_shader(temp_surface[_bg], sh_sample, true, BLEND.over);
draw_surface_blend_ext(temp_surface[!_bg], _s, _d0[0], _d0[1], _sca[0], _sca[1], _rot);
surface_reset_shader();
_bg = !_bg;
}
_outSurf = surface_verify(_outSurf, ww, hh, cDep);
surface_set_shader(_outSurf);
draw_surface_safe(temp_surface[!_bg]);
surface_reset_shader();
return _outSurf;

View file

@ -20,7 +20,7 @@ function Node_CSV_File_Write(_x, _y, _group = noone) : Node(_x, _y, _group) cons
.rejectArray();
inputs[| 1] = nodeValue("Content", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, "")
.setDisplay(true);
.setDisplay(true, true);
static writeFile = function() {
var path = inputs[| 0].getValue();

View file

@ -1,11 +1,6 @@
function Node_Gradient_Points(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "4 Points Gradient";
shader = sh_gradient_points;
uniform_dim = shader_get_uniform(shader, "dimension");
uniform_cen = shader_get_uniform(shader, "center");
uniform_col = shader_get_uniform(shader, "color");
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
.setDisplay(VALUE_DISPLAY.vector);
@ -34,11 +29,24 @@ function Node_Gradient_Points(_x, _y, _group = noone) : Node_Processor(_x, _y, _
inputs[| 10] = nodeValue("Palette", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, DEF_PALETTE )
.setDisplay(VALUE_DISPLAY.palette);
inputs[| 11] = nodeValue("Falloff 1", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 6 )
.setDisplay(VALUE_DISPLAY.slider, [ 0, 32, 1 ]);
inputs[| 12] = nodeValue("Falloff 2", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 6 )
.setDisplay(VALUE_DISPLAY.slider, [ 0, 32, 1 ]);
inputs[| 13] = nodeValue("Falloff 3", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 6 )
.setDisplay(VALUE_DISPLAY.slider, [ 0, 32, 1 ]);
inputs[| 14] = nodeValue("Falloff 4", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 6 )
.setDisplay(VALUE_DISPLAY.slider, [ 0, 32, 1 ]);
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [
["Output", true], 0,
["Positions", false], 1, 3, 5, 7,
["Falloff", true], 11, 12, 13, 14,
["Colors", false], 9, 10, 2, 4, 6, 8,
];
@ -79,6 +87,11 @@ function Node_Gradient_Points(_x, _y, _group = noone) : Node_Processor(_x, _y, _
var _4cen = _data[7];
var _4col = _data[8];
var _1str = _data[11];
var _2str = _data[12];
var _3str = _data[13];
var _4str = _data[14];
var colArr = [];
if(_usePal) {
@ -89,10 +102,11 @@ function Node_Gradient_Points(_x, _y, _group = noone) : Node_Processor(_x, _y, _
surface_set_target(_outSurf);
DRAW_CLEAR
shader_set(shader);
shader_set_uniform_f_array_safe(uniform_dim, [_dim[0], _dim[1]]);
shader_set_uniform_f_array_safe(uniform_cen, array_merge(_1cen, _2cen, _3cen, _4cen));
shader_set_uniform_f_array_safe(uniform_col, colArr);
shader_set(sh_gradient_points);
shader_set_f("dimension", _dim[0], _dim[1]);
shader_set_f("center", array_merge(_1cen, _2cen, _3cen, _4cen));
shader_set_f("color", colArr);
shader_set_f("strength", _1str, _2str, _3str, _4str);
draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], c_white, 1);
shader_reset();

View file

@ -39,7 +39,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
inputs[| 1] = nodeValue("Sync lenght", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
.setDisplay(VALUE_DISPLAY.button, [ function() {
if(content == noone) return;
var frm = max(1, floor(content.duration * PROJECT.animator.framerate));
var frm = max(1, ceil(content.duration * PROJECT.animator.framerate));
PROJECT.animator.frames_total = frm;
}, "Sync"])
.rejectArray();
@ -69,6 +69,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
output_display_list = [ 0, 1, 2, 3, 4, 5 ];
audio_surface = -1;
preview_audio = -1;
preview_id = noone;
wav_file_reading = false;
wav_file_prg = 0;
@ -165,7 +166,7 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
printIf(global.FLAG.wav_import, "-- Creating preview buffer...");
var frm = floor(content.duration * PROJECT.animator.framerate);
var frm = ceil(content.duration * PROJECT.animator.framerate);
inputs[| 1].editWidget.text = $"Sync ({frm} frames)";
var bufferId = buffer_create(content.packet * 2, buffer_fixed, 1);
@ -214,15 +215,17 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
audio_stop_sound(preview_audio);
if(!attributes.play) return;
if(PROJECT.animator.is_playing) {
if(PROJECT.animator.current_frame == 0)
audio_stop_sound(preview_audio);
var dur = PROJECT.animator.current_frame / PROJECT.animator.framerate - attributes.preview_shift;
//if(preview_id && PROJECT.animator.frame_progress)
// audio_sound_set_track_position(preview_id, dur);
if(!audio_is_playing(preview_audio))
audio_play_sound(preview_audio, 1, false, attributes.preview_gain, dur);
else if(PROJECT.animator.frame_progress)
audio_sound_set_track_position(preview_audio, dur);
preview_id = audio_play_sound(preview_audio, 1, false, attributes.preview_gain, dur);
}
}
@ -233,21 +236,23 @@ function Node_WAV_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
if(path_current != path) updatePaths(path);
checkPreview();
if(!struct_has(content, "sound")) return;
if(array_length(content.sound) < 1) return;
var len = content.packet;
var amp_ind = round(frame * content.sample / PROJECT.animator.framerate);
var amp_win = content.sample / PROJECT.animator.framerate;
var amp_win = content.sample / PROJECT.animator.framerate * 3;
var amp_st = clamp(amp_ind - amp_win, 0, len);
var amp_ed = clamp(amp_ind + amp_win, 0, len);
if(!struct_has(content, "sound")) return;
if(array_length(content.sound) < 1) return;
var dec = 0;
var val = 0;
for( var i = amp_st; i < amp_ed; i++ )
dec += content.sound[0][i] == 0? 0 : 20 * log10(abs(content.sound[0][i]));
dec /= amp_ed - amp_st;
val += content.sound[0][i] * content.sound[0][i];
val /= amp_ed - amp_st;
val = sqrt(val);
var dec = 10 * log10(val);
outputs[| 5].setValue(dec);
}

View file

@ -39,44 +39,45 @@ function file_read_wav(path) {
wav_file_load_time = current_time;
//RIFF
printIf(global.FLAG.wav_import, "-- RIFF --")
var b = file_read_ASCII(wav_file_reader, 4); printIf(global.FLAG.wav_import, b);
var l = buffer_read(wav_file_reader, buffer_u32); printIf(global.FLAG.wav_import, $"Packages: {l}");
var w = file_read_ASCII(wav_file_reader, 4); printIf(global.FLAG.wav_import, w);
var debug_str = "";
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";
//FORMAT
printIf(global.FLAG.wav_import, "-- FORMAT --")
var b = file_read_ASCII(wav_file_reader, 4); printIf(global.FLAG.wav_import, b);
var l = buffer_read(wav_file_reader, buffer_u32); printIf(global.FLAG.wav_import, $"Length: {l}");
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.");
return noone;
}
var l = buffer_read(wav_file_reader, buffer_u16); printIf(global.FLAG.wav_import, $"0x01: {l}");
var ch = buffer_read(wav_file_reader, buffer_u16); printIf(global.FLAG.wav_import, $"Channels: {ch}");
var sm = buffer_read(wav_file_reader, buffer_u32); printIf(global.FLAG.wav_import, $"Sample: {sm}");
var l = buffer_read(wav_file_reader, buffer_u32); printIf(global.FLAG.wav_import, $"BPS: {l}");
var br = buffer_read(wav_file_reader, buffer_u16); printIf(global.FLAG.wav_import, $"Bitrate: {br}");
var l = buffer_read(wav_file_reader, buffer_u16); printIf(global.FLAG.wav_import, $"Bit/Sam: {l}");
var l = buffer_read(wav_file_reader, buffer_u16); debug_str += $"0x01: {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 l = buffer_read(wav_file_reader, buffer_u16); debug_str += $"Bit/Sam: {l}\n";
//DATA
printIf(global.FLAG.wav_import, "-- DATA --")
var b = file_read_ASCII(wav_file_reader, 4); printIf(global.FLAG.wav_import, b);
var l = buffer_read(wav_file_reader, buffer_u32); printIf(global.FLAG.wav_import, $"Length: {l}");
debug_str += "-- DATA --\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";
var bpc = br / ch;
var bits = l / br;
var data = array_create(ch);
printIf(global.FLAG.wav_import, "-- READ --")
printIf(global.FLAG.wav_import, $"Channels: {ch}");
printIf(global.FLAG.wav_import, $"BPC: {bpc * 8}");
printIf(global.FLAG.wav_import, $"bits: {bits}");
printIf(global.FLAG.wav_import, $"duration: {bits / sm}");
debug_str += "-- READ --\n";
debug_str += $"Channels: {ch}\n";
debug_str += $"BPC: {bpc * 8}\n";
debug_str += $"bits: {bits}\n";
debug_str += $"samples: {sm}\n";
debug_str += $"duration: {real(bits) / real(sm)}\n";
printIf(global.FLAG.wav_import, $"-- READING DATA --");
for( var j = 0; j < ch; j++ )
data[j] = array_create(bits);
@ -86,10 +87,12 @@ function file_read_wav(path) {
sample: sm,
channels: ch,
bit_depth: bpc * 8,
duration: bits / sm,
duration: real(bits) / real(sm),
packet: bits,
};
printIf(global.FLAG.wav_import, debug_str);
return content;
}

View file

@ -20,20 +20,19 @@ float sampleMask() {
}
void main() {
vec4 _col1 = texture2D( gm_BaseTexture, v_vTexcoord );
vec4 _cBg = texture2D( gm_BaseTexture, v_vTexcoord );
vec2 fore_tex = v_vTexcoord;
if(tile_type == 0) {
if(tile_type == 0)
fore_tex = v_vTexcoord;
} else if(tile_type == 1) {
else if(tile_type == 1)
fore_tex = fract(v_vTexcoord * dimension);
}
vec4 _col0 = texture2D( fore, fore_tex );
_col0.a *= opacity * sampleMask();
vec4 _cFg = texture2D( fore, fore_tex );
_cFg.a *= opacity * sampleMask();
float al = _col0.a + _col1.a * (1. - _col0.a);
vec4 res = ((_col0 * _col0.a) + (_col1 * _col1.a * (1. - _col0.a))) / al;
float al = _cFg.a + _cBg.a * (1. - _cFg.a);
vec4 res = ((_cFg * _cFg.a) + (_cBg * _cBg.a * (1. - _cFg.a))) / al;
res.a = al;
gl_FragColor = res;

View file

@ -9,6 +9,7 @@ varying vec4 v_vColour;
uniform vec2 dimension;
uniform vec2 center[4];
uniform vec3 color[4];
uniform vec4 strength;
void main() {
vec4 distances = vec4(0.);
@ -23,9 +24,8 @@ void main() {
maxDist *= 2.;
for( i = 0; i < 4; i++ ) {
distances[i] = pow((maxDist - distances[i]) / maxDist, 6.);
}
for( i = 0; i < 4; i++ )
distances[i] = pow((maxDist - distances[i]) / maxDist, strength[i]);
vec4 weights = distances / (distances[0] + distances[1] + distances[2] + distances[3]);
vec3 clr = (color[0] * weights[0]) + (color[1] * weights[1]) + (color[2] * weights[2]) + (color[3] * weights[3]);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -2,10 +2,10 @@
"resourceType": "GMSprite",
"resourceVersion": "1.0",
"name": "s_node_separate_file_path",
"bbox_bottom": 59,
"bbox_left": 5,
"bbox_right": 60,
"bbox_top": 4,
"bbox_bottom": 57,
"bbox_left": 6,
"bbox_right": 59,
"bbox_top": 6,
"bboxMode": 0,
"collisionKind": 1,
"collisionTolerance": 0,
@ -13,14 +13,14 @@
"edgeFiltering": false,
"For3D": false,
"frames": [
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"1f270fae-824c-4aee-a8af-edae52dcec78",},
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"b045347d-8c98-47e1-b0d1-a07ecd78d120",},
],
"gridX": 0,
"gridY": 0,
"height": 64,
"HTile": false,
"layers": [
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"b8b3aabd-ed36-46fb-8bb0-0c5e5b3b185d","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"9f2daf33-be34-4d20-8f6a-dc0aff8fd5b2","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
],
"nineSlice": null,
"origin": 4,
@ -54,7 +54,7 @@
"timeUnits": 1,
"tracks": [
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"1f270fae-824c-4aee-a8af-edae52dcec78","path":"sprites/s_node_separate_file_path/s_node_separate_file_path.yy",},},},"Disabled":false,"id":"3f430e86-df2e-4d02-9ba7-c7196c1e85db","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"b045347d-8c98-47e1-b0d1-a07ecd78d120","path":"sprites/s_node_separate_file_path/s_node_separate_file_path.yy",},},},"Disabled":false,"id":"d53ea5aa-08f1-488c-8135-4613e6160147","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange": null,