Sign in to follow this  
thames

OpenGL Z-Buffer How do real games do it?

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
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
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
No really. Texture it. As you zoom in you need to view less and so you can switch to different textures or models but from far away, you're rendering too much geometry.

Honestly, I highly doubt adding geometry could come near the visual helpfulness as textures anyway.

Share this post


Link to post
Share on other sites
Hey,

There are a lot of options here, first of course is to use something like the stencil buffer to eliminate z-fighting (also a Z range of 1 to 5 with an earth 2 across is exactly the same as from 100 to 500 with an earth 200 across, it all is scaled and biased to a number 0 to 1). You should consider bump-mapping and parallax mapping when the user is zoomed out, then switch to real models and increase their geometric complexity (and texture detail) as the user zooms in. Drawing the whole world well (and making it fast) is a small project in itself, but it certainly can be done well :).

Hope this helps, ~SPH

[Edited by - ShmeeBegek on December 4, 2004 10:23:24 AM]

Share this post


Link to post
Share on other sites
If I understand you correctly, the land geometry overlay doesn't have any significant altitude over the sphere/water surface, but it does have enough coastline detail that you don't want to just use a texture.

My first suggestion for an easy fix would be the same as Superpig's, ie. disable depth test. Without overhangs, you don't need a depth test for the land either. Just ensure that you draw the water first, and enable back face culling.

However if I was doing this myself, I'd probably just include the water surface as part of the mesh, rather than drawing an entire sphere first.

Share this post


Link to post
Share on other sites

The idea of diabling the depth test doesn't seem like a good one to me assuming that this is a perspective rendition, there may not be overhangs in spherical space but there certainly could be when projected onto the screen, and artifacts could appear near the edges of the sphere.

Eliminating the Z-Fighting and changing your method are the best two options IMHO, but do prove me wrong!

~SPH

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this