PortableCompressedTexture2D

继承: Texture2D < Texture < Resource < RefCounted < Object

Provides a compressed texture for disk and/or VRAM in a way that is portable.

描述

This class allows storing compressed textures as self contained (not imported) resources.

For 2D usage (compressed on disk, uncompressed on VRAM), the lossy and lossless modes are recommended. For 3D usage (compressed on VRAM) it depends on the target platform.

If you intend to only use desktop, S3TC or BPTC are recommended. For only mobile, ETC2 is recommended.

For portable, self contained 3D textures that work on both desktop and mobile, Basis Universal is recommended (although it has a small quality cost and longer compression time as a tradeoff).

This resource is intended to be created from code.

属性

方法

voidcreate_from_image ( image: Image, compression_mode: CompressionMode, normal_map: bool = false, lossy_quality: float = 0.8 )
CompressionModeget_compression_mode ( ) const1
Formatget_format ( ) const1
boolis_keeping_all_compressed_buffers ( ) static2
voidset_keep_all_compressed_buffers ( keep: bool ) static2

枚举

enum CompressionMode:

CompressionMode COMPRESSION_MODE_LOSSLESS = 0

该枚举目前没有描述,请帮我们\ :ref:贡献一个 <doc_updating_the_class_reference>\ 吧!

CompressionMode COMPRESSION_MODE_LOSSY = 1

该枚举目前没有描述,请帮我们\ :ref:贡献一个 <doc_updating_the_class_reference>\ 吧!

CompressionMode COMPRESSION_MODE_BASIS_UNIVERSAL = 2

该枚举目前没有描述,请帮我们\ :ref:贡献一个 <doc_updating_the_class_reference>\ 吧!

CompressionMode COMPRESSION_MODE_S3TC = 3

该枚举目前没有描述,请帮我们\ :ref:贡献一个 <doc_updating_the_class_reference>\ 吧!

CompressionMode COMPRESSION_MODE_ETC2 = 4

该枚举目前没有描述,请帮我们\ :ref:贡献一个 <doc_updating_the_class_reference>\ 吧!

CompressionMode COMPRESSION_MODE_BPTC = 5

该枚举目前没有描述,请帮我们\ :ref:贡献一个 <doc_updating_the_class_reference>\ 吧!


属性说明

bool keep_compressed_buffer = false

  • void set_keep_compressed_buffer ( value: bool )
  • bool is_keeping_compressed_buffer ( )

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.


Vector2 size_override = Vector2(0, 0)

  • void set_size_override ( value: Vector2 )
  • Vector2 get_size_override ( )

Allow overriding the texture size (for 2D only).


方法说明

void create_from_image ( image: Image, compression_mode: CompressionMode, normal_map: bool = false, lossy_quality: float = 0.8 )

Initializes the compressed texture from a base image. The compression mode must be provided.

normal_map is recommended to ensure optimum quality if this image will be used as a normal map.

If lossy compression is requested, the quality setting can optionally be provided. This maps to Lossy WebP compression quality.


CompressionMode get_compression_mode ( ) const1

Return the compression mode used (valid after initialized).


Format get_format ( ) const1

Return the image format used (valid after initialized).


bool is_keeping_all_compressed_buffers ( ) static2

Return whether the flag is overridden for all textures of this type.


void set_keep_all_compressed_buffers ( keep: bool ) static2

Overrides the flag globally for all textures of this type. This is used primarily by the editor.

3

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

4

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

5

本方法用于构造某个类型。

2

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。