
Planetary Scale Terrain
Posted Wednesday, 1 October, 2008 - 20:54 by nythrix inHi!
Has anyone experience in planetary scale terrain rendering?
My problem is float precision. Earth's semi major axis is 6378137m which is 7 digits. On top of that I need at least centimeter precision on the surface so that's another 2 digits. 9 valid digits just don't fit into float. For example the camera jumps wildly instead of orbiting smoothly around the planet (as for double).
What do you suggest apart from using double?
P.S.: I couldn't find a good place for this post, so I dropped it here. Feel free to move it around.


Comments
Re: Planetary Scale Terrain
You are fighting 2 problems both of which I have imperfect answers to.
1) The loss of precision in your floats. I deal with this by internally tracking all locations in vectors made from decimal types. I then covert all locations into a difference from a point of view of the observer and cast the results down to floats. From these I build my modelView matricies.
To simplify consider this example...
observer location x=0, y=0, z=1,000,000,000,000,000,000,000,000
object location x=0, y=0, z=1,000,000,000,000,000,000,000,005.02
If you convert these z coordinates to a float, they would both be equal, but if you subtract them first and consider your observer as the origin the the coordinates look like this...
observer location x=0, y=0, z=0
object location x=0, y=0, z=5.02
This can easily fit into a float.
You still lose precision as you view things that are very far away, but they don't tend to "jump" on your screen due to perspective.
2) Planetary rendering. High detail when close transitioning to low detail when in orbit. I solve this by dynamically generating the planet mesh in real-time based on the observer's location.
http://www.robotechmmo.com/index.php?topic=screenshots
If you look at some of the screenshots from around Feb 2007, you can see the windows client which has the most complete implementation of the above described techniques. It allows for smooth transitions from the ground to orbit without "zoning".
Re: Planetary Scale Terrain
Hi and thanks for the response.
[precision loss]
This is an interesting technique. Basically, you're faking camera-to-object translation by sending the deltas for rendering, am I right? I'm a bit concerned about speed, though. Do you recalculate all the vertices?
[LOD]
I'm already playing with terrain LOD even though the engine will never face ingame high orbit view. I'm going to restrict my editor camera below 20km and game camera goes even lower. I'm just testing extreme cases right now.
Very cool project you're building there Kamujin!
Re: Planetary Scale Terrain
[precision loss]
No you don't have to do it per vertex. Your vertices should be in model space. You can compute your modelViewProjection matrix with the "observer centric" method described above without any significant impact to render time. In short, you can take the vertices from model space all the way into observer centric view space, then into projection space with a single well constructed matrix.
Its kind of like relativity. For example, the origin of my solar system would logically be the center of the sun. Assume my observer at standing on Pluto. When its time to compute my modelViewProject matrix, I compute the location of everything as if it the origin were my observer standing on Pluto. This leaves the highest amount of precision available to objects that are near my observer standing on Pluto. The increased workload is like 3 decimal subtractions and 3 decimal to float type casts per model (not per vertex).
There is also a space compression technique that I use to reduce z-fighting.
Maybe some code will help. Here is my DecVector3 structure.
Re: Planetary Scale Terrain
There you go! Code worth a million words :-D
Right now I'm rewriting my terrain code. Since the planet (or it's visible half) will never be rendered at once I should be able to fit into float after all.
Thank you for your time!
Re: Planetary Scale Terrain
hi, nythrix
http://code.google.com/p/renderterrain. maybe helpful
would you contribut source code?
hshutao
Re: Planetary Scale Terrain
would you contribut source code?
I'm afraid my terrain code looks as good as my bedroom right now. None of them can be shown to the public. My real life takes up too much time so please be patient.
You can have a look here for details on what I'm implementing.