Archived

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

How to add a alpha channel to a Xfile?

This topic is 5242 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Please, somebody could answer my question: - How to add a alpha channel to a Xfile? I want to have a translucent object (it is a Xfile) in my scene, but I don''t know how to get the vertexes from the xfile? I''m starting in Direct3D. Thank you for your attention.

Share this post


Link to post
Share on other sites
you want to parse the X file and identify the particular subset you want to be translucent, then you want to create the corresponding texture using the D3DXCreateTextureFromFileEX.(If you know what texture you need upfront you can skip the first part) the EX function allows you to create an alpha channel in a non-alpha''d texture. Then be sure and set the proper render states to display translucency.

Share this post


Link to post
Share on other sites
OK, thanks for your reply.

I''m using the D3DXCreateTextureFromFileEx function, but I only can do the transparency (seting color-key)... no translucent.
Please, could you help me how to setup the code correctly? I have in my code:

g_d3d_device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
g_d3d_device->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
g_d3d_device->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_CURRENT);
g_d3d_device->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);
g_d3d_device->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
g_d3d_device->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
g_d3d_device->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
g_d3d_device->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);

...and my function is:

D3DXCreateTextureFromFileEx(
g_d3d_device,
"Capa_CD.png",
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
NULL,
D3DFMT_UNKNOWN,
D3DPOOL_MANAGED,
D3DX_DEFAULT,
D3DX_DEFAULT,
0, // I have a doubt here
NULL,
NULL,
&Texturas )

What I must do to have 50% opaque/transparent?

Share this post


Link to post
Share on other sites