Trees

Published January 07, 2009
Advertisement
Today, I will to talk a little bit about covering a planet surface with trees. I actually did this work a while ago, but instead of reporting my progress on networking, I decided to change the topic. The networking infrastructure is progressing well though, and I will talk about that soon.

I had to rework the tree engine because the location of the trees depended on the tessellation of the planet. The trees were only generated around the viewers' position using the triangle mesh of the surface to determine the location of each tree. This technique is sufficient for rendering but not for collision detection. A ball rolling around on the other side of the planet, for example, should still collide with the trees there. Especially in a networked setting, the server will not tessellate the planet at all, but still has to perform collision detection.

The trick was to find an architecture that supports quick searches for the nearest trees at any point on the planet surface. The solution I came up with was to cover the entire sphere with a network of tree patches each containing a random sample of trees. This has reduced the problem to first locating the nearest patch(es) and then searching for the appropriate trees inside the patch. The tree distribution of the patches is pre-determined and optimized for quick searches. It required a lot of experimentation though in order to generate a grid of patches that spans the entire planet. The patches and the random patterns they contain ultimately only specify the longitude and latitude where a tree could potentially be located. Various noise functions still have to be evaluated in order to determine if there actually is a tree and what its final elevation will be.

I am pretty happy with the new tree engine now. Although I haven't implemented the collision code yet, I can be certain that it's possible to find any tree on the planet and detect collisions without having to triangulate the surface first. While I was at it, I also improved the transition between the detailed trees and the billboards. The blending has become much smoother and the trees now span so far into the distance that it becomes difficult to notice how they appear.



The images above show a scene that uses 25 tree patches of 6km side length which are constructed around the viewer. Of course, most of the patches aren't visible and only a few are actually drawn. Each patch contains about 6000 trees, but only the nearest 20 or so are rendered as geometries; the rest are all billboards. The images below show a lesser density of trees as it is currently implemented in the download.



Right now the trees are all the same, but Geist3D already uses an algorithm to generate this single tree. Once I get around to I will add variations according to elevations, slope etc.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement