[Closed] Partial Alpha's not showing up for Textures
Hey everyone, Im trying to simply create a plane and then set a texture to it from the SDK but for some reason partial alphas do not show up at all. It seems if there is any alpha at all, 3Ds Max will just view the pixel as full alpha. Everything else seems to show up correctly.
The strangest thing is that after I create the object and go to the Material Editor, all I have to do is Deselect and Select Show Standard Map in Viewport and all the alpha values will show up correctly. Shouldnt that button be the same as setting the MTL_TEX_DISPLAY_ENABLED flag for the material from the Max SDK?
// Set The Texture
BitmapTex* bitmapTexture = NewDefaultBitmapTex()
bitmapTexture->SetMapName( pictureFile )
bitmapTexture->SetAlphaAsMono( TRUE )
bitmapTexture->SetName( "pictureTexture" )
// Create a material to the node
StdMat2* planeMat = NewDefaultStdMat()
planeMat->SetSubTexmap( ID_DI, bitmapTexture )
planeMat->SetSubTexmap( ID_OP, bitmapTexture )
planeMat->SetName( "pictureMaterial" )
planeMat->SetActiveTexmap( bitmapTexture )
planeMat->SetMtlFlag( MTL_TEX_DISPLAY_ENABLED )
// set node
node->SetMtl( planeMat )
// redraw
ip->RedrawViews(ip->GetTime())
Any ideas would be great
No one else is having this issue? I looked through the SDK and it seems I’m doing everything correctly. I think it might be a Max bug but if I’m the only one seeing it maybe I am doing something wrong
I’ve been tinkering with this stuff for a couple of days now but I still haven’t been able to figure out what’s going wrong. I have found one peculiar thing though, maybe that will turn on a light bulb for another experienced Max SDK user.
I’ve been tinkering with various functions, and I noticed this one in particular seems to indicate something is wrong:
node->GetMtl()->GetCustAttribContainer()
After I create my material and assign it to the node from the SDK, I noticed the Custom Attribute Container is NULL. However, after I Deselect and Select Show Standard Map in Viewport in the Material Editor for that material, the Custom Attribute Container is now initialized to something. Am I suppose to be doing something with that if I am just doing a standard material?
this man needs help
SDK-Help for SetActiveTexmap():
Note that this method does not do everything required to update the viewports with the new texmap. To accomplish that call Interface::ActivateTexture().
what you need is:
ActivateTexture(bitmapTexture, planeMat);
also MTL_TEX_DISPLAY_ENABLED isn’t enough, you also need to set MTL_SUB_DISPLAY_ENABLED
planeMat->SetMtlFlag(MTL_DISPLAY_ENABLE_FLAGS);
guruware
Thanks for the suggestions guruware!
Unfortunately I’ve already tried using ActivateTexture before but for some reason it completely disables Alpha which is why I stopped using it.
Also I tried using MTL_DISPLAY_ENABLE_FLAGS but it didn’t seem to make a difference. When I clicked on the “Show Standard Map in Viewport” button from the Material Editor and then checked the flags in the SDK manually, I noticed they only had the
MTL_TEX_DISPLAY_ENABLED flag enabled so I just tried to copy their settings exactly.
Here is the code I just tested which makes alpha completely not show up:
// Set The Texture
BitmapTex* bitmapTexture = NewDefaultBitmapTex();
bitmapTexture->SetMapName( pictureFile );
bitmapTexture->SetAlphaAsMono( TRUE );
bitmapTexture->SetName( "pictureTexture" );
// Create a material to the node
StdMat2* planeMat = NewDefaultStdMat();
planeMat->SetSubTexmap( ID_DI, bitmapTexture );
planeMat->SetSubTexmap( ID_OP, bitmapTexture );
planeMat->SetName( "pictureMaterial" );
planeMat->SetActiveTexmap( bitmapTexture );
planeMat->SetMtlFlag( MTL_DISPLAY_ENABLE_FLAGS );
// set node
node->SetMtl( planeMat );
// Activate the Texture
ip->ActivateTexture( bitmapTexture, planeMat );
I tried setting the MtlFlag after ActivateTexture and alphas seem to show up again, but partial alpha’s still don’t show up (unless I deselect and select Show Standard Map in Viewport of course).
ip->ActivateTexture( bitmapTexture, planeMat );
planeMat->SetMtlFlag( MTL_DISPLAY_ENABLE_FLAGS );
If it helps any, here are some pictures I made to show what is going on:
image.png : the test image, it just goes from blue fading out and fading back in
before.png: this is what the code outputs onto 3ds max
after.png: After I select and Deselect Show Standard Map in Viewport
your’e right, partial alpha is only shown when doing this in mateditor
i tried some “100” codevariations, none gave me the correct alpha in viewport
must be some additional option or something they dont tell us…
guruware
Hello everyone, I posted this question about 10 months ago using 3ds Max 2009 and figured it was worth bumping to see if anyone has any ideas now. I’ve been tinkering around with 3ds Max 2011 and it seems it has the exact same problem where partial alpha’s do not show up.
One thing I did notice though in Max 2011 is when I go to “View” >> “Show Materials in Viewport As” >> “Standard Display with Maps” All the alpha magically shows up. If someone knows how to enable this option in the SDK perhaps it would solve the problem (I have a hunch that this button simply loops through all the materials and checks “Show Standard Map in Viewport” though).