ImageTextureLayered
Hereda: TextureLayered < Texture < Resource < RefCounted < Object
Heredado por: Cubemap, CubemapArray, Texture2DArray
Clase base para los tipos de textura que contienen los datos de múltiples ImageTextures. Cada imagen es del mismo tamaño y formato.
Descripción
Clase base para Texture2DArray, Cubemap y CubemapArray. No se puede usar directamente, pero contiene todas las funciones necesarias para acceder a los tipos de recursos derivados. Véase también Texture3D.
Métodos
create_from_images(images: Array[Image]) |
|
void |
update_layer(image: Image, layer: int) |
Descripciones de Métodos
Error create_from_images(images: Array[Image]) 🔗
Creates an ImageTextureLayered from an array of Images. See Image.create() for the expected data format. The first image decides the width, height, image format and mipmapping setting. The other images must have the same width, height, image format and mipmapping setting.
Each Image represents one layer.
# Fill in an array of Images with different colors.
var images = []
const LAYERS = 6
for i in LAYERS:
var image = Image.create_empty(128, 128, false, Image.FORMAT_RGB8)
if i % 3 == 0:
image.fill(Color.RED)
elif i % 3 == 1:
image.fill(Color.GREEN)
else:
image.fill(Color.BLUE)
images.push_back(image)
# Create and save a 2D texture array. The array of images must have at least 1 Image.
var texture_2d_array = Texture2DArray.new()
texture_2d_array.create_from_images(images)
ResourceSaver.save(texture_2d_array, "res://texture_2d_array.res", ResourceSaver.FLAG_COMPRESS)
# Create and save a cubemap. The array of images must have exactly 6 Images.
# The cubemap's images are specified in this order: X+, X-, Y+, Y-, Z+, Z-
# (in Godot's coordinate system, so Y+ is "up" and Z- is "forward").
var cubemap = Cubemap.new()
cubemap.create_from_images(images)
ResourceSaver.save(cubemap, "res://cubemap.res", ResourceSaver.FLAG_COMPRESS)
# Create and save a cubemap array. The array of images must have a multiple of 6 Images.
# Each cubemap's images are specified in this order: X+, X-, Y+, Y-, Z+, Z-
# (in Godot's coordinate system, so Y+ is "up" and Z- is "forward").
var cubemap_array = CubemapArray.new()
cubemap_array.create_from_images(images)
ResourceSaver.save(cubemap_array, "res://cubemap_array.res", ResourceSaver.FLAG_COMPRESS)
void update_layer(image: Image, layer: int) 🔗
Reemplaza los datos existentes de Image en la layer dada con esta nueva imagen.
La Image dada debe tener la misma anchura, altura, formato de imagen y marca de mipmapping que el resto de las imágenes referenciadas.
Si el formato de imagen no es compatible, se descomprimirá y convertirá a un Format similar y compatible.
La actualización es inmediata: está sincronizada con el dibujo.