Efficient Game Textures with Hardware Compression - th3starsite

Breaking

Home Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

الثلاثاء، 13 يناير 2015

Efficient Game Textures with Hardware Compression


Posted by Shanee
Nishry
, Developer Advocate




As you may know, high resolution textures contribute to better graphics and a
more impressive game experience. Adaptive Scalable Texture Compression (ASTC)
helps solve many of the challenges involved including reducing memory
footprint and loading time and even increase performance and battery life.




If you have a lot of textures, you are probably already compressing them.
Unfortunately, not all compression algorithms are made equal. PNG, JPG and
other common formats are not GPU friendly. Some of the highest-quality
algorithms today are proprietary and limited to certain GPUs. Until recently,
the only broadly supported GPU accelerated formats were relatively primitive
and produced poor results.




With the introduction of ASTC, a new compression technique invented by ARM
and standardized by the Khronos group, we expect to see dramatic changes for
the better. ASTC promises to be both high quality and broadly supported by
future Android devices. But until devices with ASTC support become widely
available, it’s important to understand the variety of legacy formats that
exist today.




We will examine preferable compression formats which are supported on the GPU
to help you reduce .apk size and loading times of your game.




Texture Compression




Popular compressed formats include PNG and JPG, which can’t be decoded
directly by the GPU. As a consequence, they need to be decompressed before
copying them to the GPU memory. Decompressing the textures takes time and
leads to increased loading times.




A better option is to use hardware accelerated formats. These formats are
lossy but have the advantage of being designed for the GPU.




This means they do not need to be decompressed before being copied and result
in decreased loading times for the player and may even lead to increased
performance due to hardware optimizations.




Hardware Accelerated Formats




Hardware accelerated formats have many benefits. As mentioned before, they
help improve loading times and the runtime memory footprint.




Additionally, these formats help improve performance, battery life and reduce
heating of the device, requiring less bandwidth while also consuming less
energy.




There are two categories of hardware accelerated formats, standard and
proprietary. This table shows the standard formats:



















ETC1

Supported on all Android devices with OpenGL ES 2.0 and above. Does not
support alpha channel.

ETC2

Requires OpenGL ES 3.0 and above.

ASTC

Higher quality than ETC1 and ETC2. Supported with the Android Extension
Pack.



As you can see, with higher OpenGL support you gain access to better formats.
There are proprietary formats to replace ETC1, delivering higher quality and
alpha channel support. These are shown in the following table:
























ATC

Available with Adreno GPU.

PVRTC

Available with a PowerVR GPU.

DXT1

S3 DXT1 texture compression. Supported on devices running Nvidia Tegra
platform.

S3TC

S3 texture compression, nonspecific to DXT variant. Supported on devices
running Nvidia Tegra platform.



That’s a lot of formats, revealing a different problem. How do you choose
which format to use?




To best support all devices you need to create multiple apks using different
texture formats. The Google Play developer console allows you to add multiple
apks and will deliver the right one to the user based on their device. For
more information check "http://developer.android.com/training/multiple-apks/texture.html?utm_campaign=ASTC-115&utm_source=dac&utm_medium=blog">
this page
.




When a device only supports OpenGL ES 2.0 it is recommended to use a
proprietary format to get the best results possible, this means making an apk
for each hardware.




On devices with access to OpenGL ES 3.0 you can use ETC2. The
GL_COMPRESSED_RGBA8_ETC2_EAC format is an improved version of ETC1
with added alpha support.




The best case is when the device supports the Android Extension Pack. Then
you should use the ASTC format which has better quality and is more efficient
than the other formats.




Adaptive Scalable Texture Compression (ASTC)




The Android Extension Pack has ASTC as a standard format, removing the need
to have different formats for different devices.




In addition to being supported on modern hardware, ASTC also offers improved
quality over other GPU formats by having full alpha support and better
quality preservation.




ASTC is a block based texture compression algorithm developed by "http://www.arm.com/">ARM. It offers multiple block footprints and
bitrate options to lower the size of the final texture. The higher the block
footprint, the smaller the final file but possibly more quality loss.




Note that some images compress better than others. Images with similar
neighboring pixels tend to have better quality compared to images with vastly
different neighboring pixels.




