- [Ase File In] Fix alpha blending error.

This commit is contained in:
Tanasart 2024-07-22 15:48:16 +07:00
parent c9869709d5
commit 20c89a5d3d
3 changed files with 49 additions and 31 deletions

Binary file not shown.

View file

@ -159,6 +159,9 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
return _h; return _h;
}); });
temp_surface = [ 0, 0, 0 ];
blend_temp_surface = noone;
input_display_list = [ input_display_list = [
["File", true], 0, ["File", true], 0,
["Layers", false], 1, 3, layer_renderer, ["Layers", false], 1, 3, layer_renderer,
@ -166,6 +169,8 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
]; ];
attributes.layer_visible = []; attributes.layer_visible = [];
attributes.interpolate = 0;
attributes.oversample = 0;
edit_time = 0; edit_time = 0;
attributes.file_checker = true; attributes.file_checker = true;
@ -356,25 +361,38 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
surf = surface_verify(surf, ww, hh); surf = surface_verify(surf, ww, hh);
outputs[| 0].setValue(surf); outputs[| 0].setValue(surf);
surface_set_target(surf); for (var i = 0, n = array_length(temp_surface); i < n; i++) {
temp_surface[i] = surface_verify(temp_surface[i], ww, hh);
surface_clear(temp_surface[i]);
}
var _bg = 0;
blend_temp_surface = temp_surface[2];
for( var i = 0, n = array_length(layers); i < n; i++ ) {
layers[i].tag = tag;
var cel = layers[i].getCel(CURRENT_FRAME - _tag_delay);
if(!cel) continue;
if(!array_safe_get_fast(vis, i, true)) continue;
var _inSurf = cel.getSurface();
if(!is_surface(_inSurf))
continue;
var xx = cel.data[$ "X"];
var yy = cel.data[$ "Y"];
surface_set_shader(temp_surface[_bg], sh_sample, true, BLEND.over);
draw_surface_blend_ext(temp_surface[!_bg], _inSurf, xx, yy);
surface_reset_shader();
_bg = !_bg;
}
surface_set_shader(surf);
DRAW_CLEAR DRAW_CLEAR
draw_surface_safe(temp_surface[!_bg]);
for( var i = 0, n = array_length(layers); i < n; i++ ) { surface_reset_shader();
layers[i].tag = tag;
var cel = layers[i].getCel(CURRENT_FRAME - _tag_delay);
if(!cel) continue;
if(!array_safe_get_fast(vis, i, true)) continue;
var _inSurf = cel.getSurface();
if(!is_surface(_inSurf))
continue;
var xx = cel.data[$ "X"];
var yy = cel.data[$ "Y"];
draw_surface_safe(_inSurf, xx, yy);
}
surface_reset_target();
} }
static attributeSerialize = function() { static attributeSerialize = function() {

View file

@ -57,7 +57,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
tb_rename.hide = true; tb_rename.hide = true;
layer_height = 0; layer_height = 0;
layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) { #region layer_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
PROCESSOR_OVERLAY_CHECK PROCESSOR_OVERLAY_CHECK
var amo = getInputAmount(); var amo = getInputAmount();
@ -367,7 +367,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
} }
return layer_height; return layer_height;
}); #endregion });
input_display_list = [ input_display_list = [
["Output", true], 0, 1, 2, ["Output", true], 0, 1, 2,
@ -377,7 +377,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
input_display_list_len = array_length(input_display_list); input_display_list_len = array_length(input_display_list);
function deleteLayer(index) { #region function deleteLayer(index) {
var idx = input_fix_len + index * data_length; var idx = input_fix_len + index * data_length;
if(canvas_group) { if(canvas_group) {
@ -409,7 +409,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
array_push(input_display_list, i); array_push(input_display_list, i);
doUpdate(); doUpdate();
} #endregion }
static createNewInput = function() { static createNewInput = function() {
var index = ds_list_size(inputs); var index = ds_list_size(inputs);
@ -476,7 +476,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
overlay_w = 0; overlay_w = 0;
overlay_h = 0; overlay_h = 0;
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) {
PROCESSOR_OVERLAY_CHECK PROCESSOR_OVERLAY_CHECK
var pad = current_data[0]; var pad = current_data[0];
@ -746,18 +746,18 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
} }
} }
} #endregion }
static step = function() { #region static step = function() {
var _dim_type = getSingleValue(1); var _dim_type = getSingleValue(1);
inputs[| 2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant); inputs[| 2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant);
if(canvas_draw != noone && surface_selecting == noone && getInputAmount()) if(canvas_draw != noone && surface_selecting == noone && getInputAmount())
surface_selecting = input_fix_len; surface_selecting = input_fix_len;
} #endregion }
static processData = function(_outData, _data, _output_index, _array_index) { #region static processData = function(_outData, _data, _output_index, _array_index) {
var _outSurf = _outData[0]; var _outSurf = _outData[0];
if(array_length(_data) <= input_fix_len) return [ _outSurf, noone, [1, 1] ]; if(array_length(_data) <= input_fix_len) return [ _outSurf, noone, [1, 1] ];
@ -851,17 +851,17 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
surface_reset_shader(); surface_reset_shader();
return [ _outSurf, _atlas, [ww, hh] ]; return [ _outSurf, _atlas, [ww, hh] ];
} #endregion }
static attributeSerialize = function() { #region static attributeSerialize = function() {
var att = {}; var att = {};
att.layer_visible = attributes.layer_visible; att.layer_visible = attributes.layer_visible;
att.layer_selectable = attributes.layer_selectable; att.layer_selectable = attributes.layer_selectable;
return att; return att;
} #endregion }
static attributeDeserialize = function(attr) { #region static attributeDeserialize = function(attr) {
struct_append(attributes, attr); struct_append(attributes, attr);
if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension")) if(struct_has(attributes, "use_project_dimension") && !struct_has(attr, "use_project_dimension"))
@ -872,6 +872,6 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
if(struct_has(attr, "layer_selectable")) if(struct_has(attr, "layer_selectable"))
attributes.layer_selectable = attr.layer_selectable; attributes.layer_selectable = attr.layer_selectable;
} #endregion }
} }