Skip to main content
gamedev.net
🔒 Locked

Mesh Transparency

Started by sansured Dec 3, 2005 at 6:52 PM 2 replies 600+ views
Original Post
sansured
sansured
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]
Mijin
Mijin
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...
;)
Mijin
Mijin
Also, how does it look if you try:

pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_INVSRCCOLOR);
pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR);
sansured
sansured
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.