Animation method for grass and trees explained.

Animation method for grass, trees and other flora. (cross-posted at blender.org)

Two of the things I’ve always wanted to see done in Blender wer a nicely moving tree in the wind, and a field of grass likewise perturbed. Up until now there hasn’t been a great way to do it. Well, there still is a great way to do it, but the tools finally all exist in Blender. Any Orange Project animators who want to do something like this in the Project can bug the developers about making this process easier. At the end of this post, I’ll give a little explanation of how that could be done.

First, lets use a tree for and example. It would be awesome to make a tree with L-system, or even Arboro, apply softbodies to it, then hit it with the wind. Of course, you’d get bending tree limbs, etc., not to mention the fact that it’s waaaay to many verts to efficiently calculate. It probably wouldn’t even work. The same for a field of grass - the geometry is too complex.

So what you do is this: once you have your tree built, you make a simple edge skeleton that follows the branch structure. Then, you do softbodies/wind on this simplified skeleton until it looks good. Example (click for quicktime motion):

http://www.harkyman.com/images/skeletonsample.gif

In the next step, you attach empties via vertex parenting to each vertex in the skeleton. Run (or bake) your softbody simulation. The Empties now move with the skeleton. Then, you take your final tree mesh, and use hooks to attach the relevant sections of the tree to the relevant Empties, with some overlap for smoothest results.

Does it work? Yes.

Bad bad, lazy example:

http://www.harkyman.com/images/treedeformed.gif

That sphere in the middle of the tree (it’s an uh… apple or fruit or something) is being deformed via hooks attached to the empties which are attached in turn to the softbody solution for the tree skeleton.

But, you say, oh Orange Project or other interested person, that’s a gigantic pain in the rear, and with any kind of complex tree, you’d be making empties and hooks all day!

You’re right. And that’s why we need to bug the coders while they’re working on all of this animation stuff. Clearly, the building blocks for an animation system like this are already there. We just need a better way to get to it.

Here’s what would work: a Cage deformer. You make one mesh a deformation parent of another. Parent mesh deforms child mesh based on vertex group affinity. It’s as simple as that. The cool thing is that scripts like l-system (or Fiber for that matter) could be modified, and rather minorly I think, to generate these vertex groups and skeletons during the creation of the mesh.

So in an advanced animation world for Blender, you’d run Fiber (or L-system), do a softbody wind solution for the simplified skeleton (or guide fibers), then make that skeleton object the Mesh Cage Parent of the more complex object. The vertex groups all link up, and you get nicely deforming flora with relative ease.

Of course, you can take it up even another notch, and include Deformation Delay, based on more vertex groups. You would be able to assign a delay to mesh deformation based on named vertex groups. Let the leaves on a tree deform naturally, but make the vertex group for the thinnest branches lag them by two frames. Then make the group the next thickest branches lag by two more frames. This would give the illusion that the wind was pushing the leaves first, which were in turn pulling around the branches.

Once again, this sort of vertex group creation could most easily be done at the time the mesh is generated.

Do both of these things, Cage deformation and delayed deform, and you’ll add tools to better leverage the animation capabilities that are already in Blender, and probably create some really cool natural-looking animation in the process.

Well --i was writing a python script to do almost just what you said.

I have done this kinda thing manually on grass. But its hard to get the “wind” right. For trees it mite work quite well. But the skeloton will probably need more structure to ease the “wind” parameter seach.

But for grass i think there are posibly better ways to do it. A bit like the fiber scipt. But this has limits. try a feild of grass… 2 gig of ram is still not enough. Add softbodys to that and your stuffed. So animating grass FiberScript style is a better idea i think.

Idealy some kind of procedual gemotry primitive is what we need for hair and grass. So every vertex is not explicitly stored. IMHO.

Delt0r

ps I’m real busy at this point in time… So there won;t be any script untill christmass and the soonest.

I thought quite a bit about making good easy lowpoly trees in blender, and looked other software’s plugins to have hints.
I came out with a proposal a few months ago, maybe it could serve as inspiration for your process, which shares a lot with it.

http://www.riccardocovino.it/temp/tree-proposal.pdf

i had tree and grass moving in the wind in mindfields almost 2 years ago :wink:
but then… it wasnt moving nicely i recon. i used RVKs and the wave effect to animate the tree. the advantage of the wave effect was that there was no significant slowdown on the huge grass meshes.

.andy

