How can i find out if a texture loaded from an PNG via the asset loader is in RGB or RGBA format?
I tried looking at the “textureFormat” (material.opacityTexture.textureFormat) but it seems to always return -1 in my use case. Should this work? Is there any other way to check?
The use case is to support both grayscale RGB images and proper RGBA opacity maps by automatically setting the getAlphaFromRGB when there isn’t any alpha channel in the image.
The only idea that I have is to draw the texture on the canvas, and then you can read pixel data HTML canvas getImageData() Method and figure out some logic what to do with that.
I did not test this, but I assume that if there is no alpha channel in the image
imgData.data[3]
would return undefined or something
It is not ideal solution performance-wise, but it might work.
Thanks for the idea Nogalo. But if I will go that route I can also access the raw data, either via Babylon if possible, or load the image via a side channel, and check the actual pixel values that way.
I just find it odd that the information from the PNG decoder isn’t exposed via textureFormat, so I thought I might be doing something wrong.