• Advertisement

Archived

This topic is now archived and is closed to further replies.

Tree animation

This topic is 5148 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I need some help with implementing tree animation. Actually, the problem is with animating the foliage. The leaves are rendered as textered quads that are not billboards. I would like them to somehow wave in wind. Any ideas? I really need help with this problem, thanks!

Share this post


Link to post
Share on other sites
Advertisement
What are you using to model the trees? You could simply create some keyframe animations of the tree model being swayed in the wind.

Or you could go through each triangle or vertice in the model and flag those that are being textured with the leaf texture. Then have some loop that goes through and adds some value to each vertice, meaning some vector that represents the direction of the wind. So each frame the vertices are ''pushed'' by the wind vector, and then you could have the wind vector translate back and forth between some values.

For instance, let''s say the max strength of the wind is 1, then you would have the wind vector go from -1 to 1. So each from, update the wind vector values by about 0.1 or so, and add this vector to each vertice in the tree. This way each vertex in the tree will be pushed one way and then the other when the wind vector becomes negative.

Does this help?

Share this post


Link to post
Share on other sites
You could do something like bone animation using 2 weights (or 1 weight, where weight 2 = 1.0 - weight1). You have a hierarchy of movements (trunk, branch, subbranch, leaf). Each movement is relative to the parent, such that if a branch moves, it moves the subbranches and leaves. Each movement is weighted such that near the trunk, mostly trunk movment is used, not branch movement. Further along the branch, the branch matrix is used without the trunk matrix.

A wind algorithm could sway the branches based on wind speed and direction. If a branch is parallel to the wind, it won''t move. If a branch is perpendicular to the wind, it will. The branches would also attempt to bend back to normal. In the absence of wind, the branches would accelerate towards normal, overshoot, accelerate back towards normal. The acceleration must be designed such that it WILL eventually settle. How long settling takes depends on the variety of tree. Your algorithm might also support the pull on a leaf affecting the pull of branches.

Lots of different ways to approach this.

Share this post


Link to post
Share on other sites
I''m talking out my arse here, and have never tried this, but:

You could use a spring model to represent the tree, it''s branches, and it''s leaves. It wouldn''t neccesarily have to be very complicated.

To fake some wind you could do a million different thing. Move a big ''sheet'' through you world, and when it intersects a spring model have it apply a force equal to the normal of the face hitting the spring.. Multiple sheets in succession would give you gusts of wind.

Will

Share this post


Link to post
Share on other sites
It depends how much CPU/GPU time you want it to waste.. but you can actually simulate it in a number of ways. I implemented it as a graph theoretic tree.. then you could call render on the root.. and each branch would draw itself (they only knew relative alignment compared to parent). In the same way.. there was a physics sim (a very rough and ready particle system) which you fed the wind force to the root.. and it was transformed on it''s way, relative to each branch, providing correct behaviour (almost with hardwired gravity) all the way to the leaves. In essence the scheme was very simple.. but it provided for very pleasing movement (from leaf flutter... to whole tree bending in hurricane). It is however quite expensive to render (well, on my target system spec)... with about 2000 parts (be they branches or leaves) it runs at about 30fps on a 1ghz with radeon 7500. worth noting however, is that with no rendering taking place.. but physics being calculated.. it ran at 150fps. I suspect the physics calculations could be defered to the GPU via vertex shaders.. but they are not hardware supported on this system, so I didn''t bother. I''m implemented it as part of a screen saver I was working on btw... so speed was not crucial. The design is such that instantiation of a CTree object "grows" a tree (or specified size)... so the user never even sees the internal representation.. they just feed it a force, and call render. If you are concerned about the accuracy/stability of the particle system simulation.. it was not a problem. An euler integrator (only tracking location/velocity) provided adequete stability at a huge range of wind forces (ie.. ones strong enough that the tree was horizontal). In fact.. the small degree of numerical instability, lead the leaves to flutter better. In fact, when I tried to switch to a proper lagrangian constrained motion scheme, with runge-kutta integrator.. I didn''t find the motion very pleasing at all. The graph theoretic design, also means that one could implement the tree growing over time with relative ease.

Share this post


Link to post
Share on other sites
Thanks for the replies guys. Yesterday I tried the billboard approach and it didn''t look as crappy as I expected The advantage of not having 50k polys per tree is perhaps worth it. About the animation: Do you think it would be possible to have two sets of foliage geometry, the first in its original position and the second in the full wind position and tween them in a vertex shader? All I would have to do then is to recompute the second set of geometry each time the direction/speed of the wind changes significantly.

Share this post


Link to post
Share on other sites
I would suggest that it wouldn''t look great. Before I made my leaves individually animated... there was a rather unnatural look to the whole scheme. That having been said, some sort of tweening method might give acceptable results in your situation. For me in any case, I was after realistic looking movement more than anything else. If you want a good compromise, you could probably make a tree out of say 15 sections. These would form a graph theoretic tree (as in my scheme) but the "leaf" nodes would not be leaves as in my simulation, but would be a larger branch, complete with child branches/leaves etc. If the leaf parts overlap when they sway slowly (I recommend you perturb the force as it propogates up the tree.. otherwise it tends to move too uniformly) you make get a more pleasing look. I guess it depends what sort of trees you are after. if you are happy with the sort demonstrated in that article (ie realisticly textured... but lacking in physics/complex branching structure) then that could be ideal for you. They are clearly very fast to evaluate (physics wise) and render. If you require a little more intircacy in your simulation.. then a hybrid scheme (something between that method, and what I proposed) might be nice. If you plan on having many trees however.. and if you go with your tweening method.. be VERY sure they don''t all end up moving in a syncronised manner. This can looks ridiculous (as my early tests proved). If you hunt in google, there are several other quite nice algorithms people have come up with. Good luck .

Share this post


Link to post
Share on other sites
I expect to have large forests so any *complex* animation is out of question. Basically, to have good framerates, I need to submit as large batches of geometry to the GPU as possible. Therefore splitting each tree to many parts isn''t a good choice for me.

Share this post


Link to post
Share on other sites
quote:
Original post by mikiex
get hold of the speedtree demo for inspiration


I know these demos. One thing I don''t like about it are the lower LODs of the trees.

Share this post


Link to post
Share on other sites
the faked billboards they use for the grass and tree leaves are horrible IMHO...
just go under a tree, look around, and as you rotate the view, you''ll see those billboards penetrating branches :|
also, some of these billboards don''t hold to anything and just swing around in the air... :|

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Tree movement is a classic application of modal analysis (the first modal analysis paper in graphics, by Stam, was on trees). However Stam''s own implementation looked terrible.

Share this post


Link to post
Share on other sites

  • Advertisement