OpenGL Android Texture Compression

I need help finding information (or an example) on how to use texture compression for Android. Now I have a lot of PNG, and I need to reduce the amount of memory that they use. I looked at PVR compression, but I cannot figure out how to use this in OpenGL.

Can someone point me in the right direction or offer some examples, since I can not find anything.

+55
android opengl-es textures
Feb 05 '12 at 11:20
source share
4 answers

There are basically four types of texture compression supported on Android:

  • ETC1 (Ericsson texture compression) . This format is supported by all Android phones. But it does not support the alpha channel, so it can only be used for opaque textures.
  • PVRTC (PowerVR texture compression) . Supported by devices with PowerVR GPUs (Nexus S, Kindle fire, etc.).
  • ATITC (ATI texture compression) . Used in devices with Qualcomm Adreno GPU (Nexus One, etc.).
  • S3TC (S3 texture compression) . This texture compression is used in devices with the NVIDIA chipset (Motorola Xoom, etc.)

More information here and here .

In short, if your textures don't have alpha, you can use ETC1. If they have alpha and you want to support all devices, you have to compress your textures in three other types and load them according to the device.

How to use:

  1. Compress your png files (you can use tools like ETC-Pack , PVRTexTool , ATI Compressonator , Nvidia Texure Tools according to the texture type) and add them to your project resources.

  2. Determine which extensions are available on your device if you are not using ETC1:

    public void onSurfaceCreated(GL10 gl, EGLConfig config) { String s = gl.glGetString(GL10.GL_EXTENSIONS); if (s.contains("GL_IMG_texture_compression_pvrtc")){ //Use PVR compressed textures }else if (s.contains("GL_AMD_compressed_ATC_texture") || s.contains("GL_ATI_texture_compression_atitc")){ //Load ATI Textures }else if (s.contains("GL_OES_texture_compression_S3TC") || s.contains("GL_EXT_texture_compression_s3tc")){ //Use DTX Textures }else{ //Handle no texture compression founded. } } 
  3. Load the compressed texture as raw data.

  4. Use glCompressedTexImage2D instead of glTexImage2D:

     public void onDrawFrame(GL10 gl) { .... gl.glCompressedTexImage2D(GL10.GL_TEXTURE_2D, level, internalformat, width, height, border, imageSize, data); } 
+84
Mar 01 '12 at 10:20
source share

This is an ol stream, so I decided to update it using the information available at http://devtools.ericsson.com/etc ETC2 is mandatory in the Khronos OpenGL ES 3.0 and OpenGL 4.3 standards.

+5
Mar 23 '13 at 10:18
source share

You should not use only PVR compression on Android, as this will not work with all models. To get around this, you should either use only ETC1 (provided on all GLES 2.0 devices) or have separate texture packs for individual GPU modes. The Android Developers Guide has a helper class for loading the compression format.

You can use etcpack for compression.

Note that you will not get the alpha channel with ETC1 - you can do some fancy shadow fragments to get around this by having the alpha channel as a separate texture.

+3
Feb 05 2018-12-12T00:
source share

I just want to point out that etc1 is not supported by all Android devices, contrary to what gergonzalez said

Note: ETC1 format is supported by most Android devices, but it is not guaranteed to be available. To check if the ETC1 format is supported on the device, call the ETC1Util.isETC1Supported () method.

https://developer.android.com/guide/topics/graphics/opengl.html#textures

+3
Apr 21 '14 at 20:35
source share



All Articles