As I have my PBR rendering shader working, I find out another obscure in the Defold engine – all texture extract to memory with alpha premultiplied.
As PBR rendering require all data come to shader in linear space / original value, for diffuse data, it’s just a waste of precision, for texture contain other data like normal, metallic, gloss, AO etc, their alpha channel is NOT alpha AT ALL, premultiplying them make no sense.
What’s worse, since Defold does not support sRGB, I’ve to convert them from gamma space to linear space. with alpha premultiply and precision lost, dividing alpha from premultiplied RGB channel introduce loss of precision, and terrible artifact. This force me to use some ugly hack to overcome.
As describe above, please add option to choose if a texture shall have alpha premultiply or not.
Hmmm, after reading through the manual and play around with texture profile, I notice that there is no ETC2 format nor ASTC format support, and texture with alpha channel compress with ETC1 format will lost the alpha channel completely rather than generating a split alpha channel image.
For complex scene, this may incur significant bandwidth pressure on the GPU/memory bus, especially for mobile devices. For now, it may not harm my project too much, but for long run, please consider adding support for ETC2 and ASTC format, since they are really widely support now.
I’m planning to write a complete list of the obscure I encounter during my development of PBR rendering pipeline after finishing current dev stage. Currently, the shader part is now working correctly, leaving essential some components like camera / light and shader enhancement like SH is on the queue.
Expect to write the list next week while waiting for our artist group to build models.