Archived

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

helix

Z issue

Recommended Posts

I have a simple demo I''m working on and I''ve been struggling with this bug for a while now. In my main render function call, I call the render function for all my other objects -- my room, a list of sphere objects, my weapon effect, and my UI. I''ve noticed that each render call''s Z ordering is separate from the rest. So for example, my list of sphere''s and the particle system it owns get''s drawn correctly but the next function call for my weapon effect is not properly ordered with the balls Z orders. I do turn off the Z test for my particle system (g_pGame->GetDevice()->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE ) but turn it back on when I''m done. That shouldn''t affect it should it? It''s driving me nucking futs!!

Share this post


Link to post
Share on other sites
How do you clear it? I don''t think I am, the only operation that affects the z buffer is the line I included above:

g_pGame->GetDevice()->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );

Share this post


Link to post
Share on other sites
before you begin each scene, you should be clearing the display. This function can also clear the z-buffer (like-so):


  
g_pGame->GetDevice()->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(0,0,0,255), 1.0f, 0);




This should change _something_!!

Hope it helps.

Fuzztrek

¬_¬

Share this post


Link to post
Share on other sites
Update on this. I was talking to a friend of mine and he said he thought that if you turn off the zbuffer then back on in the middle of a render call, it''ll mess it up. He said that I should save the rendering of the entities that don''t need the zbuffer last. Would that fix it?

Share this post


Link to post
Share on other sites
No, changing rendering states mid-scene shouldn''t mess anything up. If you hold off rendering non-zbuffered objects until last, than those objects will overwrite everything regardless.

What does your function call to turn the zbuffer back on? What''s the code to create a zbuffer look like? Maybe you should post a screenshot of the effect.



Jim Adams
home.att.net/~rpgbook
Author, Programming Role-Playing Games with DirectX
and Focus On: Advanced Animation with DirectX

Share this post


Link to post
Share on other sites