z-buffer problem

Started by
6 comments, last by Unknown 21 years, 1 month ago
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.
Advertisement
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 ] ::::
[size=2]aliak.net
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?

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 ,
Thank you all :)
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

great... this will hopefully give me some more knowledge about how z buffers work. thanks

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.
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.

This topic is closed to new replies.

Advertisement