If you don't want to read my short novel below, just buy the book!
As a lifelong amateur astronomer and software engineer, with 3D graphics simulation being my hobby, I always wanted to write a 3D simulation allowing a user to fly around the solar system and buzz the canyons of our rocky planets or navigate through the rings of Saturn.
But even with many years of OpenGL programming, I had no idea how to achieve what I have conceived in my head (check out the Outtera website to get an idea, absolutely stunning!).
3D Engine Design for Virtual Globes is just what I needed. The book presents a complete API for rendering globes, massive amounts of terrain, vector data (GIS) and the techniques required for a seamless and smooth transition from orbit down to your front yard.
The API is called OpenGlobe and it is built on top of OpenTK which facilitates writing OpenGL programs with C#/.Net (yeah!).
To end on a good note, I’ll mention the con’s first:
I can’t praise this book enough for finally making this topic clear to me. With that said, be forewarned: The OpenGlobe API is not a plug-n-play solar system/planetary simulator. Literally all of the example programs demonstrate their purpose in isolation to the example. For example, the globe rendering examples render a single globe in its own space. If you want to render several planets, you will need to rip out the globe rendering example code and roll your own multi-planet solar system.
This also means there is no scene management. But the authors do gloss over multi-frustum rendering for large volume scenes that cover distances from one meter to 100,000,000 meters or more.
A bit frustrating is how some techniques are covered in detail and at the end you are told “but there is a better way…” Immediately following, most of the “better ways” are covered but in a lot of cases you are instead referred to a source in the bibliography (which is the best graphics bibliography I have ever seen!).
Now the good stuff!
An Abstract Rendering Engine
OpenGL programmers know how difficult and error prone managing the OpenGL state can be. This book begins by presenting an abstract render engine and implements it in OpenGL. This render engine hides the complexity of managing OpenGL state. You don’t need to remember to restore the previous states after you draw an object. The render engine shadows the OpenGL state and takes care of the details for you.
Writing OpenGL code with this rendering engine is an absolute joy!
Note that the OpenGL core profile is used in the engine. This means you need to write your own vertex and fragment shaders to put anything on the screen. There are myriad shaders provided with all of the samples. If you don’t know GLSL, you might as well pick up a copy of the orange book (OpenGL Shading Language) as well.
Several methods for rendering globes are presented with projects that demonstrate each. The pro’s and con’s are clearly explained. Picking the method you’ll want to use is the hardest decision.
The last 4 chapters of the book concentrate on terrain rendering techniques. If you have ever wondered how a game or simulation renders hundreds of miles of detailed terrain, all is revealed here. Especially enlightening are the web services that retrieve data and terrain tiles from NASA and ESRI servers as you move through your scene.
There are two chapters that cover precision and the problems caused by floating point round off errors and artifacts caused by depth buffer z-fighting. These issues are addressed in detail with several different solutions (yes, the code for the solutions is provided!).
Part three of the book has two chapters covering vector data which really boils down to drawing lines and polygons. Where globe and terrain rendering is concerned, this means maps. If you have ever done any GIS programming (I worked on GIS software projects at UPS for 8 years) you will love the ESRI Shapefile reader/renderer.
Billboards are covered and a great texture atlas is provided in the API. The texture atlas makes rendering billboards a breeze.
Yes, you can write multi-threaded OpenGL code. And this chapter shows you how. The appendix covers a message queue used heavily in a multi-threaded program.
Lastly, I have exchanged several emails with the authors. They are prompt and very helpful in their replies. As busy as they are, the individual attention is greatly appreciated. They are currently working on a WebGL Virtual Globe and Map Engine called “Cesium.” Check it out!