Archived

This topic is now archived and is closed to further replies.

Toyemann

Alpha Texture Blending Conflict

Recommended Posts

I need help. I fail to get the Alpha Texture Blending to work. When I apply it to an object, nothing happens. Except, all my Alpha Channel materials become Alpha X-Ray. Please show me some codes. Thanks.

Share this post


Link to post
Share on other sites
You''ll be more likely to get an answer if you show us the parameters and data preparation you are performing around the alpha capabilities so we can look for possible mistakes in your code.

-----------------------
- Waverider
A healthy humility and more realistic approach towards what you know comes from realizing what other people know, too.

Share this post


Link to post
Share on other sites
Basically, I'm doing the same thing what everyone else is doing:

Dev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
Dev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
Dev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

Dev->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
Dev->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
Dev->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

Dev->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
Dev->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);

Dev->SetRenderState( D3DRS_ALPHATESTENABLE, True);
Dev->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
Dev->SetRenderState( D3DRS_ALPHAREF, 0);

Dev->SetRenderState( D3DRS_ALPHABLENDENABLE, True);
Dev->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
Dev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);

After this, when I change the diffuse alpha value of the texture material, nothing happens. Except, when I set the diffuse alpha value to 0, the object disappears. Not only that, whenever I enable the ALPHABLENDENALBE, once working semi-transparent non-texture materials turn solid or x-ray.

What am I missing?

[edited by - toyemann on March 22, 2002 3:58:01 PM]

Share this post


Link to post
Share on other sites
quote:

Dev->SetRenderState( D3DRS_ALPHATESTENABLE, True);
Dev->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
Dev->SetRenderState( D3DRS_ALPHAREF, 0);


why on earth did you do that? You're the only one using an alpha test bro. That said given what you set it to it probably isn't doing anything, but I'd remove it anyways.

quote:

After this, when I change the diffuse alpha value of the texture material, nothing happens. Except, when I set the diffuse alpha value to 0, the object disappears. Not only that, whenever I enable the ALPHABLENDENALBE, once working semi-transparent non-texture materials turn solid or x-ray.


If something has an alpha value of 0 that means it's entirely transparent. Can't be seen. Passes all light thru. What are you changing the alpha values of the texture to, and how are you changing them? (are you loading in a tga file or something? what format did you load it in as?)



[edited by - sorrow on March 22, 2002 6:33:59 PM]

Share this post


Link to post
Share on other sites
quote:

Dev->SetRenderState( D3DRS_ALPHATESTENABLE, True);
Dev->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
Dev->SetRenderState( D3DRS_ALPHAREF, 0);



is same as

quote:

Dev->SetRenderState( D3DRS_ALPHATESTENABLE, True);
Dev->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
Dev->SetRenderState( D3DRS_ALPHAREF, 1);



assuming that there is no negative value.


I''m using the .PNG format, and the diffuse alpha values are from 0.0 to 1.0. Unfortunately, at the moment, any value other than ZERO is 100% opaque. How am I changing them? Simply by calling the SetMaterial function. So, what am I doing wrong?

Share this post


Link to post
Share on other sites
quote:


Dev->SetRenderState( D3DRS_ALPHATESTENABLE, True);
Dev->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_NOTEQUAL);
Dev->SetRenderState( D3DRS_ALPHAREF, 0);
is same as

Dev->SetRenderState( D3DRS_ALPHATESTENABLE, True);
Dev->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
Dev->SetRenderState( D3DRS_ALPHAREF, 1);




yes.. I realize that... and both are redundant as that's what would happen anyways if you've got your blending set up properly. I'd advise getting rid of it.


quote:

Dev->SetRenderState( D3DRS_ALPHABLENDENABLE, True);
Dev->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR);
Dev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);



:: smacks himself in the forhead :: Wish I'd read those lines before, you've got your blend settings wrong. It should be

Dev->SetRenderState (D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
Dev->SetRenderState (D3DRS_DESTBLEND, D3DBLEND_INVSRSRCALPHA);

[edited by - sorrow on March 23, 2002 4:10:06 AM]

[edited by - sorrow on March 23, 2002 4:10:39 AM]

Share this post


Link to post
Share on other sites