Sign in to follow this  
sansured

Mesh Transparency

Recommended Posts

sansured    138
Hi, I am trying to set my mesh's .x files trasparency with the code below.It's working but i have a problem.Mesh's transparency increasing white (255,255,255) to black(0,0,0).I mean if mesh's texture is white it is more opaque but if the texture is black it is transparent.I want to revers it.Black to white opaque to transparent. Does anyone have any idea about it?
[sourcecode]

 // alpha on
 pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
 // choose a blending type
 pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
 pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_BOTHSRCALPHA);

[sourcecode]

Share this post


Link to post
Share on other sites
Mijin    100
If you're loading the material's texture yourself, check what colour key you're passing to D3DXCreateTextureFromFileEx, or whatever you're using.

Another thing to check is if there's a MeshVertexColors section in the .x file. (Obviously you can only check this if it is a text X file).
If so, then perhaps the problem is that the vertex colours' alphas are the wrong way round.

Oh, one other thing it could be is simply that the texture file has an alpha channel. Open it up in a bitmap editor and try to view alpha channel / load mask.

-----
You've probably tried all these things already. I don't know too much about this stuff, but since you've had no replies...
;)

Share this post


Link to post
Share on other sites
Mijin    100
Also, how does it look if you try:

pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCCOLOR);
pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);

Share this post


Link to post
Share on other sites
sansured    138
When i try

this

pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCCOLOR);
pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);

In the beggining it's looks like working but it's not.I mean one side of the mesh is transparent like i want but the other side is opaque.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this