Sign in to follow this  

objects: behind and in front of

Recommended Posts

Claudio    121
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
Evil Steve    2017
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
Claudio    121

The follow are the parameter for the Z-Buffer (like in the site and

// D3D present parameters
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

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