Let’s examine a texture to better understand ASTC:


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwg4M9H8Mg1GIXzXRL7QalzW4kRoflP1-pqnDpj3BmLNx1X8PIxIfVXGPGd4EPEqSnbwNpz55nShF682DPH5ou9rbxNTIgh8TKqFsylwkV7FqERHjypbeNyYTJ0nhvCLPNKLj7SKPEOtpu/s1600/jelly-original.png"
imageanchor="1">"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwg4M9H8Mg1GIXzXRL7QalzW4kRoflP1-pqnDpj3BmLNx1X8PIxIfVXGPGd4EPEqSnbwNpz55nShF682DPH5ou9rbxNTIgh8TKqFsylwkV7FqERHjypbeNyYTJ0nhvCLPNKLj7SKPEOtpu/s600/jelly-original.png" itemprop="image">


This bitmap is 1.1MB uncompressed and 299KB when compressed as PNG.




Compressing the Android jellybean jar texture into ASTC through the "http://malideveloper.arm.com/develop-for-mali/tools/asset-creation/mali-gpu-texture-compression-tool/">
Mali GPU Texture Compression Tool
yields the following results.







































Block Footprint

4x4

6x6

8x8

Memory

262KB

119KB

70KB

Image Output

"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3QGkIC7VMc9zAVVlIP-67o2B_2NXE0UfPwpbUKRhlD6C2hav7KX6yLwmAsgEpRWs7748qP8pOuPRU02gkklTfZ6Yo-uy9J7s7r91oRBZcVcq-6B9gnxr9qlW8r6bffiYXeZ_9LaCTZPvr/s1600/jelly-astc-4x4.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3QGkIC7VMc9zAVVlIP-67o2B_2NXE0UfPwpbUKRhlD6C2hav7KX6yLwmAsgEpRWs7748qP8pOuPRU02gkklTfZ6Yo-uy9J7s7r91oRBZcVcq-6B9gnxr9qlW8r6bffiYXeZ_9LaCTZPvr/s200/jelly-astc-4x4.png">


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIlznPXhROqeUQK8-TjecYpOamBOdjfeVDGUGAfvXhG_7qaInqtdRxQDfB9wbOyvlmrWTm9hPiW_80re-pyqjZq_JEXQPzVC8zSE4fXKBA5YTvy-Odd7tp_nroyqCCwaTRuwyMQ8fG6v61/s1600/jelly-astc-6x6.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIlznPXhROqeUQK8-TjecYpOamBOdjfeVDGUGAfvXhG_7qaInqtdRxQDfB9wbOyvlmrWTm9hPiW_80re-pyqjZq_JEXQPzVC8zSE4fXKBA5YTvy-Odd7tp_nroyqCCwaTRuwyMQ8fG6v61/s200/jelly-astc-6x6.png">


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRFtbsnnYGF_aMPd1Q7i9p3KmuYXizpp-WiWao_acVUdO6AxN5mJiNHMdPnxfa62incADz487v4_XJZa2js2g_HGPftWLLoAJ6CSL_dBzFPx9mu1i53BApXsikyJ-jcqVUDks8sMFLnQJy/s1600/jelly-astc-8x8.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRFtbsnnYGF_aMPd1Q7i9p3KmuYXizpp-WiWao_acVUdO6AxN5mJiNHMdPnxfa62incADz487v4_XJZa2js2g_HGPftWLLoAJ6CSL_dBzFPx9mu1i53BApXsikyJ-jcqVUDks8sMFLnQJy/s200/jelly-astc-8x8.png">


Difference Map

