reckfellENGINE

PortableCompressedTexture2D

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

On this page
class PortableCompressedTexture2DReckfellSharpInherits Texture2D

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.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

PortableCompressedTexture2DConstructor
# PortableCompressedTexture2D
C#
public PortableCompressedTexture2D();

Properties3

KeepCompressedBufferProperty
# KeepCompressedBuffer
C#
public bool KeepCompressedBuffer { get; set; }

If true, when running in the editor, this texture will keep the source-compressed data in memory, allowing the data to persist after loading. Otherwise, the source-compressed data is lost after loading and the texture can't be re-saved. Note: This property must be set before PortableCompressedTexture2D.CreateFromImage for this to work.

SizeOverrideProperty
# SizeOverride
C#
public Vector2 SizeOverride { get; set; }

Allows overriding the texture's size (for 2D only).

_DataProperty
# _Data
C#
public byte[] _Data { get; set; }

Methods9

CreateFromImagevoid
# CreateFromImage
C#
public void CreateFromImage(Image image, PortableCompressedTexture2D.CompressionMode compressionMode, bool normalMap = false, float lossyQuality = 0.8f);

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.

Parameters
NameTypeDefault
imageImage—
compressionModePortableCompressedTexture2D.CompressionMode—
normalMapboolfalse
lossyQualityfloat0.8f
GetCompressionModePortableCompressedTexture2D.CompressionMode
# GetCompressionMode
C#
public PortableCompressedTexture2D.CompressionMode GetCompressionMode();

Return the compression mode used (valid after initialized).

Returns PortableCompressedTexture2D.CompressionMode
GetSizeOverrideVector2
# GetSizeOverride
C#
public Vector2 GetSizeOverride();
Returns Vector2
IsKeepingAllCompressedBuffersbool
# IsKeepingAllCompressedBuffers
C#
public static bool IsKeepingAllCompressedBuffers();

Returns true if the flag is overridden for all textures of this type.

Returns bool
IsKeepingCompressedBufferbool
# IsKeepingCompressedBuffer
C#
public bool IsKeepingCompressedBuffer();
Returns bool
SetBasisuCompressorParamsvoid
# SetBasisuCompressorParams
C#
public void SetBasisuCompressorParams(int uastcLevel, float rdoQualityLoss);

Sets the compressor parameters for Basis Universal compression. See also the settings in ResourceImporterTexture. Note: This method must be called before PortableCompressedTexture2D.CreateFromImage for this to work.

Parameters
NameTypeDefault
uastcLevelint—
rdoQualityLossfloat—
SetKeepAllCompressedBuffersvoid
# SetKeepAllCompressedBuffers
C#
public static void SetKeepAllCompressedBuffers(bool keep);

If keep is true, overrides the flag globally for all textures of this type. This is used primarily by the editor.

Parameters
NameTypeDefault
keepbool—
SetKeepCompressedBuffervoid
# SetKeepCompressedBuffer
C#
public void SetKeepCompressedBuffer(bool keep);
Parameters
NameTypeDefault
keepbool—
SetSizeOverridevoid
# SetSizeOverride
C#
public void SetSizeOverride(Vector2 size);
Parameters
NameTypeDefault
sizeVector2—

PortableCompressedTexture2D.CompressionMode

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.