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

Problems with alpha mask using ETC1 textures

Hello,

I'm having a problem when creating textures with the Mali texture compression tool. I'm following this Mali tutorial to create a separate alpha mask that handles the alpha channel from an ETC1 texture using Method 2 as described. I managed to get this working but it appears that little white lines or artifacts are appearing round the edges where the alpha parts of the image meet the opaque parts. My current blend function is (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). This was the only blend function that would allow this to method to work. Maybe there is another blend function that would change this and rectify the problem. Or maybe some other setting in OpenGL, I aslo posted this on the OpenGl forums.

I think the problem may go away or be less noticeable if the first generated texture that contains the real RGB values has black for the transparent areas instead of white. Mali Compression tool sets the alpha areas to white and there is no option to change this in the tool. I also noticed that in the texture compression tool Texture Packer. When you generate .pkm files with that tool it sets the alpha areas to to black, which further supports this theory. As it is such a simple change, it would be great if the people who develop Mali could realease an update that allows you to set the colour of the transparaent areas in the generated image.

If anyone has any other insight on this problem that would be great.

EXTRA INFO:

OpenGL ES 2.0 (only supports etc1 not etc2)

Parents
  • stacysmith you're right that would be the most accurate fix for the current method. My fix is slightly more simple but less accurate, since if you just set the colour of all the entire alpha space in one go, to maybe a colour that roughly matches your background colour then the part where the soft alpha mixes with the colour would be barely noticeable.

    Also that technique looks somewhat time consuming unless there is a program that can propagate the colours for you?

    peterharris pre-multiplied alpha does seem like the solution I'm looking for, I know roughly how it works but I'm not an expert on subject by any stretch of the imagination. I'm pretty sure this is the blend function for pre multiplied alpha {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}? So the steps to take with pre multiplied alpha would be:

    1. Obtain pre-multiplied alpha texture (.png)

    2. Compress the texture "as normal"? so I can discard the alpha channel now that the alpha data is multiplied in to the rgb channels? No need for a separate alpha mask?
    3. Set the blend function to {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} cocos2d-x: BlendFunc Struct Reference with I assume blend equation GL_FUNC_ADD
    4. Alpha should be drawn transparent as expected?


    One more thing +1 to supporting this in MTC, I'm already running my texture through 2 different programs, adding another one to that list is going to be so time consuming, especially considering the amount of textures I have in my project. It would be great if MTC could output the compressed texture with pre multiplied alpha. I think developers would very much appreciate that.

Reply
  • stacysmith you're right that would be the most accurate fix for the current method. My fix is slightly more simple but less accurate, since if you just set the colour of all the entire alpha space in one go, to maybe a colour that roughly matches your background colour then the part where the soft alpha mixes with the colour would be barely noticeable.

    Also that technique looks somewhat time consuming unless there is a program that can propagate the colours for you?

    peterharris pre-multiplied alpha does seem like the solution I'm looking for, I know roughly how it works but I'm not an expert on subject by any stretch of the imagination. I'm pretty sure this is the blend function for pre multiplied alpha {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}? So the steps to take with pre multiplied alpha would be:

    1. Obtain pre-multiplied alpha texture (.png)

    2. Compress the texture "as normal"? so I can discard the alpha channel now that the alpha data is multiplied in to the rgb channels? No need for a separate alpha mask?
    3. Set the blend function to {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} cocos2d-x: BlendFunc Struct Reference with I assume blend equation GL_FUNC_ADD
    4. Alpha should be drawn transparent as expected?


    One more thing +1 to supporting this in MTC, I'm already running my texture through 2 different programs, adding another one to that list is going to be so time consuming, especially considering the amount of textures I have in my project. It would be great if MTC could output the compressed texture with pre multiplied alpha. I think developers would very much appreciate that.

Children