Skip to content

Commit 71ab584

Browse files
authored
Texture profiles update (#516)
* Update texture profiles entry * Add small sidenote about astc support * Update note about device support
1 parent d237bc1 commit 71ab584

File tree

2 files changed

+105
-47
lines changed

2 files changed

+105
-47
lines changed
Loading

docs/en/manuals/texture-profiles.md

Lines changed: 105 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,54 @@ The processing of textures is configured through a specific texture profile. In
1717

1818
Since all available hardware texture compression is lossy, you will get artifacts in your texture data. These artifacts are highly dependent on how your source material looks and what compression method is used. You should test your source material and experiment to get the best results. Google is your friend here.
1919

20-
You can select what software image compression is applied on the final texture data (compressed or raw) in the bundle archives. Defold supports [Basis Universal](https://github.com/BinomialLLC/basis_universal) texture compression, which compresses the image into a intermediary format. This format is transcoded at runtime to a hardware format appropriate for the current device's GPU.
21-
The Basis Universal format is a high quality but lossy format.
22-
All images are also compressed using LZ4 for further reduction of file size when we store them into the game archive.
20+
You can select what software image compression is applied on the final texture data (compressed or raw) in the bundle archives. Defold supports [Basis Universal](https://github.com/BinomialLLC/basis_universal) and [ASTC](https://www.khronos.org/opengl/wiki/ASTC_Texture_Compression) compression formats.
2321

2422
::: sidenote
2523
Compression is a resource intensive and time consuming operation that can cause _very_ long build times depending on the number of texture images to compress and also the chosen texture formats and type of software compression.
2624
:::
2725

26+
### Basis Universal
27+
28+
Basis Universal (or BasisU for short) compresses the image into a intermediary format that is transcoded at runtime to a hardware format appropriate for the current device's GPU. The Basis Universal format is a high quality but lossy format.
29+
All images are also compressed using LZ4 for further reduction of file size when stored in the game archive.
30+
31+
### ASTC
32+
33+
ASTC is a flexible and efficient texture compression format developed by ARM and standardized by the Khronos Group. It offers a wide range of block sizes and bit rates, allowing developers to balance image quality and memory usage effectively. ASTC supports various block sizes, from 4×4 to 12×12 texels, corresponding to bit rates ranging from 8 bits per texel down to 0.89 bits per texel. This flexibility enables fine-grained control over the trade-off between texture quality and storage requirements.
34+
35+
ASTC supports various block sizes, from 4×4 to 12×12 texels, corresponding to bit rates ranging from 8 bits per texel down to 0.89 bits per texel. This flexibility enables fine-grained control over the trade-off between texture quality and storage requirements. The following table shows the supported block sizes and their corresponding bit rates:
36+
37+
| Block Size (width x height) | Bits per pixel |
38+
| --------------------------- | -------------- |
39+
| 4x4 | 8.00 |
40+
| 5x4 | 6.40 |
41+
| 5x5 | 5.12 |
42+
| 6x5 | 4.27 |
43+
| 6x6 | 3.56 |
44+
| 8x5 | 3.20 |
45+
| 8x6 | 2.67 |
46+
| 10x5 | 2.56 |
47+
| 10x6 | 2.13 |
48+
| 8x8 | 2.00 |
49+
| 10x8 | 1.60 |
50+
| 10x10 | 1.28 |
51+
| 12x10 | 1.07 |
52+
| 12x12 | 0.89 |
53+
54+
55+
#### Supported devices
56+
57+
While ASTC provides great results, it is not supported by all graphics cards. Here is a small list of supported devices based on vendor:
58+
59+
| GPU vendor | Support |
60+
| ------------------ | --------------------------------------------------------------------- |
61+
| ARM (Mali) | All ARM Mali GPUs that support OpenGL ES 3.2 or Vulkan support ASTC. |
62+
| Qualcomm (Adreno) | Adreno GPUs supporting OpenGL ES 3.2 or Vulkan support ASTC. |
63+
| Apple | Apple GPUs since the A8 chip support ASTC. |
64+
| NVIDIA | ASTC support is mostly for mobile GPUs (e.g., Tegra-based chips). |
65+
| AMD (Radeon) | AMD GPUs that support Vulkan generally support ASTC via software. |
66+
| Intel (Integrated) | ASTC is supported in modern Intel GPUs via software. |
67+
2868
## Texture profiles
2969

3070
Each project contains a specific *.texture_profiles* file that contains the configuration used when compressing textures. By default, this file is *builtins/graphics/default.texture_profiles* and it has a configuration matching every texture resource to a profile using RGBA with no hardware texture compression and using the default ZLib file compression.
@@ -101,22 +141,21 @@ The *Formats* added to a profile each have the following properties:
101141
*Format*
102142
: The format to use when encoding the texture. See below for all available texture formats.
103143

104-
*Compression*
105-
: Selects the quality level for the resulting compressed image.
144+
*Compressor*
145+
: The compressor to use when encoding the texture.
106146

107-
| LEVEL | Note |
108-
| -------- | --------------------------------------------- |
109-
| `FAST` | Fastest compression. Low image quality |
110-
| `NORMAL` | Default compression. Best image quality |
111-
| `HIGH` | Slowest compression. Smaller file size |
112-
| `BEST` | Slow compression. Smallest file size |
147+
*Compressor Preset*
148+
: Selects a compression preset to use for encoding the resulting compressed image. Each compressor preset is unique to the compressor and its settings depend on the compressor itself. To simplify these settings, the current compression presets come in four levels:
113149

114-
::: sidenote
115-
Since 1.2.185 we've redefined these enums, since they are a bit ambiguous.
116-
:::
150+
| Preset | Note |
151+
| --------- | --------------------------------------------- |
152+
| `LOW` | Fastest compression. Low image quality |
153+
| `MEDIUM` | Default compression. Best image quality |
154+
| `HIGH` | Slowest compression. Smaller file size |
155+
| `HIGHEST` | Slow compression. Smallest file size |
117156

118-
*Type*
119-
: Selects the type of compression used for the resulting compressed image, `COMPRESSION_TYPE_DEFAULT` or `COMPRESSION_TYPE_BASIS_UASTC`. See [Compression Types](#compression-types) below for more details.
157+
Note that the `uncompressed` compressor only has one preset called `uncompressed`, which means no compression will be applied to the textures.
158+
To see the list of available compressors, see [Compressors](#compressors)
120159

121160
## Texture formats
122161

@@ -138,21 +177,40 @@ The following lossy compression formats are currently supported:
138177
| `TEXTURE_FORMAT_LUMINANCE` | none | 1 channel gray-scale, no alpha. RGB channels multiplied into one. Alpha is discarded. |
139178
| `TEXTURE_FORMAT_LUMINANCE_ALPHA` | none | 1 channel gray-scale and full alpha. RGB channels multiplied into one. |
140179

180+
For ASTC, the number of channels will always be 4 (RGB + alpha), and the format itself defines the size of the block compression.
181+
Note that these formats are only compatible with an ASTC compressor - any other combination will produce a build error.
141182

142-
## Compression types
183+
`TEXTURE_FORMAT_RGBA_ASTC_4X4`
184+
`TEXTURE_FORMAT_RGBA_ASTC_5X4`
185+
`TEXTURE_FORMAT_RGBA_ASTC_5X5`
186+
`TEXTURE_FORMAT_RGBA_ASTC_6X5`
187+
`TEXTURE_FORMAT_RGBA_ASTC_6X6`
188+
`TEXTURE_FORMAT_RGBA_ASTC_8X5`
189+
`TEXTURE_FORMAT_RGBA_ASTC_8X6`
190+
`TEXTURE_FORMAT_RGBA_ASTC_8X8`
191+
`TEXTURE_FORMAT_RGBA_ASTC_10X5`
192+
`TEXTURE_FORMAT_RGBA_ASTC_10X6`
193+
`TEXTURE_FORMAT_RGBA_ASTC_10X8`
194+
`TEXTURE_FORMAT_RGBA_ASTC_10X10`
195+
`TEXTURE_FORMAT_RGBA_ASTC_12X10`
196+
`TEXTURE_FORMAT_RGBA_ASTC_12X12`
143197

144-
The following software image compression types are supported. The data is uncompressed when the texture file is loaded into memory.
198+
199+
## Compressors
200+
201+
The following texture compressors are supported by default. The data is uncompressed when the texture file is loaded into memory.
202+
203+
| Name | Formats | Note |
204+
| --------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------- |
205+
| `Uncompressed` | All formats | No compression will be applied. Default. |
206+
| `BasisU` | All RGB/RGBA formats | Basis Universal high quality, lossy compression. Lower quality level results in smaller size. |
207+
| `ASTC` | All ASTC formats | ASTC lossy compression. Lower quality level results in smaller size. |
145208

146209
::: sidenote
147-
We are currently looking into how to reintroduce support for hardware formats, as well as reading support for WEBP compression.
148-
Our current long running task of introducing content pipeline plugins aim to fix this.
210+
Defold 1.9.7 refactored the texture compressor pipeline to support installable compressors, which is the first step in
211+
enabling implementing a texture compression algorithm in an extension (such as WEBP, or something completely custom).
149212
:::
150213

151-
| Type | Formats | Note |
152-
| --------------------------------- | ------------------------- | ---- |
153-
| `COMPRESSION_TYPE_DEFAULT` | All formats | Generic lossless data compression. Default. |
154-
| `COMPRESSION_TYPE_BASIS_UASTC` | All RGB/RGBA formats | Basis Universal high quality, lossy compression. Lower quality level results in smaller size. |
155-
156214
## Example image
157215

158216
To better give an understanding of the output, here is an example.
@@ -163,51 +221,51 @@ Base image (1024x512):
163221

164222
### Compression times
165223

166-
| Level | Compression time | Relative time |
224+
| Preset | Compression time | Relative time |
167225
| ----------------------------- | --------------- |
168-
| `FAST` | 0m0.143s | 0.5x |
169-
| `NORMAL` | 0m0.294s | 1.0x |
170-
| `HIGH` | 0m1.764s | 6.0x |
171-
| `BEST` | 0m1.109s | 3.8x |
226+
| `LOW` | 0m0.143s | 0.5x |
227+
| `MEDIUM` | 0m0.294s | 1.0x |
228+
| `HIGH` | 0m1.764s | 6.0x |
229+
| `HIGHEST` | 0m1.109s | 3.8x |
172230

173231
### Signal loss
174232

175233
The comparison is done using the `basisu` tool (measuring the PSNR)
176234
100 dB means no signal loss (i.e. it's the same as the original image).
177235

178-
| Level | Signal |
236+
| Preset | Signal |
179237
| ------------------------------------------------------------ |
180-
| `FAST` | Max: 34 Mean: 0.470 RMS: 1.088 PSNR: 47.399 dB |
181-
| `NORMAL` | Max: 35 Mean: 0.439 RMS: 1.061 PSNR: 47.620 dB |
182-
| `HIGH` | Max: 37 Mean: 0.898 RMS: 1.606 PSNR: 44.018 dB |
183-
| `BEST` | Max: 51 Mean: 1.298 RMS: 2.478 PSNR: 40.249 dB |
238+
| `LOW` | Max: 34 Mean: 0.470 RMS: 1.088 PSNR: 47.399 dB |
239+
| `MEDIUM` | Max: 35 Mean: 0.439 RMS: 1.061 PSNR: 47.620 dB |
240+
| `HIGH` | Max: 37 Mean: 0.898 RMS: 1.606 PSNR: 44.018 dB |
241+
| `HIGHEST` | Max: 51 Mean: 1.298 RMS: 2.478 PSNR: 40.249 dB |
184242

185243
### Compression file sizes
186244

187245
Original file size is 1572882 bytes.
188246

189-
| Level | File Sizes | Ratio |
247+
| Preset | File Sizes | Ratio |
190248
| ---------------------------------- |
191-
| `FAST` | 357225 | 22.71 % |
192-
| `NORMAL` | 365548 | 23.24 % |
193-
| `HIGH` | 277186 | 17.62 % |
194-
| `BEST` | 254380 | 16.17 % |
249+
| `LOW` | 357225 | 22.71 % |
250+
| `MEDIUM` | 365548 | 23.24 % |
251+
| `HIGH` | 277186 | 17.62 % |
252+
| `HIGHEST` | 254380 | 16.17 % |
195253

196254

197255
### Image quality
198256

199257
Here are the resulting images (retrieved from the ASTC encoding using the `basisu` tool)
200258

201-
`FAST`
202-
![fast compression level](images/texture_profiles/kodim03_pow2.fast.png)
259+
`LOW`
260+
![low compression preset](images/texture_profiles/kodim03_pow2.fast.png)
203261

204-
`NORMAL`
205-
![normal compression level](images/texture_profiles/kodim03_pow2.normal.png)
262+
`MEDIUM`
263+
![medium compression preset](images/texture_profiles/kodim03_pow2.normal.png)
206264

207265
`HIGH`
208-
![high compression level](images/texture_profiles/kodim03_pow2.high.png)
266+
![high compression preset](images/texture_profiles/kodim03_pow2.high.png)
209267

210-
`BEST`
211-
![best compression level](images/texture_profiles/kodim03_pow2.best.png)
268+
`HIGHEST`
269+
![best compression preset](images/texture_profiles/kodim03_pow2.best.png)
212270

213271

0 commit comments

Comments
 (0)