PKM and ETC Format: Complete Guide
PKM is a simple container format for ETC-compressed textures, widely used on Android and OpenGL ES platforms. This article provides a complete guide to understanding PKM format structure, ETC/ETC2 compression versions, and how to use them effectively.
What is PKM Format?
PKM (short for 'PoKeMon', named by Ericsson) is a simple container format designed specifically for storing ETC-compressed texture data. Unlike complex formats like KTX or DDS, PKM has a minimal structure with just a 16-byte header followed by compressed image data.
The format was created to provide a lightweight way to store and load ETC-compressed textures on mobile devices. Its simplicity makes it easy to implement and parse, with virtually no overhead beyond the compressed texture data itself.
PKM File Structure
- 16-byte header: Magic number (PKM), version, format, dimensions
- Compressed texture data: Raw ETC/ETC2 blocks
ETC Compression Versions
There are two major versions of ETC compression, each with different capabilities:
ETC1 (Ericsson Texture Compression 1)
The original ETC standard, supporting only RGB color channels with 4:1 fixed compression ratio. Widely supported on Android devices since OpenGL ES 2.0.
Support: All OpenGL ES 2.0+ devices
Compression Ratio: 4:1 fixed (4 bits per pixel)
ETC2 (Ericsson Texture Compression 2)
Improved successor to ETC1, adding RGBA support with multiple format options. Provides better quality and alpha channel support while maintaining backward compatibility.
Support: OpenGL ES 3.0+, Vulkan
Compression Ratio: 4:1 to 8:1 depending on format
PKM Format Variants
PKM can contain different ETC format types:
ETC1 RGB
Original format, RGB only, no alpha channel
ETC2 RGB
Improved RGB compression with better quality than ETC1
ETC2 RGBA
Full RGBA support with 8:1 compression (8 bits per pixel)
ETC2 RGB + Punch-through Alpha
RGB with 1-bit alpha, maintaining 4:1 compression
Advantages of PKM/ETC
Universal Android Support
ETC1 is guaranteed to be supported on all Android devices, making it the most portable compression format for Android development.
Fixed Compression Ratio
Predictable memory usage with consistent 4:1 or 8:1 compression ratios, simplifying memory budget calculations.
Good Quality-to-Size Ratio
ETC2 provides excellent visual quality for most texture types, comparable to desktop formats like DXT/BCn.
Hardware Decoding
Direct GPU decompression with zero CPU overhead during rendering, enabling efficient texture sampling.
Limitations and Considerations
ETC1 Quality Limits
ETC1 can show visible artifacts on textures with high-frequency detail or smooth gradients. Consider using ETC2 for better quality.
No Alpha in ETC1
ETC1 doesn't support alpha channels. You need to use ETC2 RGBA or store alpha separately if targeting OpenGL ES 2.0 devices.
Limited Advanced Features
PKM doesn't support mipmaps, cubemaps, or texture arrays. Use KTX or KTX2 formats for these advanced features.
How to Use PKM Format
Using PKM files in your projects is straightforward:
Encoding to PKM
- Upload your PNG/JPG image (must have power-of-2 or multiple-of-4 dimensions)
- Choose between ETC1 RGB or ETC2 RGB/RGBA based on your needs
- Download the generated .pkm file and integrate it into your project
Decoding PKM Files
- Upload your .pkm file to verify its contents
- Preview the decompressed texture and check quality
- Export to PNG if you need to edit or inspect the texture
Best Practices
- Use ETC1 RGB for maximum compatibility across all Android devices (OpenGL ES 2.0+)
- Prefer ETC2 RGBA when targeting modern devices (OpenGL ES 3.0+) that need alpha channels
- Ensure texture dimensions are multiples of 4 (ETC1) or power-of-2 for best quality
- For textures requiring alpha on older devices, consider using separate grayscale textures
- Test compressed textures on actual target devices - quality perception varies by content type
Conclusion
PKM with ETC/ETC2 compression is the standard choice for Android and mobile OpenGL ES development. Its universal support, predictable performance, and good quality make it an excellent default for mobile texture compression.
Our online PKM encoder and decoder tools make it easy to work with ETC-compressed textures without installing command-line tools or SDKs. Whether you're creating new textures or inspecting existing ones, these tools help you optimize your mobile graphics pipeline.
Further Reading & References
Learn more about ETC and PKM formats:
- ETC Texture Compression (Khronos) - Official OpenGL ES specification and ETC format documentation
- Ericsson Texture Compression (Wikipedia) - History and technical details of ETC compression algorithms
- Android Graphics: Texture Compression - Android official guide to texture compression formats
- PKM File Format Specification - Technical specification for PKM container format