Z Buffer Problems

Started by
7 comments, last by nes8bit 23 years, 10 months ago
When I turn off the writing to the zbuffer and turn it back on, it doesn''t work. The zbuffer doesn''t go back to normal after that. Any suggestions? This happened on 3 computers so far. ------------------------ Captured Reality
Advertisement
Someone please? I need this one.

------------------------
Captured Reality
You should email nes8bit, he probably knows. Just kidding, is this OpenGL or Direct 3D??? Give some code that you are using.

---
www.crazycrackerz.org
Direct3D

Not much to the code. It''s just setting the renderstate.

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, True

''// Draw Particles Here

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, False

------------------------
Captured Reality
Does pd3dDev->Clear() return ok, or does it by chance give "no z-buffer present"? (And do the z-write render state changes return ok?) What do you mean the z-buff "doesn''t go back to normal"?
I never looked into that.

After I set the renderstate to no writing to the zbuffer, it doesn''t want to go back. I''m wondering if I have to do something when I create the zbuffer surface or if it''s simply a driver problem. I will look into the zbuffer clears when I get back to my computer.

------------------------
Captured Reality
Thanks guys for trying to help, but I found out it was a driver problem. I''m still not sure if its a driver problem, but I fixed it. If you ever get this problem, follow the pseudo code.

int i;

i = D3DDev.GetRenderstate(D3DRENDERSTATE_ZWRITEENABLE)
D3DDev.SetRenderstate(D3DRENDERSTATE_ZWRITEENABLE,False)

// Do particle effects here

D3DDev.SetRenderstate(D3DRENDERSTATE_ZWRITEENABLE,i)

it''s a very simple solution



------------------------
Captured Reality
Uh, nes, that doesn''t look like a driver issue. It''s more of a logic one .

See this:

quote:
If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, True

''// Draw Particles Here

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, False


Basically what your doing is turning on the Zwriting when you are drawing the particles, then turning it off as soon as your done. (You need to do the opposite )

So instead, do this:

If UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, False''// Draw Particles HereIf UseZBuffer Then Direct3DDevice.SetRenderstate D3DRENDERSTATE_ZWRITEENABLE, True  


--TheGoop
Oh silly me. I didn''t copy the code directly, but it already looks like that. Thanks anyway.

------------------------
Captured Reality

This topic is closed to new replies.

Advertisement