Bitmaptexture.alphaSource always return 0

Bitmaptexture.alphaSource always return 0

futengda
Enthusiast Enthusiast
1,295 Views
6 Replies
Message 1 of 7

Bitmaptexture.alphaSource always return 0

futengda
Enthusiast
Enthusiast

Bitmaptexture.alphaSource always return 0 before I clicked the texture in the MaterialEditor, is it a bug?

0 Likes
Accepted solutions (3)
1,296 Views
6 Replies
Replies (6)
Message 2 of 7

denisT.MaxDoctor
Advisor
Advisor

This cannot be called a bug, although there is certainly uncertainty. 😀
I already explained this problem on the "now defunct" CGTalk...
In a nutshell:
- when a BitmapTexture is created, its default alpha source is defined as "what the image file says" - 0.
- but as soon as you upload it for editing, the system reads the actual alpha state from the file.
- and if the system finds out that there is no alpha...
- sets None(Opaque) - 2 (according to UI numbering).

So, to know "what the alphaSource will be" without editing the texture, you need to look to see if alpha is available in the file. If yes, then 0, if no, then 2.

 

Yes, it sounds pretty weird and complicated, but that's the way it's always been.

Message 3 of 7

futengda
Enthusiast
Enthusiast

@denisT.MaxDoctor Thanks for the quick response!

But what if a png file (which alpha is avaliable) manually set to `None(Opaque)` ? It should return 2 rather than 0, then how can I get the real state before editing?  🤣

0 Likes
Message 4 of 7

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

There is no problem with this. If alphasource has been set programmatically or manually, the value can be directly get via MXS. 

Message 5 of 7

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

By the way... the easiest way to check if alpha is available is to check #hasalpha of the texture bitmap

Message 6 of 7

futengda
Enthusiast
Enthusiast

When you create a new BitmapTexture in Max Script, its alphaSource always returns 0 until you click it in the Material Editor to display the UI, after which it changes to 2 (None). I believe this is indeed a bug because the default value of alphaSource for BitmapTexture should be consistent with the UI, which should be 2.

0 Likes
Message 7 of 7

futengda
Enthusiast
Enthusiast
Accepted solution
0 Likes