Class PortableCompressedTexture2D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class PortableCompressedTexture2D : Texture2D, IDisposable
- Inheritance
-
PortableCompressedTexture2D
- Implements
- Inherited Members
Constructors
PortableCompressedTexture2D()
public PortableCompressedTexture2D()
Properties
KeepCompressedBuffer
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.
public bool KeepCompressedBuffer { get; set; }
Property Value
SizeOverride
Allow overriding the texture size (for 2D only).
public Vector2 SizeOverride { get; set; }
Property Value
_Data
public byte[] _Data { get; set; }
Property Value
- byte[]
Methods
CreateFromImage(Image, CompressionMode, bool, float)
Initializes the compressed texture from a base image. The compression mode must be provided.
normalMap
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.
public void CreateFromImage(Image image, PortableCompressedTexture2D.CompressionMode compressionMode, bool normalMap = false, float lossyQuality = 0.8)
Parameters
image
ImagecompressionMode
PortableCompressedTexture2D.CompressionModenormalMap
boollossyQuality
float
GetCompressionMode()
Return the compression mode used (valid after initialized).
public PortableCompressedTexture2D.CompressionMode GetCompressionMode()
Returns
GetFormat()
Return the image format used (valid after initialized).
public Image.Format GetFormat()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsKeepingAllCompressedBuffers()
Return whether the flag is overridden for all textures of this type.
public static bool IsKeepingAllCompressedBuffers()
Returns
SetKeepAllCompressedBuffers(bool)
Overrides the flag globally for all textures of this type. This is used primarily by the editor.
public static void SetKeepAllCompressedBuffers(bool keep)
Parameters
keep
bool