Archived

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

ylegoc

help: don't manage to write in the z-buffer

Recommended Posts

I need to write in the depth buffer and I use directx 8.1. I tried to do this by hardware but my graphic card seems not to allow this (I cannot set the D3DFMT_D16_LOCKABLE flag). I tried by software but it seems that the changes I make in the depth buffer have no effect on the objects of the scene which still appear whereas I set 0 for all value in the depth buffer. And when I check it at the end of the scene it contains the 0 values(I disabled the depth buffer writing). Has anybody already managed to write in the z-buffer, and how?

Share this post


Link to post
Share on other sites
Remember that some chips don''t even have Z buffers to do their hidden surface removal. And that most do things like compressed buffers etc which is why they won''t expose the lockable format.

The most compatible way is to render invisible geometry onto the screen - simply set the alpha blending mode to ZERO:ONE and render the geometry - due to the blend mode, no colour will be written, but the Z/depth buffer will be.

On top of that you can rely on the fact thar if a pixel fails alpha-test, it won''t get written to the screen OR depth buffer, this can be useful to reduce the number of "depth write" polygons you render.

Also once the depth buffer is written, do remember that you can preserve it over many frames by simply not clearing it.


Alternative to that you may be able to munge alpha test and shaders to provide arbitrary pseudo-Z writes if you''re trying to do something like nailboards.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
ok, I have already thought about a pre-calculus of the scene in order to obtain a z-buffer and then to display the objects of the scene, but it is impossible because I have a pre-calculated z-buffer that cannot be calculated by a 3D representation (simplified for example). I have values stored in an array and these values must replace those stored in the z-buffer.

Share this post


Link to post
Share on other sites
AFAIK, unfortunately pixel sized triangles is the only available solution (apart from ps1.4 pixel shaders) which will be compatible on all hardware and driver combinations.

ISTR this is the method the PowerVR Kyro drivers use to "emulate" lockable Z buffers.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites