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 🔗
When running on the editor, this class will keep the source compressed data in memory. Otherwise, the source compressed data is lost after loading and the resource can't be re saved.
This flag allows to keep the compressed data in memory if you intend it to persist after loading.
Note: This must be set before create_from_image() to take effect.
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) 🔗
Sets the compressor parameters for Basis Universal compression. See also the settings in ResourceImporterTexture.
Note: This must be set before create_from_image() to take effect.
void set_keep_all_compressed_buffers(keep: bool) static 🔗
為該型別的所有紋理全域覆蓋該旗標。主要由編輯器使用。