Game Development Community

dev|Pro Game Development Curriculum

Trees, lot of trees.

by Claude-Alain Fournier · 01/26/2007 (1:18 pm) · 22 comments

My first blog ;)

What is this post all about ? Trees, lot of trees and performance.

i173.photobucket.com/albums/w67/cafournier/Tree/tree_rep_screenshot_2.jpg
More screenshots and video here : TreeReplicator

I am the Lead programmer for Adellion a MMORPG in the making. I don't want to discuss this project here, that's not the goal of this post, but discuss a little part of the project I am currently working on. In Adellion we have a huge island with many different terrain type and tree and vegetations. So my current goal is to be able to lay down forests, but not just a few trees, no, I want forest by the Kilometer. I waited long enough for the forest pack, it was promising and in fact made me postpone my work in that area in the hope that I would see the forest pack released one day, but I start to get impatient.

So to make a long story short, here is what I success I have so far.

You can see on Youtube a few videos I took during the development.

Last video is bad quality on Youtube, try this link : TreeReplicator

The idea is to have billboards of tree replaced by 3d models at a certain distance. Now I did not want to rewrite the whole engine so I took apart fxFoliageReplicator and fxShapeReplicator and kind of merged them. This gave some mixed results, while I was able to have 1000's of tree in a forest, the performance where not that good and the limit for number of tree was quickly attained.

Then I realised that I took it the wrong way, I was using fxShapeReplicator to create the trees and attached a billboard to each, this proved to be a bad idea, the scene renderer has to go thru 1000's of shapes at each pass. Using fxShapeReplicator I loose the ability to use quadtree system to render foliages as buffers, which is realy good for performance.

So I rewrote the whole and used fxFoliageReplicator as a base. Now I can benefit of the quadtree sorting and buffer render. One of my video show 200'000 trees over a 4km x 4km area. It's impressive to see in game. Latest video show the result with integration of 3d tree models, in the last video I show the same forest with 100'000 trees, I made new billboards as I had to change the tree I was using for testing, the pine tree and banana trees I used previously where too high in polys (~2500) the new trees are from the RST environment pack, swamp area, they are very nice looking and low in polys (~300). So in the last video you can clearly see the change from billboard to 3d model, I left a color difference so it's well visible.

For the 3d model, I use a little trick, I don't create one tree model per tree in the forest (imagine 100'000 tsStatic ;) ) but about 50 for each tree type, and store them in a pool, where I take them as needed. When not rendered a shape is taken out of the scene, and added only when required.

So it's not yet perfect, far from it, but still it's a good start. On the performance side I get around 15fps on a non optimised compile. And there are still lot of improvements for performance.

Once I have something good enough, I plan to release this as a ressource. Be aware that I work on TGEA (TSE) only so TGE users will have to port it themself.
Page«First 1 2 Next»
#21
01/27/2007 (2:34 pm)
The fading idea is good but that would be realy only feasible for single player. For a multiplayer game and specially with NPC and mobs running around you need some sort of collision detection. If you see another player character go through a tree that would look weird.

@Jason, the trees are based on a seed that used to pickup the random positions, the seed number and forest information is networked so every client get the same, then with the seed the random routine always return the exact same numbers, that mean everytime you start the game, you find your trees at the exact same position even that it's done randomly and on the fly. Same will apply to all clients, server only need to distribute the seed number to all clients, and they generate forest which will look the same.
#22
01/27/2007 (10:34 pm)
Claude,

Take a look at Dungeon Siege, if you can find a copy of the original (number 2 is now out and I don't know if they used the same convention, as I have not played it), I do not recall seeing anything that looked strange like enemies moving through visible trees, I think that would have jumped out at me.

I will see if I can locate my copy, install it and take a look.
Page«First 1 2 Next»