Sign in to follow this  
Claudio

objects: behind and in front of

Recommended Posts

Hi. My problem is that the virtual object A (that is behind of the virtual object B in the virtual envroinment) is graphically always in front of the object B. The current settings are the follows:
 	
ZEnable = true;
CullMode = ccw;
AlphaBlendEnable = true;
BlendOp = add;
SrcBlend = srcalpha;
DestBlend = invsrcalpha;


Are theese settings correct ? or incorrect ? And/Or there are also other parameters to set ? The version of DirectX is 9.

Share this post


Link to post
Share on other sites
Yes and no. For opaque translucent objects, you'll need to draw them in back-to-front order, otherwise the translucency won't work properly.

Have you actually created a Z-buffer? What is the depth-stencil format set to in your D3DPRESENT_PARAMETERS?

Share this post


Link to post
Share on other sites
Hi.

The follow are the parameter for the Z-Buffer (like in the site http://www.toymaker.info/Games/html/z_buffer.html and http://www.toymaker.info/Games/html/render_states.html#Zbuffer):


// D3D present parameters
D3DPRESENT_PARAMETERS D3Dpp;
ZeroMemory(&D3Dpp, sizeof(D3Dpp));
// Fill of the structure D3Dpp
...
D3Dpp.EnableAutoDepthStencil = true;
D3Dpp.AutoDepthStencilFormat = D3DFMT_D16;

// creation of the device:
....



and then:


D3DDev->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); // ZEnable
D3DDev->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
D3DDev->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);



But the object A (behind of the object B) is always in front of the object B.

Are the parametrs correct so ? or not ?

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