diff options
author | reduz <reduzio@gmail.com> | 2022-03-24 18:18:55 +0100 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-03-30 10:39:41 +0200 |
commit | 45f74ceb853a2986acbdb44f7b36b409b4e0cea5 (patch) | |
tree | 4390fbbe5abad6ec67bbc152fbc93dc4a3c7189c /doc | |
parent | f6ef63635f92c0a8c9c637c488f0ec129217fade (diff) |
Add PortableCompressedTexture
* Resource that allows saving textures embedded in scenes or standalone.
* Supports only formats that are portable: Lossy, Lossles or BasisUniversal
This is something I wanted to add for a long time. I made it now because @fire
requires it for importing GLTF2 files with embedded textures, but also this
will allow saving Godot scenes as standalone binary files that will run
in all platforms (because textures will load everywhere).
This is ideal when you want to distribute individual standalone assets online
in games that can be built from Godot scenes.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/Image.xml | 2 | ||||
-rw-r--r-- | doc/classes/PortableCompressedTexture2D.xml | 79 |
2 files changed, 80 insertions, 1 deletions
diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 35868563de..140015babf 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -153,7 +153,7 @@ Returns [constant ALPHA_BLEND] if the image has data for alpha values. Returns [constant ALPHA_BIT] if all the alpha values are stored in a single bit. Returns [constant ALPHA_NONE] if no data for alpha values is found. </description> </method> - <method name="detect_used_channels"> + <method name="detect_used_channels" qualifiers="const"> <return type="int" enum="Image.UsedChannels" /> <argument index="0" name="source" type="int" enum="Image.CompressSource" default="0" /> <description> diff --git a/doc/classes/PortableCompressedTexture2D.xml b/doc/classes/PortableCompressedTexture2D.xml new file mode 100644 index 0000000000..7b46a0bf07 --- /dev/null +++ b/doc/classes/PortableCompressedTexture2D.xml @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="PortableCompressedTexture2D" inherits="Texture2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> + <brief_description> + Provides a compressed texture for disk and/or VRAM in a way that is portable. + </brief_description> + <description> + 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. + </description> + <tutorials> + </tutorials> + <methods> + <method name="create_from_image"> + <return type="void" /> + <argument index="0" name="image" type="Image" /> + <argument index="1" name="compression_mode" type="int" enum="PortableCompressedTexture2D.CompressionMode" /> + <argument index="2" name="normal_map" type="bool" default="false" /> + <argument index="3" name="lossy_quality" type="float" default="0.8" /> + <description> + Initializes the compressed texture from a base image. The compression mode must be provided. + If this image will be used as a normal map, the "normal map" flag is recommended, to ensure optimum quality. + If lossy compression is requested, the quality setting can optionally be provided. This maps to Lossy WEBP compression quality. + </description> + </method> + <method name="get_compression_mode" qualifiers="const"> + <return type="int" enum="PortableCompressedTexture2D.CompressionMode" /> + <description> + Return the compression mode used (valid after initialized). + </description> + </method> + <method name="get_format" qualifiers="const"> + <return type="int" enum="Image.Format" /> + <description> + Return the image format used (valid after initialized). + </description> + </method> + <method name="is_keeping_all_compressed_buffers" qualifiers="static"> + <return type="bool" /> + <description> + Return whether the flag is overriden for all textures of this type. + </description> + </method> + <method name="set_keep_all_compressed_buffers" qualifiers="static"> + <return type="void" /> + <argument index="0" name="keep" type="bool" /> + <description> + Overrides the flag globally for all textures of this type. This is used primarly by the editor. + </description> + </method> + </methods> + <members> + <member name="_data" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray()"> + </member> + <member name="keep_compressed_buffer" type="bool" setter="set_keep_compressed_buffer" getter="is_keeping_compressed_buffer" default="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. + </member> + <member name="size_override" type="Vector2" setter="set_size_override" getter="get_size_override" default="Vector2(0, 0)"> + Allow overriding the texture size (for 2D only). + </member> + </members> + <constants> + <constant name="COMPRESSION_MODE_LOSSLESS" value="0" enum="CompressionMode"> + </constant> + <constant name="COMPRESSION_MODE_LOSSY" value="1" enum="CompressionMode"> + </constant> + <constant name="COMPRESSION_MODE_BASIS_UNIVERSAL" value="2" enum="CompressionMode"> + </constant> + <constant name="COMPRESSION_MODE_S3TC" value="3" enum="CompressionMode"> + </constant> + <constant name="COMPRESSION_MODE_ETC2" value="4" enum="CompressionMode"> + </constant> + <constant name="COMPRESSION_MODE_BPTC" value="5" enum="CompressionMode"> + </constant> + </constants> +</class> |