Original Post
<< WARNING: Long! >>
Introduction:
As some of you might have noticed from other threads on this forum, I am developing a planetary-scale 3D graphics engine for our game, "The Keepers" (link in my signature). The game will involve the simulation of an entire planet. On the engine's side, this will involve procedural generation of terrain features (including features such as vegetation coverage, rivers, etcetera), real-time deformation of the terrain, simulation of water (seas and oceans in partcular), weather simulation, and rendering of the terrain, plants, water, and atmosphere based on the generated data. The engine is currently in early stages of development, and the planetary simulation/rendering part of the engine is in design stages.
Following my own interest in the area, and the interest expressed in this recent thread, I have decided to initiate a series of threads, each focusing on a different aspect of the realistic simulation and rendering of a virtual planet. In the beginning of each thread, I will provide a references section with links to previous threads in the series and other threads, articles, papers, and so on, which are relevant to that particlar thread. This series is intended to serve as a reference for everyone developing a terrain engine, particularly those interested in procedural worlds, contineuous ("infinite") terrain, and/or planetary scale engines (somewhat like this famous sky thread). The success of this series depends entirely on your participation and cooperation. Note: I suppose this would be a good time to ask everyone who decides to participate to stick to the topic of the corresponding thread.
PS: Did you notice the icon I used for this thread? Get it?
References: The Virtual Terrain Project [website] Infinite world. tiling maps [gamedev thread] - includes basis for geo-quadtree idea (see below). Spherical Trees [gamedev thread] Geomipmaping [paper] Octrees [tutorial] Adaptive Binary Trees [gamedev thread] (some posts down the thread) Quaternions [article] Anyone knows some good links regarding quadtrees (I don't need them myself, but other people that read this thread might need them)? Some more links regarding octrees are also welcome (as well as any other link you think is relevant).
Ok. Let's begin. As stated by the title, this thread is about the basics of planet rendering, which means the following:
The circle represents our planet, with its center being the origin. The blue line represent the D(A,B,C) vector, and the red line represents the plane. Everything within the white region is considered to be on the inner side of the plane , and everything in the gray region is considered to be on the outer side of the plane .
As before, other ideas are welcome.
Some basic algorithms
Horizon culling:
The first thing to do for horizon culling is to compute the angle between the camera and any one object. Any object that is farther than a known angle theta from the camera can be culled away. By calculating the angle between the camera and the vertices of each node of our geo-quadtree, heirarchial horizon culling can be acheived. The angle theta is a direct function of the altitude of the camera, and can be easily precalculated and stored in a LUT. It is imporatnt to note, that since some objects (such as high mountains) can be seen beyond the horizon, theta should be larger than the angle from the camera to the horizon:
As can be seen from the image, theta is given by: theta = arccos(R/h) + arccos(R/H), where R is the radius of the planet, not including the atmosphere (i.e. the minimum surface altitude, measured from the center of the planet), h is the altitude of the camera (measured from the center of the planet), and H is the maximum altitude that an object can reach (again, measured from the center).
Frustum culling:
Frustum culling may be done in one of two ways. The first one is to convert the whatever-position-representation of the geo-quadtree nodes' vertices to conventional cartesian coordinates, and proceed as normal. The other way is to take advantage of the way we represent our planes:
The gray area represents the geo-quadtree node we are testing. The culling against each of the frustum's planes is done by calculating two treshold values for the plane's D parameter, using the formula D=R*cos(theta), where R is the minimum/maximum radius of the volume we're testing, and theta is the angle between the plane's (A,B,C) vector and the coorsponding side of the volume (marked in blue in the image). If the plane's actual D is lower than the minimum treshold, than the volume is entirely on the outer side of the plane. If the plane's actual D is higher than the maximum treshold, than the volume is entirely on the inner side of the plane. Otherwise, the plane intersects the volume.
I am not sure which of the two methods is more efficient, and which optimization are possible with each one... As always, comments, suggetions, etcetera are welcome.
Occlusion culling:
I am not yet sure exactly how to acheive this, but a possible way may involve the culling of geo-octree nodes against other geo-octree nodes that are known to be underground.
LOD:
This can be done in one of many different methods, but geomipmamping seems a good choice here, with the adjustment that we work with traingular regions instead of rectangular ones:
The red lines represent the pach boundaries. An inportant issue to consider here, is how would one handle large level-of-detail changes, e.g. to represent the height data of a river shore, which runs though a large relatively flat area...
Let the discussions begin!
Michael K.,
Designer and Graphics Programmer of "The Keepers"
We come in peace... surrender or die! [edited by - technobot on April 4, 2003 7:08:42 PM]
References: The Virtual Terrain Project [website] Infinite world. tiling maps [gamedev thread] - includes basis for geo-quadtree idea (see below). Spherical Trees [gamedev thread] Geomipmaping [paper] Octrees [tutorial] Adaptive Binary Trees [gamedev thread] (some posts down the thread) Quaternions [article] Anyone knows some good links regarding quadtrees (I don't need them myself, but other people that read this thread might need them)? Some more links regarding octrees are also welcome (as well as any other link you think is relevant).
Ok. Let's begin. As stated by the title, this thread is about the basics of planet rendering, which means the following:
- The concepts of continuous and semi-continuous data representation .
- Basic data structures and representation. Note that additional data structures may be discussed in following threads, if necessary.
- Basic algorthims (LOD, frustum culling, etc.), in the context of that data representation.
- The nodes of the tree would represent triangular areas, rather than rectangular areas as in a conventional quadtree.
- While the root node would represent the entire planet, as you would probably do with an ordinary quadtree, its four child nodes would represent the four faces of a trangular piramid which is the basis for the geosphere, as suggested by TerranFury in this thread.
- The nodes would subdivide as decribed in the same thread.
- Each node would store pointers to its three neighbours, in addition to the regular child (and possibly parent) pointers. This is crucial for the continuity of the data representation.
- Each node would have a minimum and maximum altitude.
- How to handle neighbor pointers between nodes of different subdivision levels?
- How to represent the volume of each node? Positions of the corners? Some other method?
- Other?
- Continuous
- Easy to find angle between two positions (the more efficient, the better - this is important for horizon culling, which is described below)
- Easy to work with when it comes to physics. For example, if polar coordinates didn't have their other problems, they could have been used directly in physics, since on the local scale the two are almost the same (since the angles involved are extremely small)
The circle represents our planet, with its center being the origin. The blue line represent the D(A,B,C) vector, and the red line represents the plane. Everything within the white region is considered to be on the inner side of the plane , and everything in the gray region is considered to be on the outer side of the plane .
As before, other ideas are welcome.
Some basic algorithms
Horizon culling:
The first thing to do for horizon culling is to compute the angle between the camera and any one object. Any object that is farther than a known angle theta from the camera can be culled away. By calculating the angle between the camera and the vertices of each node of our geo-quadtree, heirarchial horizon culling can be acheived. The angle theta is a direct function of the altitude of the camera, and can be easily precalculated and stored in a LUT. It is imporatnt to note, that since some objects (such as high mountains) can be seen beyond the horizon, theta should be larger than the angle from the camera to the horizon:
As can be seen from the image, theta is given by: theta = arccos(R/h) + arccos(R/H), where R is the radius of the planet, not including the atmosphere (i.e. the minimum surface altitude, measured from the center of the planet), h is the altitude of the camera (measured from the center of the planet), and H is the maximum altitude that an object can reach (again, measured from the center).
Frustum culling:
Frustum culling may be done in one of two ways. The first one is to convert the whatever-position-representation of the geo-quadtree nodes' vertices to conventional cartesian coordinates, and proceed as normal. The other way is to take advantage of the way we represent our planes:
The gray area represents the geo-quadtree node we are testing. The culling against each of the frustum's planes is done by calculating two treshold values for the plane's D parameter, using the formula D=R*cos(theta), where R is the minimum/maximum radius of the volume we're testing, and theta is the angle between the plane's (A,B,C) vector and the coorsponding side of the volume (marked in blue in the image). If the plane's actual D is lower than the minimum treshold, than the volume is entirely on the outer side of the plane. If the plane's actual D is higher than the maximum treshold, than the volume is entirely on the inner side of the plane. Otherwise, the plane intersects the volume.
I am not sure which of the two methods is more efficient, and which optimization are possible with each one... As always, comments, suggetions, etcetera are welcome.
Occlusion culling:
I am not yet sure exactly how to acheive this, but a possible way may involve the culling of geo-octree nodes against other geo-octree nodes that are known to be underground.
LOD:
This can be done in one of many different methods, but geomipmamping seems a good choice here, with the adjustment that we work with traingular regions instead of rectangular ones:
The red lines represent the pach boundaries. An inportant issue to consider here, is how would one handle large level-of-detail changes, e.g. to represent the height data of a river shore, which runs though a large relatively flat area...
Let the discussions begin! We come in peace... surrender or die! [edited by - technobot on April 4, 2003 7:08:42 PM]
