Original Post
🔒 Locked
Depthbuffer
Advertisement
Depth-buffers? You mean, to use for z- (or w- ) depth culling?
When you create your device, you have to set the parameters :
This will allow the creation of a depth buffer.
Then, to activate it, use :
To disable writing (but with reading/culling still enabled) use :
Although I'm not entirely sure about the "ZWRITE" part.
ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more
[edited by - ToohrVyk on January 4, 2003 10:36:00 AM]
When you create your device, you have to set the parameters :
D3DPRESENT_PARAMETERS Params;
//Set other parameters
Params.EnableAutoDepthStencil = true;
Params.AutoDepthStencilFormat = D3DFMT_D16;
//You can also use D3DFMT_D32, I think, but you would have to
//check support for it
This will allow the creation of a depth buffer.
Then, to activate it, use :
lpDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
//There's another value that can be used to select
//w-buffer instead of z-buffer, but I forgot which.
//Look at "render states" in the sdk to find it.
To disable writing (but with reading/culling still enabled) use :
lpDevice->SetRenderState(D3DRS_ZWRITE, false);
Although I'm not entirely sure about the "ZWRITE" part.
ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more
[edited by - ToohrVyk on January 4, 2003 10:36:00 AM]
Suppose you render an alpha-blended polygon. You don''t want to appear on top of existing geometry (especially when it''s behind a wall) so you will compare each of its pixels to the depth buffer.
However, that polygon might have some transparent pixels. These will not appear on the screen, but will still be written to the Z-buffer. that means if you render a transparent or semi-trasnparent texture, any walls behind it will have a "hole" in them, because the z-buffer has been filled with the depth of the invisible pixels.
By disabling Z-write, you cancel that "hole" effect while still using the Z-buffer to draw your sprites behind stuff.
Also, alpha-blended polygons should be drawn after everything opaque has been drawn, as in following example :
if you draw wall A, then the (transparent object), your object will be draw on top of wall A. If you then draw object B, which is in front of wall A, then all pixels will pass the depth test and will be overdrawn - including the pixels from the object, who didn''t have their own depth set.
ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more
However, that polygon might have some transparent pixels. These will not appear on the screen, but will still be written to the Z-buffer. that means if you render a transparent or semi-trasnparent texture, any walls behind it will have a "hole" in them, because the z-buffer has been filled with the depth of the invisible pixels.
By disabling Z-write, you cancel that "hole" effect while still using the Z-buffer to draw your sprites behind stuff.
Also, alpha-blended polygons should be drawn after everything opaque has been drawn, as in following example :
--------------- wall A
--------------- wall B
---- object
if you draw wall A, then the (transparent object), your object will be draw on top of wall A. If you then draw object B, which is in front of wall A, then all pixels will pass the depth test and will be overdrawn - including the pixels from the object, who didn''t have their own depth set.
ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!
Click here to learn more
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement