- [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

@ -158,7 +158,10 @@ function Node_ASE_File_Read(_x, _y, _group = noone) : Node(_x, _y, _group) const
tag_renderer.h = _h;
return _h;
});
temp_surface = [ 0, 0, 0 ];
blend_temp_surface = noone;
input_display_list = [
["File", true], 0,
["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.interpolate = 0;
attributes.oversample = 0;
edit_time = 0;
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);
outputs[| 0].setValue(surf);
surface_set_target(surf);
DRAW_CLEAR
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]);
}
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 _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"];
var _inSurf = cel.getSurface();
if(!is_surface(_inSurf))
continue;
surface_set_shader(temp_surface[_bg], sh_sample, true, BLEND.over);
draw_surface_blend_ext(temp_surface[!_bg], _inSurf, xx, yy);
surface_reset_shader();
var xx = cel.data[$ "X"];
var yy = cel.data[$ "Y"];
draw_surface_safe(_inSurf, xx, yy);
}
surface_reset_target();
_bg = !_bg;
}
surface_set_shader(surf);
DRAW_CLEAR
draw_surface_safe(temp_surface[!_bg]);
surface_reset_shader();
}
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;
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
var amo = getInputAmount();
@ -367,7 +367,7 @@ function Node_Composite(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
}
return layer_height;
}); #endregion
});
input_display_list = [
["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);
function deleteLayer(index) { #region
function deleteLayer(index) {
var idx = input_fix_len + index * data_length;
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);
doUpdate();
} #endregion
}
static createNewInput = function() {
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_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
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);
inputs[| 2].setVisible(_dim_type == COMPOSE_OUTPUT_SCALING.constant);
if(canvas_draw != noone && surface_selecting == noone && getInputAmount())
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];
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();
return [ _outSurf, _atlas, [ww, hh] ];
} #endregion
}
static attributeSerialize = function() { #region
static attributeSerialize = function() {
var att = {};
att.layer_visible = attributes.layer_visible;
att.layer_selectable = attributes.layer_selectable;
return att;
} #endregion
}
static attributeDeserialize = function(attr) { #region
static attributeDeserialize = function(attr) {
struct_append(attributes, attr);
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"))
attributes.layer_selectable = attr.layer_selectable;
} #endregion
}
}