1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Use the blend layers shader to blend the children of group layers

This commit is contained in:
Emmanouil Papadeas 2024-08-11 00:51:31 +03:00
parent bdc1b5af11
commit 363c764fc1

View file

@ -14,15 +14,37 @@ func _init(_project: Project, _name := "") -> void:
func blend_children(frame: Frame, origin := Vector2i.ZERO) -> Image: func blend_children(frame: Frame, origin := Vector2i.ZERO) -> Image:
var image := Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8) var image := Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
var children := get_children(false) var children := get_children(false)
if children.size() <= 0:
return image
var blend_rect := Rect2i(Vector2i.ZERO, project.size) var blend_rect := Rect2i(Vector2i.ZERO, project.size)
for layer in children: var textures: Array[Image] = []
var metadata_image := Image.create(children.size(), 4, false, Image.FORMAT_R8)
for i in children.size():
var layer := children[i]
if not layer.is_visible_in_hierarchy(): if not layer.is_visible_in_hierarchy():
continue continue
if layer is GroupLayer: if layer is GroupLayer:
image.blend_rect(layer.blend_children(frame, origin), blend_rect, origin) var blended_children: Image = layer.blend_children(frame, origin)
if DisplayServer.get_name() == "headless":
image.blend_rect(blended_children, blend_rect, origin)
else:
textures.append(blended_children)
else: else:
var cel := frame.cels[layer.index] var cel := frame.cels[layer.index]
DrawingAlgos.blend_layers_headless(image, project, layer, cel, origin) if DisplayServer.get_name() == "headless":
DrawingAlgos.blend_layers_headless(image, project, layer, cel, origin)
else:
textures.append(display_effects(cel))
DrawingAlgos.set_layer_metadata_image(layer, cel, metadata_image, i)
if DisplayServer.get_name() != "headless":
var texture_array := Texture2DArray.new()
texture_array.create_from_images(textures)
var params := {
"layers": texture_array, "metadata": ImageTexture.create_from_image(metadata_image)
}
var gen := ShaderImageEffect.new()
gen.generate_image(image, DrawingAlgos.blend_layers_shader, params, project.size)
return image return image