I’m currently writing a rendering node that has a fragment shader that uses the alpha channel in a non-standard way. It doesn’t use it for blending. It uses it for other things.
Anyhow, normally there’d be no problem with this, but what I’m finding is that the PNG loader makes a lot of assumptions about how you’re going to use your image. Specifically, in CCImageCommon_cpp.h, I see this code:
for(unsigned short i = 0; i < m_nHeight; i++)
for(unsigned int j = 0; j < rowbytes; j += 4)
*tmp++ = CC_RGB_PREMULTIPLY_ALPHA( row_pointers[i][j], row_pointers[i][j + 1],
row_pointers[i][j + 2], row_pointers[i][j + 3] );
The problem here is that this is blowing away the information in my color channels. I need the image to stay non-pre-multiplied. I just want the raw color and alpha channels with no modification.
On a related note, I do have some images I’m rendering out of Maya that has premultiplied alpha already. If I put it in a PNG, I think it’s premultiplying it again, double-darkening those edges.
This is in version 2.1.4. It sounds like this might be already addressed in 3.0? Ideally there’d be some sort of flag we could set which would turn this premultiplying on or off. In my case I really don’t want this functionality for my specific use case.
Short of modifying the cocos2d code locally, is there any sort of workaround that anyone could suggest in the meantime? I’ve tried saving out a TIFF and loading that, and it actually does the right thing, but unfortunately pops up an annoying warning dialog on load in Windows (my usual development platform). Perhaps PVR would work, but I don’t want the compression. I really just want the raw texture data, unmodified.