This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
Parents
  • Note: This was originally posted on 22nd March 2013 at http://forums.arm.com

    Hi Irfan,

    I didn't spot you posted about the same issue twice - I've merged the threads and deleted the duplicate post without the code.

    You are right that the ETC1 format used by OpenGL ES 2.0 doesn't contain an alpha channel, but plenty of OpenGL ES 2.0 games and examples manage translucent water effects, so you don't need to move to OpenGL ES 3.0 just for that reason. Since there are not many commercial devices supporting OpenGL ES 3.0 yet perhaps aim to do the effect under OpenGL ES 2.0 to maximise the target market?

    There are a few ways to use both ETC1 and have an alpha channel, essentially it comes down to 2 choices.

    1) you could double the height of the texture, and keep only RGB color data in the top half, and put the alpha channel in the bottom half in grayscale. Then, your fragment shader changes to sample the top half of the texture to get the color data and samples the same texel in the bottom half to read the alpha value.

    2) you could have 2 ETC1 textures, one holding color data and one holding alpha data coded as grayscale. You sample both textures in your fragment shader to form the complete RGBA texture data.

    We have some sample code and a document that goes into more depth on these techniques.

    From the code posted, it looks like if you see the message "Unable to read PKM file header" then the code wasn't able to read even the ETC1 header bytes. Could it be a problem with the InputStream itself? You could try changing the code to print how many bytes were able to be read (we only know it's not the number that are in an ETC1 header). If for instance it comes back zero then something has gone wrong trying to read the stream at all. If it reads some but not enough for an ETC1 header then perhaps the file has become corrupt and truncated somehow.

    HTH, Pete
Reply
  • Note: This was originally posted on 22nd March 2013 at http://forums.arm.com

    Hi Irfan,

    I didn't spot you posted about the same issue twice - I've merged the threads and deleted the duplicate post without the code.

    You are right that the ETC1 format used by OpenGL ES 2.0 doesn't contain an alpha channel, but plenty of OpenGL ES 2.0 games and examples manage translucent water effects, so you don't need to move to OpenGL ES 3.0 just for that reason. Since there are not many commercial devices supporting OpenGL ES 3.0 yet perhaps aim to do the effect under OpenGL ES 2.0 to maximise the target market?

    There are a few ways to use both ETC1 and have an alpha channel, essentially it comes down to 2 choices.

    1) you could double the height of the texture, and keep only RGB color data in the top half, and put the alpha channel in the bottom half in grayscale. Then, your fragment shader changes to sample the top half of the texture to get the color data and samples the same texel in the bottom half to read the alpha value.

    2) you could have 2 ETC1 textures, one holding color data and one holding alpha data coded as grayscale. You sample both textures in your fragment shader to form the complete RGBA texture data.

    We have some sample code and a document that goes into more depth on these techniques.

    From the code posted, it looks like if you see the message "Unable to read PKM file header" then the code wasn't able to read even the ETC1 header bytes. Could it be a problem with the InputStream itself? You could try changing the code to print how many bytes were able to be read (we only know it's not the number that are in an ETC1 header). If for instance it comes back zero then something has gone wrong trying to read the stream at all. If it reads some but not enough for an ETC1 header then perhaps the file has become corrupt and truncated somehow.

    HTH, Pete
Children
No data