PortableCompressedTexture2D
继承: Texture2D < Texture < Resource < RefCounted < Object
为磁盘和/或显存提供可移植的压缩纹理。
描述
这个类能够将压缩纹理存储为自包含的资源(与导入资源相对)。
用于 2D 时(在磁盘上压缩、在显存中不压缩)推荐使用有损和无损模式。用于 3D 时(在显存中压缩)则取决于目标平台。
如果你只想用于桌面平台,则推荐使用 S3TC 或 BPTC。如果只用于移动平台,则推荐使用 ETC2。
如果要实现可移植、自包含的 3D 纹理,让这种纹理能同时在桌面和移动平台使用,则推荐 Basis Universal(尽管代价是有较小的质量损耗和更长的压缩时间)。
这个资源应使用代码创建。
属性
|
||
resource_local_to_scene |
|
|
|
方法
void |
create_from_image(image: Image, compression_mode: CompressionMode, normal_map: bool = false, lossy_quality: float = 0.8) |
get_compression_mode() const |
|
get_format() const |
|
is_keeping_all_compressed_buffers() static |
|
void |
set_basisu_compressor_params(uastc_level: int, rdo_quality_loss: float) |
void |
set_keep_all_compressed_buffers(keep: bool) static |
枚举
enum CompressionMode: 🔗
CompressionMode COMPRESSION_MODE_LOSSLESS = 0
There is currently no description for this enum. Please help us by contributing one!
CompressionMode COMPRESSION_MODE_LOSSY = 1
There is currently no description for this enum. Please help us by contributing one!
CompressionMode COMPRESSION_MODE_BASIS_UNIVERSAL = 2
There is currently no description for this enum. Please help us by contributing one!
CompressionMode COMPRESSION_MODE_S3TC = 3
There is currently no description for this enum. Please help us by contributing one!
CompressionMode COMPRESSION_MODE_ETC2 = 4
There is currently no description for this enum. Please help us by contributing one!
CompressionMode COMPRESSION_MODE_BPTC = 5
There is currently no description for this enum. Please help us by contributing one!
CompressionMode COMPRESSION_MODE_ASTC = 6
There is currently no description for this enum. Please help us by contributing one!
属性说明
bool keep_compressed_buffer = false 🔗
在编辑器中运行时,这个类会将来源压缩数据保持在内存中。否则加载资源后来源压缩数据就会丢失,资源也无法重新保存。
如果你要在加载后再次进行持久化,这个标志能够让压缩数据保持在内存中。
注意:必须在 create_from_image() 之前设置才能生效。
Vector2 size_override = Vector2(0, 0) 🔗
允许覆盖纹理大小(仅限 2D)。
方法说明
void create_from_image(image: Image, compression_mode: CompressionMode, normal_map: bool = false, lossy_quality: float = 0.8) 🔗
使用基础图像初始化压缩纹理。必须提供压缩模式。
如果该图像会用作法线贴图,则推荐使用 normal_map,确保达到最佳质量。
如果请求了有损压缩,还可以提供质量设置。会映射至有损 WebP 压缩质量。
CompressionMode get_compression_mode() const 🔗
返回使用的压缩模式(初始化后有效)。
返回使用的图像格式(初始化后有效)。
bool is_keeping_all_compressed_buffers() static 🔗
返回是否为所有该类型的纹理覆盖该标志。
void set_basisu_compressor_params(uastc_level: int, rdo_quality_loss: float) 🔗
设置 Basis Universal 压缩的压缩器参数。另见 ResourceImporterTexture 中的设置。
注意:必须在 create_from_image() 前设置才会生效。
void set_keep_all_compressed_buffers(keep: bool) static 🔗
为该类型的所有纹理全局覆盖该标志。主要由编辑器使用。