Skip to main content
gamedev.net
🔒 Locked

Tree rendering

Started by Aqua Costa Mar 20, 2011 at 5:04 PM 4 replies 3.1k views
Original Post
Aqua Costa
Aqua Costa
I would like to know how are trees rendered... especially the leaves...

The trunk is a simple mesh right?
But what about the leaves? Are they a point list and converted in quads in the geometry shader? or also simple meshes?

Which are the recent techniques to render trees?
BattleMetalChris
BattleMetalChris
Mostly the trunk is geometry and the leaves/smaller branches are textures with alpha-transparency (either billboards - I know Just Cause 2 does it this way - or just more geometry in the appropriate shape). How detailed you make your geometry before it switches to transparent textures depends on how close you need to get to the tree and how convincing your model of the trunk/branches is.If the trees are further than 50-100 metres or so away then you can get away with having the entire tree as just a single billboard quad with a transparent texture.
Vilem Otte
Vilem Otte
Kevin Boulanger did some great jobs on tree rendering http://www.kevinboul....net/trees.html

I'm currently using pretty high detailed trunk and branches (to show all the necessary details) with every leaf = instance of polygon ... it is quite fast (262k leafs are cool also ... but a footprint of few megs per tree is quite high). Well I used this technique for a demo showing high quality trees, in "real" applications I use similar technology to speed tree, in distance impositors, as you get closer tree gets 3D (trunk, branches and clusters of leaves), leaf plates are billboarded geometry (quads) with texture of cluster of leaves. If you get really close to tree, then I render every leaf as instance of quad (with sample-alpha-to-coverage). E.g. still the first technique, but with level-of-detail applied, as it is really necessary. Image here:

[attachment=1714:GameAccessScn01 - Tree.PNG]
Aqua Costa
Aqua Costa

Kevin Boulanger did some great jobs on tree rendering http://www.kevinboul....net/trees.html

I'm currently using pretty high detailed trunk and branches (to show all the necessary details) with every leaf = instance of polygon ... it is quite fast (262k leafs are cool also ... but a footprint of few megs per tree is quite high). Well I used this technique for a demo showing high quality trees, in "real" applications I use similar technology to speed tree, in distance impositors, as you get closer tree gets 3D (trunk, branches and clusters of leaves), leaf plates are billboarded geometry (quads) with texture of cluster of leaves. If you get really close to tree, then I render every leaf as instance of quad (with sample-alpha-to-coverage). E.g. still the first technique, but with level-of-detail applied, as it is really necessary. Image here:

[attachment=1714:GameAccessScn01 - Tree.PNG]


So you use instancing to draw the leaves? Sounds good.

The trees in your demo look great! Can you tell me where you find 3d models of trees? Or can you share some of yours with me?
Vilem Otte
Vilem Otte
I've written my own generator - small one. Creating one is pretty straightforward and simple, You begin with trunk and iteratively grow it (and spawn braches points), it grows as cylinder (of course deformed at every "level" (level means every "floor" of the cylinder) - translated and scaled) and on top you cap it (or make cone out of it). Then you do the same with branches (and branches branches, and so on). Voila, you have a tree, with no leaves. so you spawn at branches ends (and branches branches ends, etc.) points, where to place leaves, and these points are translation source for instancing, rotation is always done in more-less random way (because no one notices if the leaf is upside down), also it could be done the way, that resulting leaf would direct out of branch (e.g. like in real), difference is unnoticeable though and random-rotation is way simplier to implement.

Thats it, pretty straightforward and simple to write.

I would send generator application, but it is very messy for now, although I'm recently working on tree generating algorithms (more specifically, it is needed for one of my projects), so if it is not so urgent I might share it in future (and during the development). I'll probably release it for free in the end also (with pretty large database of trees, about a dozen of tree-types is planned right now) ... it might be smaller alternative for speedtree, but for realtime graphics.
Aqua Costa
Aqua Costa

I've written my own generator - small one. Creating one is pretty straightforward and simple, You begin with trunk and iteratively grow it (and spawn braches points), it grows as cylinder (of course deformed at every "level" (level means every "floor" of the cylinder) - translated and scaled) and on top you cap it (or make cone out of it). Then you do the same with branches (and branches branches, and so on). Voila, you have a tree, with no leaves. so you spawn at branches ends (and branches branches ends, etc.) points, where to place leaves, and these points are translation source for instancing, rotation is always done in more-less random way (because no one notices if the leaf is upside down), also it could be done the way, that resulting leaf would direct out of branch (e.g. like in real), difference is unnoticeable though and random-rotation is way simplier to implement.

Thats it, pretty straightforward and simple to write.

I would send generator application, but it is very messy for now, although I'm recently working on tree generating algorithms (more specifically, it is needed for one of my projects), so if it is not so urgent I might share it in future (and during the development). I'll probably release it for free in the end also (with pretty large database of trees, about a dozen of tree-types is planned right now) ... it might be smaller alternative for speedtree, but for realtime graphics.


Sounds good. I might try to create a tree generator after I finish implementing some new features on my engine...

Make a post in your blog about your tree generator when you update it and good luck!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.