4
\$\begingroup\$

My app currently uses a lot of textures most of which probably could be compressed quite a lot by using ETC2 (my app runs on 4.4 so i have a lot of devices supporting GLES30), i cannot use ETC1 since i need alpha too.

Problem is that i map my textures from a Bitmap i create dynamically (and quite often every 60 seconds), i currently map them this way (textures are not power of 2 sized):

GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, id);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, mode);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, mode);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

So i was wondering if:

  • Is it possible to load a Bitmap using ETC2 to use less memory on the graphic card? A code example would be great
  • How much overhead does the compression have? Mapping a 1024x1024 ARGB_8888 Bitmap every 60 seconds is feasible?
\$\endgroup\$
2
\$\begingroup\$

Note that while GLES3 mandates ETC2 support, it doesn't mandate that it saves any memory on the graphics card. A lot of implementations that support it simply decompresses the texture in software and create an uncompressed texture on the graphics card. The same problem also applies to ASTC.

If you need a format that is hardware supported, you need to support several different formats and choose the right one at runtime.

\$\endgroup\$
1
\$\begingroup\$

To answer your first question, yes it's quite possible to load an ETC2 texture on any OpenGL ES 3.0 device. In fact, it's required by the standard. In order to do so, you replace the glTexImage2D function call with glCompressedTexImage2D. For more details, read the documentation.

Currently there aren't that many texture compression tools that support ETC2. Off the top of my head I can only think of one. That compressor uses the stock ETC2 compressor that Ericsson released a while back. I believe that the tool can output textures in a KTX file that comes with a codec implementation.

If you want to do compression online in the app, you may be out of luck. A preliminary search on the internet shows that ports of etcpack exist but I've never tried them. In any case you should be able to expect a decent quality compression of a 1024x1024 sized bitmap within 60 seconds of any codec worth it's salt.

\$\endgroup\$
  • \$\begingroup\$ Thanks for your reply, a possible solution i found is to use 2 ETC1 textures, one for the alpha and one for the other channels, this works but its pretty ugly, also i am not very happy with the texture compression artifacts. \$\endgroup\$ – FrankMonza Feb 17 '15 at 8:50
  • \$\begingroup\$ ETC2 should help with the compression artifacts. Are you generating the ETC1 textures dynamically or offline? \$\endgroup\$ – Mokosha Feb 19 '15 at 7:34
  • \$\begingroup\$ I am generating ETC1 online via Android ETCUtils and quality is unacceptable, i was hoping to find something to do ASTC but up to now there is nothing that works on the device \$\endgroup\$ – FrankMonza Feb 19 '15 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.