I wanted to reduce apk size of my game. So I wanted to convert PNG32 files to JPEG+Alpha.
I’ve spend several days to research and made a component for it.
This component can be applied any node that has cc.Sprite component on it to mask with alpha texture.
It compiles a shader to get RGB colors from original sprite texture and ALPHA from alpha texture.
Useful to apply transparency on JPEG images.
Tested on: Cocos Creator 1.9.3 Editor, Simulator, Browser, Windows, Android.
** Note for browser and editor **
It doesn’t work properly if original sprite frame and alpha sprite frame comes from differen texture atlases.
I couldn’t manage to give second texture on webgl. Any contribution appreciated
Here is the repo:
I hope it saves time for you