In Verge3D, textures may be compressed using the highly effective KTX2/BasisU compression algorithm, thus significantly reducing GPU memory consumption and improving rendering speed.
- Enabling Texture Compression
- Checking Your Files
- Tweaking Compression
- Special Case - HDR textures
Enabling Texture Compression
To enable texture compression automatically upon export, you can simply turn on the corresponding option in the export settings.
Checking Your Files
To ensure that your app now actually loads compressed texture, run your app (either from App Manager or from a website where it is deployed). Open the browser console and switch to the Network tab.
Reload your app so that the console starts displaying files from the beginning. Find the texture files in the list - if everything is ok, they should end with .ktx2.
Alternatively, you can check whether the compressed textures are enabled by using the performance profile feature.
There is an option available for each texture to tweak the compression algorithm:
- Choose best algorithm automatically. Corresponds to using UASTC in the current implementation.
- modern method which offers best quality. It is good for everything including normal maps, ORM textures, etc.
- offers best compression and generates smallest files. However, it may cripple textures so you might use it only for non-contrast images (such as grass, wood, bricks, etc).
- disable texture compression.
Special Case - HDR textures
Besides genuine texture compression, all HDR images are compressed with lossless LZMA (i.e. same method used for glTF files). This makes the HDR files 4x-6x times smaller, although they still occupy the same amount of video memory. This feature is turned off when you set the texture compression setting to Disabled.
In general, it's save to enable texture compression for all of your scenes, however you should be aware of some limitations and drawbacks introduced by this feature.
Compressing requires more data to load over network
As stated in the beginning of this section, texture compression significantly reduces GPU memory consumed by your apps. However, it is not always true for data transferred over network. When using UASTC compression algorithm (or Auto), the textures can get bigger in some cases. If network bandwidth is a priority, disable texture compression altogether or use the more efficient ETC1S algorithm.
Starting from Verge3D 4.2, we implemented a countermeasure to limit the size of compressed textures. Should the resulting image get more than 3x times larger than the original image, the exporter keeps the original uncompressed image intact.
Compression requires more time to compress your data during export. To save time, you can only enable it at final stages of development.
Supported only for JPEG and PNG textures
Only JPEG/PNG textures can be converted to KTX2. Textures in other formats (WebP, BMP, etc) are left uncompressed.
Not supported for non-power-of-two (NPOT) textures
If the exporter detects that you try to compress NPOT textures (which we don't recommend using in your apps anyway), it will fallback to regular non-compressed data and prints a warning in the console of your modelling tool.
Not supported for PNG textures with embedded ICC profile
PNG images with embedded color profile chunks (ICC aka iCCP) are not supported by the texture compressor. As such, to process such images we strip ICC data entirely before passing them to the compressor. In case of non-standard color profiles (non-sRGB) this might result in somewhat distorted colors.
If stripping ICC data is not desirable, disable texture compression for the said images or apply color profile using some image editing software (Photoshop, GIMP).
Not compatible with AR mode on iOS devices
Disable compression if you need to convert your models to USDZ to be shown in AR Quick Look mode on Apple devices. Alternatively, use two separate scenes for AR and non-AR modes or generate USDZ assets statically, e.g by using your modelling suite or model converter. See here for more info.
Feel free to ask on the forums!