Kesshi Posted December 10, 2015 Share Posted December 10, 2015 Hi, after loading a texture how can i check if the source image (PNG) has an alpha channel/transparent pixels or not?I need to know this to set the flags material.diffuseTexture.hasAlpha and material.useAlphaFromDiffuseTexture to true.In my scenario the images/textures which will be used later in the application are not predefined.The only way is that i automatically detect if i need to enable the alpha flags. Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 10, 2015 Share Posted December 10, 2015 There is always a way! In this case, not with BabylonJS, but there is a way :-) You will have to download the image on your own, then check the 25's byte of the data. This byte contains the PNG type: Possible values are:0 - grey2 - RGB3 - RGB with palette4 - grey + alpha6 - RGB + alphaSo, you will need to check the 25th bytevar alpha = downloadedData[25] >=4;After downloading the image yourself, you can convert it to Base64 and use it as data for a texture. Does it make sense? Quote Link to comment Share on other sites More sharing options...
Kesshi Posted December 10, 2015 Author Share Posted December 10, 2015 Yes it makes sense :-)I will try this later. Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.