I made some softbody grass tests. Here is one very shor animation with sofbody grass. It’s different than one I’ve posted here some time ago.
http://grzybu.com/movies/softbody_grass.avi
I think softbody is quite usable for grass, but file with baked sofbody is quite huge.
Computing sofbody is quite fast when you disable “Use Edges” option.

Right. One of my points was that it CAN be done with current tools, but that the structure and potential exist to do it much more quickly and simply.

The addition of a Mesh Cage deformer means that smooth animation of much more complex meshes (like a whole field of grass) can be done significantly more quickly than it would take to calculate a full softbody solution for the complex mesh.

I’m going to try to find time today to do a small mockup with grass. We’ll see if it works.

I don’t know whether I’m on the right track here but when you were talking about “mesh cage deformers” All I could think of were lattices. So I fired up Blender, made some ‘grass’, added a lattice and wrapped it around the grass. The first thing I looked for was the wave effect… but there are no effects for lattices. So I clicked on the soft body tab. All the buttons where there, everything looked good. Enable soft body, add a wind generator, alt-a. The lattice moves, but it moves allot and doesn’t wiggle. So I try to setup a weight group… oh surprise, no vertex groups on a lattice.

So I think I get it now, you want a more full featured lattice object. One that inherits most of the characteristics of a mesh, like vertex groups and hooks, but which also deforms its children based on the movement of its verts. Am I close?

Yeah. Very close. What I’d like to be able to do is parent any mesh to another mesh as a deformer, like a lattice. Unlike a lattice, though, the deformation influence would be based on defined vertex groups.

I like your idea harkyman, and I can see another use for it in character animation.

With your cage mesh deformer, I could make a lowpoly character and rig and skin it easily. I could then add detail to the lowpoly character. The resulting high poly character would be difficult to work with and difficult to skin properly, but no worries because I can use the easy-to-work-with lowpoly character as a deformer.

I’d thought that too, but didn’t want to overly complicate my explanation. In fact, you could use this to drive a character’s skin based on deforming low-poly muscles that are attached to bones.

I like your idea.

But as an alternative, how about a system to automate the creation of vertex parented empties on one mesh (based on a selection of vertices for example) and the automatic creation of hooks to the empties on the points of a lattice (based on physical distance)?

Wouldn’t that help? I wish I had something like this when I used the wave effect to deform the model of a dandelion seed via a lattice.

I agree that your cage deformer would be invaluable. Have you submitted a feature request yet?

Koba

Urgh…

I was playing around with hooks and vertex parents again. I am so sick of setting up like hundred hooks each time. I was trying to get two softbodies to deflect each other by applying softbodies, creating vertex parented empties and creating hooks to an identical cube with “Deflection” enabled. It sort of worked for the simplest cubes but I have given up with subdivided cubes…either I keep screwing up from tedium or it isn’t possible.

Anyway…it would be worth making a python script for this. I’ve not played with python for a while so I may have forgotten how it works and what is available in the API. Anyway, I’ll lay down some naive pseudocode which I may or may not implement. Perhaps someone else learning Python would like to take it up.

  1. Use a naming convention to specify the deformer and the deformed object. Find the length of the vertex list for each. Store the larger number (the deformer will be assumed to have the smallest number of vertices - create an error message if not). This will be the number of hooks to create.

  2. Starting with the first vertex in the list of the deformed object (most vertices), use pythagoras on every other vertex of the second object to find the closest match in terms of distance. Store the index of that vertex. Now create an Empty (named in ascending numerical order), move it to the position of the vertex and create a hook at that vertex.

  3. Using the stored index, create a vertex parent to the last empty created (known by number).

  4. Increment the the deformed vertex index and repeat till the number or vertices of the deformed object is reached.

This script would be in no way optimised but a lot quicker than doing it by hand. It assumes the geometry of the two meshes overlaps roughly so all the verticies of the deformer are used.

This script wouldn’t replace your cage deformer but would allow use to experiment with your idea a little.

Koba

I’d like to add support to the character animation aspect of this feature. IMHO, this feature is necessary for correct joint deformation of more sofisticated characters. I posted about character joint deformation using lattice objects here. I used lattice objects in this example because there is no other option atm, but if there was a cage deformer, I would have used it instead, because cage deformers can have a much more useful shape than the default cube shape of the lattice.

For 2.4(abc)
No groups but a weight directly assigned to the lattice vertex. Select vertex NKEY oooh. BTW curves work too.

The blend on this page uses a lattice with a hook to start then animation.
http://mosebjorn.altervista.org/sbtut/
BM