Texture compression for real time XR explained
Texture compression reduces memory usage and bandwidth without CPU decompression overhead. Unlike mesh compression, texture compression happens on the GPU. Compressed textures remain compressed in VRAM and decompress on-the-fly during sampling. This reduces memory footprint by 75-90% with minimal quality loss.
Uncompressed textures consume 4 bytes per pixel for RGBA8. A 2048x2048 texture requires 16MB. A scene with 10 such textures uses 160MB of VRAM. Mobile GPUs have 2-4GB total memory shared with system RAM. Texture memory directly competes with framebuffer and geometry buffers. Compression is essential for mobile XR.
GPU texture compression formats are platform-specific. Desktop GPUs support BC7 (DirectX) and BC6H (HDR). Mobile GPUs support ASTC and ETC2. iOS devices support PVRTC. WebGL requires fallback to uncompressed textures if the platform does not support the compressed format. GLB files can embed multiple texture formats and select at runtime.
ASTC is the preferred format for mobile XR. It supports variable block sizes from 4x4 to 12x12 pixels. Smaller blocks preserve more detail but compress less. 6x6 blocks achieve 5.3:1 compression with good quality. 8x8 blocks achieve 8:1 compression with acceptable quality for normal maps. ASTC supports both LDR and HDR textures.
ETC2 is the fallback for older mobile devices. It achieves 4:1 compression for RGB and 8:1 for RGBA. Quality is lower than ASTC but compatible with all OpenGL ES 3.0 devices. Use ETC2 for base color textures on devices that do not support ASTC. Avoid ETC2 for normal maps due to visible artifacts.
BC7 is optimal for desktop VR. It achieves 4:1 compression for RGBA with better quality than ASTC. BC7 uses mode-based compression with per-block optimization. It handles gradients and sharp edges better than ASTC. Use BC7 for all textures on Windows-based VR headsets.
Texture compression introduces artifacts. Block compression averages colors within each block. This causes banding in gradients and blurring of fine details. Normal maps suffer from quantization of XY components. Metallic and roughness maps lose precision in smooth transitions. The impact depends on block size and content.
Quality settings trade file size for visual fidelity. ASTC 4x4 produces near-lossless results but compresses only 4:1. ASTC 8x8 compresses 8:1 but shows visible artifacts in detailed textures. For XR, use 6x6 for base color, 8x8 for normal maps, and 8x8 for metallic/roughness. This balances quality and memory usage.
Texture resolution matters more than compression quality. A 1024x1024 texture with ASTC 8x8 looks better than a 2048x2048 texture with ASTC 4x4 while using less memory. Resize textures before compressing. For mobile AR, use 1024x1024 for base color and 512x512 for normal maps. Compression quality is secondary to resolution.
Normal maps require special handling. Standard ASTC compression treats normal maps as color data. This introduces errors in the Z component reconstruction. Use ASTC normal map mode or store only XY components and reconstruct Z in the shader. This improves quality without increasing memory usage.
Metallic and roughness maps compress well. These are single-channel or dual-channel textures with smooth gradients. Pack them into RGB channels of a single texture. Use ASTC 8x8 or BC7 for 8:1 compression. The visual impact is minimal because these maps modulate lighting rather than directly contribute color.
Basis Universal enables runtime transcoding. It is a compressed intermediate format that transcodes to platform-native formats (ASTC, ETC2, BC7) at load time. This allows a single texture file to work across all platforms. Transcoding adds CPU overhead but eliminates the need for multiple texture variants in the GLB file.
Compression happens offline during asset processing. Tools like OptimiXR compress resize textures and apply JPEG compression for base color. For GPU compression, use dedicated tools like compressonator or basis universal encoder. Integrate these into your build pipeline to automate texture compression.
Avoid common mistakes: do not compress textures multiple times (JPEG then ASTC introduces double artifacts), do not use the same compression settings for all texture types (base color tolerates more compression than normal maps), do not ignore platform compatibility (test on actual devices), do not compress UI textures (use uncompressed or lossless PNG for text and icons).
The workflow for texture compression: resize textures to target resolution, convert base color to JPEG at 80-90 quality, convert normal maps to PNG, pack metallic and roughness into a single texture, use basis universal for cross-platform deployment, test on target hardware. OptimiXR compress handles resizing and JPEG compression. For GPU compression, use external tools and reimport the compressed textures.
Memory budget for mobile XR: allocate 512MB-1GB for textures. A typical scene has 10-20 materials. Budget 20-50MB per material including all texture maps. Use ASTC 6x6 for base color (1024x1024 = 2.7MB), ASTC 8x8 for normal maps (512x512 = 0.5MB), and ASTC 8x8 for packed metallic/roughness (512x512 = 0.5MB). Total per material: 3.7MB. This allows 15-20 materials within budget.
Texture compression is non-negotiable for mobile XR. It reduces memory usage by 75-90% with acceptable quality loss. Use ASTC for mobile, BC7 for desktop, and basis universal for cross-platform. Resize textures before compressing. Pack single-channel maps into RGB channels. Test on target hardware to validate quality. OptimiXR compress provides basic texture resizing. For advanced GPU compression, integrate dedicated tools into your pipeline.