diff --git a/src/Classes/Layers/GroupLayer.gd b/src/Classes/Layers/GroupLayer.gd index 789965411..f6cb4f40f 100644 --- a/src/Classes/Layers/GroupLayer.gd +++ b/src/Classes/Layers/GroupLayer.gd @@ -14,15 +14,37 @@ func _init(_project: Project, _name := "") -> void: func blend_children(frame: Frame, origin := Vector2i.ZERO) -> Image: var image := Image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8) var children := get_children(false) + if children.size() <= 0: + return image 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(): continue 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: 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