Jump to content
  • Advertisement

Archived

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

Roof Top Pew Wee

Z buffer accurate up close, but not far away.

This topic is 5308 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 am currently writing a GUI for my sprite engine. To make things really easy, I am going to simply adjust the Z distance of windows when they are clicked on. That is, if a window is clicked on, it is moved closest to the camera and all of the others are moved back. So the user doesn''t see a difference, the changes in position are small (everything is viewed at 100 units away, and the changest are probably going to be 1/100 of a unit or less. I could draw from back to front, but for speed purposes I am first going to draw the buttons then the text. Therefore, I need the Z-buffer to do its magic. The problem is that at regular distances, this small difference in distance isn''t enough and the Z buffer isn''t working right. If I get really close to my buttons, the z buffer works just fine, but as I move further back, it seems as if the small differences aren''t large enough and some of my windows are in front when they should be in back. Is my only solution to switch textures for every button (text and the button graphics are in different textures) or is there a way to increase the sensitivity of the z buffer so that the buttons are drawn correctly at further distances. --Vic--

Share this post


Link to post
Share on other sites
Advertisement
My understanding this is a hardware limitation.. ZBuffer are only 16 or 32bit buffers and you tend to mix your buffer with another type of Buffer like a Stencil buffer so it becomes a 15/1bit buffer. This means with small and mintue distance changes the precision of the ZBuffer just isn''t up to the task.

This is all quoted out of memory, so while I think the gist of what I''m saying is correct some small parts may be inaccurate..

Share this post


Link to post
Share on other sites
In your perspective matrix, what is the z-value of the far plane? (If you''re using D3DXMatrixPerspectiveFovLH it would be the last param). You may want to try and make that value smaller than it currently is. Also, if it is 0 or null, you will have problems.

Share this post


Link to post
Share on other sites
I''m not entirely certain, but couldn''t you just load an orthographic matrix and make the differences in your z coordinates an arbitrary size? This seems to be the effect you''re trying to emulate anyway...

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
CircleSoft: I have to keep my far plane high because I am also rendering stuff that is far away. That is, my GUI will be used as a menu in all types of games; and some games have objects that are very far away.

The near plane is about as large as it ca be before I start having problems with it.

Thunder Hawk: I don''t want to use an ortho view because I take advantage of the size differences in my games. In my engine I set the view, draw all game objects then jump directly to the GUI. If I were to use a Z Buffer, that currently wouldn''t be a problem because I sort my sprites from back to front and don''t use Z for alpha reasons on them.

I have decided that I will just make two versions of my GUI. A layered version and a fast version. The layered version will draw each button in its entirety before moving on to the rest. This will be slow, but allow for windows on top of other windows. The other version will assume that there is only one layer and it is up to the programmer to make sure that buttons don''t overlap. Here I will draw buttons in components to minimize texture changes.

Hoever, thanks for your help all. Always good to learn something new.

--Vic--

Share this post


Link to post
Share on other sites
You realize you can use an ortho matrix for your GUI and a normal matrix for everything else, right?

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites


I remember reading in an Andre LaMothe book that Z-buffers are inaccurate at large distances, but W-buffers are not.

I''ve never used a W-buffer so I can''t tell you much beyond that.

Oh, and the book was about the DirectX8 era, so it should be relatively current.

~Sparticus

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!