FPS Weapon

Started by
12 comments, last by superpig 18 years, 3 months ago
Sure, but quake 3 doesn't use modern shadowing techniques. If I remember right its shadow maps or perspective shadow maps that have issue with the whole zbuffer clearing idea. I could be wrong though. And anyone know for sure if clearing the zbuff stalls the pipeline?
Advertisement
To the anonymous poster and CastorX :

Ok, i will clear the z-buffer. But how do i do that in directx ? Because if i use the clear method it of course erase all. Should i present the things that are done (apart from the gun and the GUI), then clear and recall Present for the gun and the GUI ?
"Do, or do not. There is no try." - Yoda
Problem solve, i actually succeeded to erase the z-buffer. For those who come on this thread to have a solution, here it is :

As it has been said, we must clear the z-buffer between the scene objects rendering, and the gun and GUI rendering, so they are kind of independant. But it's important to clear only the z-buffer, because erasing the stencil buffer can cause problems and clearing the viewport, well... clear the viewport. So, in the Clear() call of IDirect3DDevice9, the target flag must be only D3DCLEAR_ZBUFFER. Here is an exemple :

First clear (with target flags like D3DCLEAR_ZBUFFER, D3DCLEAR_TARGET and D3DCLEAR_STENCIL)
Begins scene
Draw objects (like ground, characters, etc..)
D3DDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,0),1.0f,0); (those parameters are for exemple sake, yours can be different, apart from the D3DCLEAR_ZBUFFER flag of course)
Draw gun and GUI
End scene
Present


Thnaks to you all for helping me, and good luck to new game programmer looking for this solution !
"Do, or do not. There is no try." - Yoda
If you want to avoid the clear and are willing to sacrifice a little z-buffer precision for it, you could solve this by splitting the Z-buffer into two "windows" - one large one that you use for the majority of the scene (say Z-values 0.05 through 1.0) and one small one that you use just for the gun (say 0.0 through 0.05). You can set these windows up using the MinZ/MaxZ parameters on the viewport.

However, because you're using a reduced Z-buffer range and thus reduced precision, you might see Z-fighting issues.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement