Table of Contents

Class PortableCompressedTexture2D

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

Inheritance
PortableCompressedTexture2D

Remarks

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.

Properties

keep_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.

var keep_compressed_buffer : bool = false

Property Value

bool

Remarks

  • void set_keep_compressed_buffer(bool value)
  • bool is_keeping_compressed_buffer

size_override

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

var size_override : Vector2 = Vector2(0, 0)

Property Value

Vector2

Remarks

Methods

create_from_image(Image, int, bool, float)

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.

void create_from_image(Image image, int compression_mode, bool normal_map, float lossy_quality)

Parameters

image Image
compression_mode int
normal_map bool
lossy_quality float

get_compression_mode

Qualifiers: const

Return the compression mode used (valid after initialized).

int get_compression_mode

get_format

Qualifiers: const

Return the image format used (valid after initialized).

int get_format

is_keeping_all_compressed_buffers

Qualifiers: static

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

bool is_keeping_all_compressed_buffers

set_keep_all_compressed_buffers(bool)

Qualifiers: static

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

void set_keep_all_compressed_buffers(bool keep)

Parameters

keep bool