Archived

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

z-buffer problem

This topic is 5397 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem when rendering my terrain, the terrain is divided into "patches" that I don''t sort or anything. Just render them as they are created. When I walk the terrain sometimes a hill behind a closer one shines trough. Looks like the z buffer can''t handle the large terrain that I have. Is there a way to make the buffer more accurate. Or should I sort the patches in back to front order? Thanks.

Share this post


Link to post
Share on other sites
I guess you can try messing around with the D3DRS_ZBIAS renderstate. The default is set to 0. How it works is that if you render 2 primitives with the exact same z value, you wont be able to predict which one will actually be in front, but if you set the ZBIAS of the first primitive to 0 and then for the second primitive set it to 1, the second primitive will be rendered in front of the first one. I dunno if that''s exactly what you were looking for but what the hell.


:::: [ Triple Buffer V2.0 ] ::::

Share this post


Link to post
Share on other sites
Thanks, I''ll look into that... Would it be faster to sort the patches. Maybe each patch contains a BSP tree to. Or should I go for the z buffer, would the speed differ alot?

Share this post


Link to post
Share on other sites
Z Buffers are not infinite . You can easily have problems with z buffer inacurracies when you don''t manage scene correctly . Make sure you set ur near clipping plane to something larger ,

Share this post


Link to post
Share on other sites
That''s due to the non-linearity of the z-buffer precision, visit this website for more details: http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Although off-topic: Z Bias is evil, don''t use it - http://tomsdxfaq.blogspot.com/ (the section: Why z Bias isn''t a good thing)

Cheers,
Muhammad Haggag

Share this post


Link to post
Share on other sites
You are sure you are actually creating a device with z and that you are actually enabling it right? Because stuff can look OK when you don''t have z enabled just because most of it happens to be drawn in the back to front order. It''s the minor glitches where background stuff gets drawn in front of foreground that tipped me off that my z wasn''t actually on.

Share this post


Link to post
Share on other sites
Yes I''m sure of that, I use a z buffer when rendering. And the terrain have the same error no matter where I stand and view it. I''ve put it aside for a momemt and I''m concentrating on the gameplay now, the graphics has taken up to much time as is. I''ll go back to it later when I have the gameplay code "finished". The graphisc I have this far is enough for now. Thansk for all the replyes.

Share this post


Link to post
Share on other sites