PDA

View Full Version : Partial Alpha's not showing up for Textures


NoKKiE
09-03-2009, 11:57 PM
Hey everyone, I’m trying to simply create a plane and then set a texture to it from the SDK but for some reason partial alpha’s 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. Shouldn’t 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

NoKKiE
09-08-2009, 06:14 PM
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

NoKKiE
09-10-2009, 11:55 PM
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?

guruware
09-11-2009, 01:49 PM
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

NoKKiE
09-11-2009, 06:15 PM
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 );

NoKKiE
09-11-2009, 06:21 PM
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 );

NoKKiE
09-11-2009, 06:46 PM
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”

guruware
09-12-2009, 04:38 PM
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

NoKKiE
05-07-2010, 10:23 PM
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).

CGTalk Moderation
05-07-2010, 10:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.