Check if albedo Texture has alpha channel


How i can check in Code if the albedo Texture has “Texture” in Alpha channel?
So i want create an markup for the user, that the Model has Transparency.

Do I have to get the channel and then check pixel by pixel if gray colors exist?


First I assume that this is a format that supports alpha, like PNG, but not JPG.

I do not know if or how inspector shows alpha, but Gimp and may other programs show a pattern to indicate that there is alpha. Here is an eyebrow texture, which needs to be transparent to be over layed on top of skin.

If you are trying to debug a material, the material with the texture, you must also ensure that the transparencyMode is set. The default is BABYLON.PBRMaterial.PBRMATERIAL_OPAQUE. When not set to one of the other modes, it will not be transparent.

material.transparencyMode = BABYLON.PBRMaterial.PBRMATERIAL_ALPHABLEND;
1 Like

I don’t want activate transparency or so … i only want know if albedo texture which is a PNG has “content” in Alpha channel.

It is a glb file and i want check if alpha is present.

If you are using loading from glTF, you can check the hasAlpha property of the texture to see if is supposed to have alpha or not. Note that this does not mean whether the source image actually has alpha or not but instead whether glTF says it should have alpha or not.

AFAIK, there is no way to tell if the source image has alpha or not on the web without parsing the image manually.

1 Like

Is there a good example how parse image manuelly?

I’m not sure why you would want to parse manually. If you are trying to show the user whether the model has alpha and it’s a glTF, then the hasAlpha property is what you want. Whether the texture actually has alpha or not is not relevant to the model.


I’d personally never used this property before but was curious, so a made a little playground example.

Check out line 18

Hope this helps!