Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

TextureLayered

继承: Texture < Resource < RefCounted < Object

派生: CompressedTextureLayered, ImageTextureLayered, PlaceholderTextureLayered, TextureLayeredRD

包含多个 Image 的纹理类型的基类。每个图像的大小和格式都是一样的。

描述

ImageTextureLayeredCompressedTextureLayered 的基类。不能直接使用,但包含了访问派生资源类型所需的所有函数。另见 Texture3D

数据是按层设置的。对于 Texture2DArray,层指定的是数组层。

所有图像都需要具有相同的宽度、高度和 mipmap 级别数。

TextureLayered 可以用 ResourceLoader.load 加载。

在内部,Godot 将这些文件映射到目标渲染驱动程序(Vulkan、OpenGL3)中的对应文件。

方法

Format

_get_format ( ) virtual const

int

_get_height ( ) virtual const

Image

_get_layer_data ( int layer_index ) virtual const

int

_get_layered_type ( ) virtual const

int

_get_layers ( ) virtual const

int

_get_width ( ) virtual const

bool

_has_mipmaps ( ) virtual const

Format

get_format ( ) const

int

get_height ( ) const

Image

get_layer_data ( int layer ) const

LayeredType

get_layered_type ( ) const

int

get_layers ( ) const

int

get_width ( ) const

bool

has_mipmaps ( ) const


枚举

enum LayeredType:

LayeredType LAYERED_TYPE_2D_ARRAY = 0

纹理为通用的 Texture2DArray

LayeredType LAYERED_TYPE_CUBEMAP = 1

纹理为 Cubemap,每一面都有自己的层(共 6 层)。

LayeredType LAYERED_TYPE_CUBEMAP_ARRAY = 2

纹理为 CubemapArray,每个立方体贴图都由 6 层组成。


方法说明

Format _get_format ( ) virtual const

查询该 TextureLayered 的格式时被调用。


int _get_height ( ) virtual const

查询该 TextureLayered 的高度时被调用。


Image _get_layer_data ( int layer_index ) virtual const

查询该 TextureLayered 中某一层的数据时被调用。


int _get_layered_type ( ) virtual const

查询该 TextureLayered 的层类型时被调用。


int _get_layers ( ) virtual const

查询该 TextureLayered 的层数时被调用。


int _get_width ( ) virtual const

查询该 TextureLayered 的宽度时被调用。


bool _has_mipmaps ( ) virtual const

查询该 TextureLayered 的 Mipmap 是否存在时被调用。


Format get_format ( ) const

返回纹理当前使用的格式。详情见 Format


int get_height ( ) const

返回该纹理的高度,单位为像素。高度通常由 Y 轴表示。


Image get_layer_data ( int layer ) const

返回带有指定 layer 层数据的 Image 图像资源。


LayeredType get_layered_type ( ) const

返回该 TextureLayered 的类型。类型决定了数据的访问方式,立方体图有特殊的类型。


int get_layers ( ) const

返回引用的 Image 数。


int get_width ( ) const

返回该纹理的宽度,单位为像素。宽度通常由 X 轴表示。


bool has_mipmaps ( ) const

如果层生成了 mipmap 则返回 true