Vizard 7 » Reference » Appearance & Texturing » Texture compression
7.6

Texture Compression

All typical images become uncompressed when used by a graphics card. If they're stored as JPG or another compressed format, the file size on disk will be smaller, but once it's loaded it will have the same overhead as an uncompressed format. Graphics cards support a few specialized compression formats that can reduce texture memory significantly, but the compression formats are all lossy and can introduce artifacts.

 

The recommended workflow for compressing textures for the GPU is through Vizard's Inspector tool. Inspector supports compressing textures using the supercompressed Basis Universal format or the DXT format. The Basis Universal compression format supports two modes; High Quality and High Compression. The High Quality mode uses BC7 compression and is the recommended mode in most cases. The High Compression mode uses DXT compression, which will have more compression artifacts but will compress down to a lower size on disk.

Note: BC7 compression is an RGBA format, so compressing an RGB texture to Basis Universal (High Quality) will automatically add an alpha channel to the texture.

To use texture compression, the resolution of your texture maps must be divisible by 4. Using texture compression will lead to a 4:1 compression ratio for most textures, and a 6:1 ratio for RGB images when using Basis Universal (High Compression) or DXT. Since GPU texture compression is lossy, it will introduce some compression artifacts. For this reason, GPU texture compression is only recommended for resource intensive scenes, where uncompressed images could affect performance.

Compression Format

Compression Ratio

Alpha

DXT1

6:1

No alpha/1-bit alpha

DXT3

4:1

Sharp alpha

DXT5

4:1

Gradient alpha

BC7 4:1 Gradient alpha

In addition to compressing textures through Inspector, DXT compression can be applied to images through the OSG exporter, in the Vizard script, or with certain file formats (e.g. DDS). The following code shows how to apply DXT compression through the Vizard script:

viz.setOption('viz.hint', viz.COMPRESS_TEXTURE_HINT)

Decreasing texture load times

There are several stages associated with loading textures. The first is loading the data from the hard disk. The second is decompressing the loaded data. The third is uploading the data to the graphics driver. This can result in significant load times for models with heavy textures. Since DXT is not only compressed data but when stored as DXT format in your file, the data can be uploaded from disk directly to graphics card without any intervening processing. This can decrease load time by more than an order of magnitude.

The Image above is without DXT_1 compression (200% zoom)
 
The image above is with DXT_1 compression (200% zoom)
 

Freeing host memory

By default, Vizard keeps loaded textures in the program memory space in addition to loading the texture data into the graphics card driver. For small applications, this is the simplest and most flexible default behavior. For large applications, the cost of keeping textures in program memory space can be as much as a 400% waste of memory.

 

To reduce this memory waste, instruct Vizard to free texture memory after the data has been uploaded to the graphics card. Freeing texture memory releases valuable host memory resources for other assets. It also makes available memory for the graphics load to swap back into system memory should more texture memory be allocated that is physically present on your graphics card. Freeing memory is done by applying a hint as follows:

viz.setOption('viz.hint', viz.FREE_TEXTURE_MEMORY_HINT)

Once texture memory has been freed, it is no longer possible to build/destroy mipmaps or issue a texture compression command.