"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1-4WrEsvLxWNssAMrx27pXskY0WR983ez2SPjxcOwL3zD4tXmUP_Hvgus0HyccZDt5BQ6Dq6l3JfGTBOgRQQ_HwOenAJd05CnpE9HsBfDtjPYS_YNwJ9iAEOiY323QrtKXT5Unh_E7By/s1600/4x4-1x.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1-4WrEsvLxWNssAMrx27pXskY0WR983ez2SPjxcOwL3zD4tXmUP_Hvgus0HyccZDt5BQ6Dq6l3JfGTBOgRQQ_HwOenAJd05CnpE9HsBfDtjPYS_YNwJ9iAEOiY323QrtKXT5Unh_E7By/s200/4x4-1x.png">


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNWJCBOBrbQrSBRSKsNpDBKUu3hEqlzAlJS-SS63fW71Ty32PhqC31qkTxjSs4L4rVkE6z5t0mhp-l5tIzkkqGI72KBBghMKt8-aeCZQzv7bxxYibgOZ8ov0qK5X0BLLDYjsskKSi7__WG/s1600/6x6-1x.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNWJCBOBrbQrSBRSKsNpDBKUu3hEqlzAlJS-SS63fW71Ty32PhqC31qkTxjSs4L4rVkE6z5t0mhp-l5tIzkkqGI72KBBghMKt8-aeCZQzv7bxxYibgOZ8ov0qK5X0BLLDYjsskKSi7__WG/s200/6x6-1x.png">


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-q1SXlDlqB5DaijIDhyphenhyphenoxxmArnRAMTaX10PLlydJRBtlwf3QbsxewwkXLxJV64TC0OOFPe4xIK2K_Hat3lVnelsykkoU54AppI5CIIPcldrOg9mfM7cMKxksqH-G1X1JQUOB6QQ-9BO0F/s1600/8x8-1x.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-q1SXlDlqB5DaijIDhyphenhyphenoxxmArnRAMTaX10PLlydJRBtlwf3QbsxewwkXLxJV64TC0OOFPe4xIK2K_Hat3lVnelsykkoU54AppI5CIIPcldrOg9mfM7cMKxksqH-G1X1JQUOB6QQ-9BO0F/s200/8x8-1x.png">


5x Enhanced Difference Map

"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYL6eXJNqlHG6aziUe3yS7MPAZutLeXp5IewNInGgGIlSL0BOP7gEMT4ycCz6cRz3QANy8zvuaUUdaUQ6ZGREgVknLnTpOS8X61wON9BpONJr1pnglG2EGtZFNFaA2mor5cRx83nl9_TM7/s1600/4x4-5x.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYL6eXJNqlHG6aziUe3yS7MPAZutLeXp5IewNInGgGIlSL0BOP7gEMT4ycCz6cRz3QANy8zvuaUUdaUQ6ZGREgVknLnTpOS8X61wON9BpONJr1pnglG2EGtZFNFaA2mor5cRx83nl9_TM7/s200/4x4-5x.png">


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNTglcNfiOxJcjpkxzYi8HZUPDuwKB5V-VZ9XeW37mey1rwaKStqy5oMk3Bme7xUjjIaEb2lgQBr0OLtohXM80pPUyWuVCSN5JNuLuS0jiYL5w5Oo8jccF34N308NzT2SNTsgSq1qLHao9/s1600/6x6-5x.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNTglcNfiOxJcjpkxzYi8HZUPDuwKB5V-VZ9XeW37mey1rwaKStqy5oMk3Bme7xUjjIaEb2lgQBr0OLtohXM80pPUyWuVCSN5JNuLuS0jiYL5w5Oo8jccF34N308NzT2SNTsgSq1qLHao9/s200/6x6-5x.png">


"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMcPGVPgHlHqN6gsn_P-pUSSjvNyRXqhGERtJwto6NfkYZDNJz-oPHtSNO5phRj3RDBfEXBRiffOfI4Izu3joM8N-d5XYSF-bFmklteQjy10zEhv5CD_FutRNRmxm_rhjE2ywrIDnnR1Xp/s1600/8x8-5x.png"
imageanchor="1"> "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMcPGVPgHlHqN6gsn_P-pUSSjvNyRXqhGERtJwto6NfkYZDNJz-oPHtSNO5phRj3RDBfEXBRiffOfI4Izu3joM8N-d5XYSF-bFmklteQjy10zEhv5CD_FutRNRmxm_rhjE2ywrIDnnR1Xp/s200/8x8-5x.png">




As you can see, the highest quality (4x4) bitrate for ASTC already gains over
PNG in memory size. Unlike PNG, this gain stays even after copying the image
to the GPU.




The tradeoff comes in the detail, so it is important to carefully examine
textures when compressing them to see how much compression is acceptable.




Conclusion




Using hardware accelerated textures in your games will help you reduce the
size of your .apk, runtime memory use as well as loading times.




Improve performance on a wider range of devices by uploading multiple apks
with different GPU texture formats and "http://developer.android.com/training/multiple-apks/texture.html?utm_campaign=ASTC-115&utm_source=dac&utm_medium=blog">
declaring the texture type in the AndroidManifest.xml
.




If you are aiming for high end devices, make sure to use ASTC which is
included in the Android Extension Pack.



ليست هناك تعليقات:

إرسال تعليق

Post Bottom Ad

Responsive Ads Here

Pages