Log in

View Full Version : X Files and opacity


hyperkat
12-08-2003, 09:07 AM
I create a model in 3dsMax with opacity in some places so I can see through it. I look at the file with 3DExplor and I can see the opacity. When I load it using the Directx mesh viewer it's not opaque and it's not opaque in the game. Any clue on what I can change to make this work?

Kai-Peter
12-09-2003, 02:39 AM
I wrestled with this problem myself, but it is some time ago so my memory might fail me. If I remember correctly the .x format (or atleast the loader provided with the D3DX library) doesn't support transparency at all. So you are probably doing everything correctly, but there just isn't any engine level support for the thing you are trying to do.

The reason why transparent surfaces aren't supported is that they are generally incompatible with z-buffering. Because transparent pixels need information about all the underlying pixels they basically require you to draw with the following algorithm:

1. Draw all non transparent triangles in the scene
2. Draw all transparent triangles in the scene from back to front

As step 2 requires scene level reordering it is impossible to achieve on a mesh level, that's my guess why D3DX doesn't support it.

patrox
12-09-2003, 02:43 AM
I'm not an expert into that but how about using a 32 bit tga texture with transparent information in it ( instead of using a transparent material ) ?

pat.

Henrik
12-09-2003, 07:54 AM
In any case you need to enable alpha blending, something like

d3d->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
d3d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d3d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

hyperkat
12-09-2003, 08:37 AM
Thanks for the replies. I think Kai hit the problem. I modified the x file for a test and sure nuff I can make it happen just like I want. So now the deal is to modify the x file format with a new template and write my own exporter, sigh....Too much mechanics, not enough game...