Dark Side of the Sun

Friday, November 20, 2009

Autumn Leaves v1.0 (MEL script)

The first version of Autumn Leaves is now available for download from the scripts section of my website. It's the first MEL script to find its way there.

Autumn Leaves automatically creates an optimized setup to simulate dozens of flying / falling tree leaves, with proper collisions, deformations, dynamics and aerodynamics. You only need to have high-res and low-res models of your leaves (you can combine several different models), and a NURBS surface to place the leaves on. After applying the script, you cand add more stuff to the simulation, like fields, or collisions with animated objects and characters.

Here's a very simple example video:

Autumn Leaves (Maya MEL script) example from Mayec Rancel on Vimeo.

This script is an evolution of a technique I developed to do leaves simulations in the film Planet 51 (which, by coincidence, comes out in US cinemas today!). It creates a relatively fast low-res single nCloth simulation, and transfers its animation to the high-res leaves through the use of wrap deformers.

I have many ideas of how to take this tool further, and make it more powerful / flexible. So if you use it and have any ideas for improvements, let me know. Same thing, of course, if you find any bugs (they are always there, creeping about somewhere...).

Here is the release info (which you can find in the .txt file that comes with the script download):

Autumn Leaves v.1.0

AUTHOR: Mayec Rancel


Tested in Maya Versions: 2009 x64


This script prepares a scene for a realistic simulation of falling tree-leaves.
You can also make them blow in the wind, or collide with the ground or other objects, etc.

The simulation itself is done with nCloth. The idea is to have one or several leaf models,
and their corresponding low-res models (sub-divided and shaped planes, basically). This script
1. Scatter as many copies as you want of those leaves, on the NURBS surface of your choice
(with random rotations), avoiding intersections.
2. Combine all the low-res models into a single object (named "simLeaves_Lo") , which will be
simulated with nCloth.
3. Apply wrap deformers to the high-res leaves, so they will have the movement and deformations of the
simulated low-res leaves.
4. Set basic parameters of the nCloth simulation, although you will have to tweak those depending
on the scale of your scene/leaves and desired behaviour.


For the script to work, you need to have in your scene:
- A high-res model for each of you different leaf variations, named "leaf#_Hi"
(e.g.: leaf1_Hi, leaf2_Hi and leaf3_Hi.)
- As many corresponding low-res models, properly aligned and with the same number
as their corresponding high-res leaf. Their names should be "leaf#_Lo".
(e.g.: leaf1_Lo, leaf2_Lo, leaf3_Lo). These models are to be simulated
with nCloth. For instructions on how to optimize them for this use, read
the Maya documentation on nCloth, or take a look at the Autumn Leaves example scene.
- A NURBS surface, where all your leaf copies will be placed.
When you execute the script, you just have to confirm (or modify) the number of different
leaf models you want to use, input the name of your Placement Surface object, and enter
the number of copies you want of each leaf variation.

Execute the script. And after all the calculations and setup, your scene should be ready to play
and sim. By default, script hides low-res leaves and leaves high-res leaves visible. If you hide the
high-res and show the low-res instead, your simulation will go faster (for display reasons). You can
cache it, and then bring back on the high-res leaves for playblasting/rendering.

You will probably want to tweak the parameters of the nCloth object, to adapt to your scene
scale and/or desired behaviour. The default settings are suposed to work pretty well with a real scale
(leaves aproximately 10cm large). The script sets the following parameters to these values:

Space Scale: 0.05
Use Plane: true
SubSteps: 12
Collision Iterations: 16
Start Frame: 1
Thickness: 0.3
Lift: 0.6
Drag: 0.6
Mass: 5
Bend Resistance: 5

So if things look weird for your specific scale, these could be the first parameters to adjust: Space Scale,
Thickness, Lift, Drag, Mass and Bend Resistance.

After running the script, you can add fields or collisions to the nCloth sim.


With this script you will find a test scene, called "autumnLeaves_testScene.ma". It´s an example of how to
set your scene before using Autumn Leaves. Just open it, and launch the AutumnLeaves MEL script. Leave
everything at default, and set up the number of copies (around 20 is a good value), then run, and you should
see the pretty leaves flying around.

The leaf models in this scene were modeled and kindly donated by Bego Gonzalez. Feel free to use them for your
animations, as long as proper credit is given to her (and to me, if you use the script ;).


- more precise check for intersections.
- more scatter options:
- scatter leaves on an object's surface (make it work for Poly)
- scatter leaves in an object's volume
- scatter leaves at particles
- option to have other names for leaf models.


Glenn said...

Hi Marcel!

Fantastic work! This is such a commonly needed effect, this tool will be valuable to many artists. And congrats on Planet 51, I'm really looking forward to it! The designs looks awesome. Are you working on a new project yet?



Mayec said...

Hi Glenn. Thanks for your comment. I have to point out that my name is not Marcel, but Mayec. ;)

I'm glad to hear this tool could be useful! be sure to let me know if you use it, and if you miss anything.

Since a few months ago I am at MPC, London. For the moment, I´m working on Ridley Scott´s Robin Hood film.

Anonymous said...

The information here is great. I will invite my friends here.


Anonymous said...

Don t work on maya 2012?
Thks for ur script

Mayec said...

I have never tried the script in Maya 2012, so it's possible that it doesn't work in that version. If you find that kind of incompatibility in one of my scripts, feel free to send me an email detailing your findings, and I'll try to look into it and see if it can be easily fixed.