Jump to content
  • Advertisement
Sign in to follow this  
thames

OpenGL Z-Buffer How do real games do it?

This topic is 5040 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

After playing round with opengl for a little while I have come upon a few things which puzzle me, I was hoping someone who knows better or someone from the games industry could answer my question (probably very simple). I have created a 3D Globe with accurate land mass models (countrys etc). Now the problem here is I have a sphere (acting as the globe, ok i modelled it as an oblate spheroid, but we will say sphere) and land masses which have to lie exactly on top of the surface of the sphere. Now is it possible to get the land masses to lie on top of the earth without causing graphic glitches (flickering and Z fighting for example). Questions: 1: Is is possible to do this without using glPolyGonOffset? 2: How would the games industry/someone who knows what they are doing do this? 3: What should the Zbuffer limits be set to considering the radius of the earth is about 6000km, should i work in meters? I.E 6,000,000 or km 6000 or even 10's Km 600? What would be most optimal for the Z-buffer and for the solution i require. How would you do it? Any help greatly appreciated. Thanx Tom

Share this post


Link to post
Share on other sites
Advertisement
Cheat.. cheat... and more cheating. :)

This is one of the reasons why LOD is used.. :D

Otherwise you could do this...

zbuffer:
Faraway -> Even further away
draw:
Nebulousas and so on...

zbuffer:
Near -> Faraway
draw:
Planets that are close...


I dont know if you understand what I mean, but simply change the zbuffer range depending on what you´re drawing! :)

peace!

Share this post


Link to post
Share on other sites
Render the sphere with no z-writes?

Assuming that your land masses aren't modelling below the 'surface' of the sphere...

Land masses on the far side of the sphere ought to be taken out by backface culling, and you turn z-writes on for the land masses so that they can occlude each other or themselves (overhangs, or land masses near the side of the sphere).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
move your near plane farther away.

Share this post


Link to post
Share on other sites
Thank you all for your replies.

Texturing is not an option, I have very detailed coastline data, Texture maps could never convey this kind of accuracy especially not when zoomed in(even with swapping in and out of more detailed textures, the resolution just is not there).

As for zooming in and out, the initial view is zoomed out and i can see the whole globe, but i can zoom right down into say a certain part of the uk, this is why i am keeping with vectored coastline data.

Would 10-10000 be a reasonable z-buffer? I am looking into Z-writes as i type this:D

tom

Share this post


Link to post
Share on other sites
log2(10000/10) ~= 10 bits
That should work fine with the typical 24bit hardware z-buffer

At that far-out zoom level, textures would be fine, you won't be able to see any detail nor height variation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!