Jump to content

Animated Trees


theShadow
 Share

Recommended Posts

I have been thinking about various ways this could be done, without having too large an impact on performance, and have also gotten a few Ideas from other games.

I recently played a game called Dear Esther, and instead of animating all of the plants, it had animated "detail" plants mixed in with non animated plants. The movement was enough that it looked like all the plants were animated. So for 0ad, animations could be assigned to a percentage of the trees, instead of all of them. It could even change which tree is being animated, so that every tree is animated, but never at the same time.

and the animations themselves could just be a rotation of the whole entity from side to side, and assigned procedurally.

Would something like this work in 0ad?

Link to comment
Share on other sites

I play a game called Mount & Blade: Warband which every piece of vegetation was static. But a DLC called Napoleonic Wars came out and brought animation to every tree and grass. I'm pretty sure animation in vegetation will not be a problem if created properly.

Or what you can do is when ever a unit of some kind interacts with a vegetation of some kind, it will become animated. Like if you watch a character walk through grass, the grass will move and then stand back up again. If somebody is chopping down a tree, the tree will rock back and forth and eventually topple over.

Edited by Sighvatr
Link to comment
Share on other sites

I wonder if 0 A.D. might benefit from using a library like ngPlant:

Df9Vd.jpg

If I understand correctly, it will actually generate a random (subject to input parameters) tree and give you a description of how each leaf and branch relate to each other. This would allow us to animate it with something like this. Later iterations could even do crazy things like animating individual leaves on high-end systems but to begin with it can just support basic low poly trees much like those already in the game:

CNCdf.pngPH6HP.jpg

(Screenshots from BlenderArtists.org)

Link to comment
Share on other sites

I wonder if 0 A.D. might benefit from using a library like ngPlant:

That kind of thing has been around for a long time. What I wonder is how easy is it to find "good" parameters? I've always seen mentioned that it's quite difficult. And more practically, can it generate trees that work well with alpha testing rather than alpha blending, which I think will be our preferred method of rendering trees (lots of little leaves/branches would look ugly)?

About animated trees: can people link or make some videos showing animated trees in other games? I tried looking up AoE3, BFME2, and only saw very slight tree animation and not clearly on every map, understandably most people show off gameplay in their videos rather than graphic effects ;) I don't own any such games.

Link to comment
Share on other sites

That kind of thing has been around for a long time. What I wonder is how easy is it to find "good" parameters? I've always seen mentioned that it's quite difficult. And more practically, can it generate trees that work well with alpha testing rather than alpha blending, which I think will be our preferred method of rendering trees (lots of little leaves/branches would look ugly)?

Tree generation has been around since the early 70's, but those early algorithms were guided more by mathematical and botanical principles (like fractals) than by visual appearance. ngPlant seems to be based on a more recent (1995) and well-established technique by Jason Weber and Joseph Penn, designed specifically for photorealism. Here is a sound bite from their paper, which was presented at SIGGRAPH:

"Our attention in designing the model was focused on allowing a general user to create trees that generally match images from books or photographs.The user needs no knowledge of botany or complex mathematical principles, only a basic understanding of geometry. We concentrated on the general structural appearance of a tree instead of the biological and biophysical principles that produced its structure."

Commercial packages like SpeedTree also seem to use some variation of this technique.

Furthermore, ngPlant comes with a "designer" application which allows you (or an artist) to model a base tree which can then be randomized within some specificed range. The model is exported as a special file which can be imported into the game using the C++ library and seeded at runtime.

So overall, it seems like a pretty controlled and professional solution.

As for alpha testing vs. alpha blending, I imagine that is entirely up to the user - the library only concerns itself with creating the basic tree model (the mesh, if you will). Texturing it would be done with whatever tools artists normally use.

Edited by zoot
Link to comment
Share on other sites

Furthermore, ngPlant comes with a "designer" application which allows you (or an artist) to model a base tree which can then be randomized within some specificed range. The model is exported as a special file which can be imported into the game using the C++ library and seeded at runtime.

Interesting, probably something for the art team to keep in mind when they focus on revamping the gaia assets, I wouldn't mind more varied tree models (y)

Thanks for the example! Maybe it's just me, but I hardly notice the subtle swaying of trees in that video? I mean when you focus on the tree and the camera isn't moving, you see it clearly, but most of the time during a game I'd be oblivious to such a minor effect. The fields were more apparent but only from being so ugly... What really stood out to me in that video were the effects surrounding naval combat, which are much lacking for 0 A.D. ;)

Link to comment
Share on other sites

Here's a more recent game that has nice trees:

Here's how I think it can be done (without even modifying the tree models):

  • there's a global wind direction/intensity shared by all trees
  • each tree vertex knows its height from the ground
  • vertices higher up sway more (in the wind direction)
  • swaying is done by adding a sin or cos wave to the vertex positions
  • maybe there's some randomness to make different trees look unique

All this can be done in the vertex shader, so the performance cost is probably minor. Same effect can be generalised to also do things like moving grass, cloth etc.

Edited by myconid
  • Like 1
Link to comment
Share on other sites

Unfortunately animating most of the existing tree models would substantially increase lag, negating the added realism of animated trees.

True, if you try to rig the models with skeletons and animate them manually (in that case the vertex transforms are done on the CPU, and that has a severe performance penalty). What I'm suggesting is to send some generic parameters to the GPU (time and wind direction/intensity) and let it do what it does best.

Would it then be possible to use the global wind direction/intensity for smoke also?

That's a different effect entirely (particles), though I suppose they could share the same wind parameters.

Edited by myconid
Link to comment
Share on other sites

This.

"Using a hierarchical form of vertex displacement, [deformation and wind modelling] can be combined in a single vertex shader, fully leveraging the power of modern GPUs to realistically animate thousands of branches and ten thousands of leaves at practically no cost."

If tree animation has to be very low priority, myconid's solution seems a lot more straightforward, of course.

Edited by zoot
Link to comment
Share on other sites

This.

"Using a hierarchical form of vertex displacement, [deformation and wind modelling] can be combined in a single vertex shader, fully leveraging the power of modern GPUs to realistically animate thousands of branches and ten thousands of leaves at practically no cost."

If tree animation has to be very low priority, myconid's solution seems a lot more straightforward, of course.

Whoa, that's really clever and looks amazing! It seems like it's using the low-frequency components of a frequency-space texture to transform the trunk and branches and the high-frequency components to transform the leaves... I only skimmed the paper, but I suppose it needs a super-fast Fourier transform library to be done efficiently?

Link to comment
Share on other sites

True, if you try to rig the models with skeletons and animate them manually (in that case the vertex transforms are done on the CPU, and that has a severe performance penalty). What I'm suggesting is to send some generic parameters to the GPU (time and wind direction/intensity) and let it do what it does best.

Interesting. Am I right in thinking something like that would take a long time to implement in order to test performance impact?

Link to comment
Share on other sites

Whoa, that's really clever and looks amazing! It seems like it's using the low-frequency components of a frequency-space texture to transform the trunk and branches and the high-frequency components to transform the leaves... I only skimmed the paper, but I suppose it needs a super-fast Fourier transform library to be done efficiently?

As far as I can tell, they just trace linear trajectories through the texture (one texture per branch level). But you'd probably need some level of detail technique to be able to animate tens of trees at once.

Link to comment
Share on other sites

Interesting. Am I right in thinking something like that would take a long time to implement in order to test performance impact?

Probably not too long.

As far as I can tell, they just trace linear trajectories through the texture (one texture per branch level). But you'd probably need some level of detail technique to be able to animate tens of trees at once.

Yeah, I figured it would be a lot simpler than I thought initially! ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...