Forest Editor Wind Effects for Artists
by Russell Fincher · in Torque 3D Professional · 06/03/2010 (10:42 am) · 45 replies
Edit: Forest Editor is currently included in the Torque 3D 1.1 beta, presumably to be included in the full 1.1 release. T3D 1.0 owners should have access to the 1.1 betas.
I'm going to add this post as an explanation of how to set up your vegetation model to take advantage of the wind effects in the Forest Editor. This information has been covered in a few other posts, but I wanted to get it all in one place. This post will discuss how to paint vertices of your plant models in your modeling program and set them up in T3D. I'll tweak this over time as I am able to. Please let me know in the comments if there is anything missed or unclear here.
VERTEX PAINTING YOUR MODEL
The color of a vertex in a model allows the artist to specify how a plant model will behave once it is brought into T3D and allowed to respond to a wind emitter. Here is a breakdown of how the colors affect a model:

The red coloring only, to designate the upward/downward bend of the branches... notice how the base of the branches are black and the ends of the branches are red:

The blue coloring only, to designate leaf fluttering... notice how only the edges of the blades are colored:

The green coloring only, to designate individual instances of branch bend... each branch has its own shade of green:

And all the colors mixed together with an additive blend. Notice that the trunk has no coloring, since it will neither flutter like a leaf nor wave like a branch. The bend along the tree's height is done without the use of vertex coloring:

And a video of this in action:
How you actually apply these color sets varies between modeling apps, but here's how I do it in 3ds Max:

If you need to go back and tweak individual color sets/modifiers in Max, you can put their blending modes back to "normal" and turn them on and off to isolate an individual color set.
And I probably don't have to say this, but don't eyeball the colors, dial them in. When I say "red", I mean pure red, or R:100%, G:0%, B: 0%.
EXPORTING YOUR MESH TO TORQUE 3D
I use the free OpenCollada as my exporter (DTS does not support vertex color data). The last I checked, Max's built-in Collada(.dae) exporter wasn't exporting vertex coloring correctly. OpenCollada exports both vertex coloring and User Properties correctly, so it's my Collada exporter of choice. Just be aware that it appends material names with "-material". I can't get those guys to agree with me that it's a terrible idea.
For those not using Max or Maya who cannot use the OpenCollada plugin... you'll just have to see if T3D's Collada importer will correctly read vertex coloring in your file.
SETTING UP A PLANT MESH IN TORQUE 3D TO DISPLAY WIND EFFECTS

Once a mesh is brought into the Forest Editor (and a global wind emitter is placed in the scene), the mesh parameters must be set properly for your plant to come alive correctly. Definitions for mesh parameters:
SETTING THE VIEW DISTANCE OF THE WIND EFFECTS
Plants in the distance will not display wind effects. In the current beta release, Torque 3D 1.1 beta 1, you can change the threshold that wind effects disappear by changing its configuration in the source code. See Tom's comment below about setting that.
In subsequent releases, this can be changed by simply entering this in the console: $pref::windEffectRadius = 30; That sets it to 30 meters around the camera. The default setting is 25 meters. Obviously this will affect performance, but you can cater it to your specs. Make sure to save your level after doing this.
A FEW MORE NOTES ON WIND EFFECTS
In addition to the global wind emitter, you can use a local wind emitter around anything that may create a localized wind situation... waterfalls, helicopter rotors, big fans, jet engine exhaust, etc.
Also, when setting up the wind parameters for your mesh in T3D, be sure to occasionally toss a grenade near your plant to see how your settings look with an explosion nearby.
Have fun! Make your foliage come alive! :)
I'm going to add this post as an explanation of how to set up your vegetation model to take advantage of the wind effects in the Forest Editor. This information has been covered in a few other posts, but I wanted to get it all in one place. This post will discuss how to paint vertices of your plant models in your modeling program and set them up in T3D. I'll tweak this over time as I am able to. Please let me know in the comments if there is anything missed or unclear here.
VERTEX PAINTING YOUR MODEL
The color of a vertex in a model allows the artist to specify how a plant model will behave once it is brought into T3D and allowed to respond to a wind emitter. Here is a breakdown of how the colors affect a model:
- Bending of branches: controlled by the amount of red on a vertex. Normally the ends of branches are fully red, and the spot where they reach the trunk would be fully black (or colorless, depending on how you are painting...see my method below), with a smooth gradation between.
- Branch group instancing: So that groups of branches sway independently, they need to have varying amounts of green. Usually done by selecting a clump of branches/fronds and filling with a random shade of green (anywhere from pure green to black).
- Flutter of leaves: flutter is controlled by the amount of blue on a vertex. Normally, the ends of fronds are fully blue so they flutter fully, but I've found that in a lot of cases (in trees, mostly) I can just fill the entire frond with blue.
- Vertical bend: the vertical bend of a tree does not have to be painted... that is calculated automatically by its height

The red coloring only, to designate the upward/downward bend of the branches... notice how the base of the branches are black and the ends of the branches are red:

The blue coloring only, to designate leaf fluttering... notice how only the edges of the blades are colored:

The green coloring only, to designate individual instances of branch bend... each branch has its own shade of green:

And all the colors mixed together with an additive blend. Notice that the trunk has no coloring, since it will neither flutter like a leaf nor wave like a branch. The bend along the tree's height is done without the use of vertex coloring:

And a video of this in action:
How you actually apply these color sets varies between modeling apps, but here's how I do it in 3ds Max:
- Stack three separate Vertex Paint modifiers on the tree model.
- Working from the bottom, one modifier at a time, fill the vertices with black, then paint one of the color sets listed above to each of the three modifiers. In the end, it doesn't matter in what order the colors are created or stacked.
- After all three have been painted their own color set, set the blend mode of the top two Vertex Paint modifiers to "additive".
- Export your model as Collada with these modifiers on and you should have the vertex coloring you need to get wind effects on your meshes. Do not collapse the stack.

If you need to go back and tweak individual color sets/modifiers in Max, you can put their blending modes back to "normal" and turn them on and off to isolate an individual color set.
And I probably don't have to say this, but don't eyeball the colors, dial them in. When I say "red", I mean pure red, or R:100%, G:0%, B: 0%.
EXPORTING YOUR MESH TO TORQUE 3D
I use the free OpenCollada as my exporter (DTS does not support vertex color data). The last I checked, Max's built-in Collada(.dae) exporter wasn't exporting vertex coloring correctly. OpenCollada exports both vertex coloring and User Properties correctly, so it's my Collada exporter of choice. Just be aware that it appends material names with "-material". I can't get those guys to agree with me that it's a terrible idea.
For those not using Max or Maya who cannot use the OpenCollada plugin... you'll just have to see if T3D's Collada importer will correctly read vertex coloring in your file.
SETTING UP A PLANT MESH IN TORQUE 3D TO DISPLAY WIND EFFECTS

Once a mesh is brought into the Forest Editor (and a global wind emitter is placed in the scene), the mesh parameters must be set properly for your plant to come alive correctly. Definitions for mesh parameters:
- shapeFile - path to mesh
- collidable - indicates whether or not the mesh uses collision
- breakable - (not implemented)
- radius - the canopy radius in meters. This keeps plants from being placed too close to one another and having overlapping canopies. This value may need to be adjusted on larger plants when placing smaller plants under their canopy (placing bushes under a tree, for instance). This has no in-game functionality and only matters when placing trees in your environment.
- mass - mass will generally affect how springy a plant is in response to wind or an explosion. Think of it as a weight on the end of a stick. Most of my trees are set to around 5, smaller plants down to 0.5.
- rigidity - how much the plant resists the wind force. Most of my trees are within 10-20, but some small grasses go down to 1.
- tightnessCoefficient - how much the plant resists bending. Between 0 and 1.
- dampingCoefficient - slows down the sway of the plant so it won't whip back and forth forever. Between 0 and 1.
- windScale - relative scale at which this plant is affected by wind. Between 0 and 1, but will almost always be set around 1.
- trunkBendScale - the amount that a plant will sway from top to bottom. This is very sensitive. I don't have any vegetation set higher than 0.03, and most are under 0.01.
- branchAmp - amount that a branch with sway up and down. Start well below 1.
- detailAmp - the amount of leaf flutter. Start well below 1, in the 0.05 range.
- detailFreq - the speed of leaf flutter. Start well below 1, in the 0.05 range.
SETTING THE VIEW DISTANCE OF THE WIND EFFECTS
Plants in the distance will not display wind effects. In the current beta release, Torque 3D 1.1 beta 1, you can change the threshold that wind effects disappear by changing its configuration in the source code. See Tom's comment below about setting that.
In subsequent releases, this can be changed by simply entering this in the console: $pref::windEffectRadius = 30; That sets it to 30 meters around the camera. The default setting is 25 meters. Obviously this will affect performance, but you can cater it to your specs. Make sure to save your level after doing this.
A FEW MORE NOTES ON WIND EFFECTS
In addition to the global wind emitter, you can use a local wind emitter around anything that may create a localized wind situation... waterfalls, helicopter rotors, big fans, jet engine exhaust, etc.
Also, when setting up the wind parameters for your mesh in T3D, be sure to occasionally toss a grenade near your plant to see how your settings look with an explosion nearby.
Have fun! Make your foliage come alive! :)
About the author
Art Lead at Sickhead Games, focused on dev tools and prototyping, instructor/advisor at several Dallas colleges and universities, Associate Developer with GarageGames, champion of avant-garde game art at uncommonassembly.com.
#22
To change this manually in code go to enginesourceforestforestWindMgr.cpp in function ForestWindMgr::processTick() at line 89:
... also in enginesourceforestwindDeformation.cpp in function WindDeformationConstHandles::setConsts() at line 50:
Change the 25.0f in those two spots to your desired radius and rebuild the EXE. In the forthcoming release hacking this won't be necessary.
06/07/2010 (8:53 am)
So in T3D beta 1.1 the $pref::windEffectRadius isn't exposed.To change this manually in code go to enginesourceforestforestWindMgr.cpp in function ForestWindMgr::processTick() at line 89:
GameBase *cam = conn->getCameraObject();
if ( !cam )
return;
// TODO: Expose this!
F32 radius = 25.0f; // WIND EFFECT RADIUS!
const Point3F &camPos = cam->getPosition();... also in enginesourceforestwindDeformation.cpp in function WindDeformationConstHandles::setConsts() at line 50:
if ( wind )
{
// Calculate distance to camera fade.
F32 toCamLen = ( state->getDiffuseCameraPosition() - wind->getPosition()).len();
// Expose this as the wind effect distance!
F32 toCamInterp = 1.0f - (toCamLen / 25.0f); // WIND EFFECT RADIUS!
toCamInterp = mClampF( toCamInterp, 0.0f, 1.0f );
windDir.set( wind->getDirection().x, wind->getDirection().y, 0.0f );Change the 25.0f in those two spots to your desired radius and rebuild the EXE. In the forthcoming release hacking this won't be necessary.
#23
06/07/2010 (9:05 am)
Thanks, Tom. I've changed the post to point to Tom's addition. Sorry again for the false info, Justin.
#24
Indeed it was! I've never been this close to Collada, but it's pretty cool! And the file had everything I needed to get an idea.
My script is able to modify an existing Collada file and paint vertex colors, but I plan to support .obj files as well and still export as Collada. I'm planning to make this available as a free web based service on our website - hopefully not long before you can check it out.
Coloring works best for trees that roughly have an ordinary shape - things like horizontally grown trunks will not produce the best results, but they will still look pretty good.
Differentiating between trunks, branches and leaves was not so hard. I build on the assumption, that anything that should not be painted will have an opaque texture. So for that, I check for transparency in the material diffuse texture instead, and leave the model alone. This is giving me pretty solid results.
I generally use all kinds of distances and the number of triangles a given vertex is a part of to calculate color distribution. I've just worked out a new method to find groups of branches / leaves which I think will give me perfect results - I'll be able to tell in a few hours hopefully.
Once I have some results I'll do a quick screenr cast and show you what it looks like with exactly the same settings as in your example.
06/07/2010 (9:08 am)
@Russell:Quote:
The default tree does have proper vertex coloring, so it should be a faithful test for you. That is one poorly built tree at the moment... I intend to update it before 1.1 ships. :)
Indeed it was! I've never been this close to Collada, but it's pretty cool! And the file had everything I needed to get an idea.
Quote:
You just blew my mind. Procedurally generating vertex colors for wind effects would be fantastic. I've been doing this manually for about a year now, so I have my process down, but it's still a chore. It seems like you'd still need to select groups of polys to designate which are the trunk, which are branches, and which are fronds. But automating the actual painting part would certainly make things easier.
My script is able to modify an existing Collada file and paint vertex colors, but I plan to support .obj files as well and still export as Collada. I'm planning to make this available as a free web based service on our website - hopefully not long before you can check it out.
Coloring works best for trees that roughly have an ordinary shape - things like horizontally grown trunks will not produce the best results, but they will still look pretty good.
Differentiating between trunks, branches and leaves was not so hard. I build on the assumption, that anything that should not be painted will have an opaque texture. So for that, I check for transparency in the material diffuse texture instead, and leave the model alone. This is giving me pretty solid results.
I generally use all kinds of distances and the number of triangles a given vertex is a part of to calculate color distribution. I've just worked out a new method to find groups of branches / leaves which I think will give me perfect results - I'll be able to tell in a few hours hopefully.
Once I have some results I'll do a quick screenr cast and show you what it looks like with exactly the same settings as in your example.
#25
Desiclaimer: I'm making this up as I go along! ;)
I used a single Vertex Colour channel for RGB because ... frankly ... I've never done it before and have no idea how to combine 3 seperate vertex channels together.(I could've read some docs but went charging in "Tally-ho" style instead)
Initially the vertex colour defaulted to "white" - and so I selected "black" as the RGB paint colour and then hit toolbar/header/menu paint->Set Vertex Colours which fills all vertexes with the chosen colour.
After that, I started painting with R/G/B respectively - but found that using "Mix" actually didn't mix at all, but replaced one with another. Setting it to "Add" did mix the colours together.
For a test I split my "Big Spikey Tree Stand-in" into 3 sections, red at the bottom, green in the centre and blue at the top. (The white bits are all 3 colours mixing together)

And it should end up looking something like this, with all the 3 colours (and black) mixed together.
In-game you can see the 3 sections moving according to what they should be doing.
06/07/2010 (2:00 pm)
Blender: Vertex Paint first attemptDesiclaimer: I'm making this up as I go along! ;)
I used a single Vertex Colour channel for RGB because ... frankly ... I've never done it before and have no idea how to combine 3 seperate vertex channels together.(I could've read some docs but went charging in "Tally-ho" style instead)
Initially the vertex colour defaulted to "white" - and so I selected "black" as the RGB paint colour and then hit toolbar/header/menu paint->Set Vertex Colours which fills all vertexes with the chosen colour.
After that, I started painting with R/G/B respectively - but found that using "Mix" actually didn't mix at all, but replaced one with another. Setting it to "Add" did mix the colours together.
For a test I split my "Big Spikey Tree Stand-in" into 3 sections, red at the bottom, green in the centre and blue at the top. (The white bits are all 3 colours mixing together)

And it should end up looking something like this, with all the 3 colours (and black) mixed together.
In-game you can see the 3 sections moving according to what they should be doing.
#26
06/07/2010 (2:16 pm)
that's really cool Steve .. now add some snow and a toasty camp fire to set the scene. :) I'm gonna have to dig out blender. What's the impact on having lots of these wind based trees in your game?
#27
Currently it's real close, and seems to fade out, but with a few of these things gathered around the player I can't see any fps drop.
------------------------
Also, checked Blender docs and see no way of merging 3 seperate colour vertex channels for export to Collada.
------------------------
I think I'm winning on lowest quality trees ... 8D
06/07/2010 (2:44 pm)
Distance isn't exposed to 1.1b1 ... so we'll have to wait and see with b2.Currently it's real close, and seems to fade out, but with a few of these things gathered around the player I can't see any fps drop.
------------------------
Also, checked Blender docs and see no way of merging 3 seperate colour vertex channels for export to Collada.
------------------------
Quote:
The default tree does have proper vertex coloring, so it should be a faithful test for you. That is one poorly built tree at the moment...
I think I'm winning on lowest quality trees ... 8D
#28
As far as Blender's 3 seperate colour vertex channels go - just set your color as you need, all the channels are automatically added to your file. Even a bonus Alpha channel. Afaik, you just need to set the proper color and paint away!
Me, giving Steve a protip for Blender. Right.
Well, still, worth a try. It seemed to have worked for me in Blender.
06/07/2010 (3:01 pm)
@Steve: Really cool! I was just thinking about this effect being used for underwater scenes. Would be very useful to simulate underwater animals and plants.As far as Blender's 3 seperate colour vertex channels go - just set your color as you need, all the channels are automatically added to your file. Even a bonus Alpha channel. Afaik, you just need to set the proper color and paint away!
Me, giving Steve a protip for Blender. Right.
Well, still, worth a try. It seemed to have worked for me in Blender.
#29
Starting off with 3 "black" channels
So if I have only red selected - I only get red movement in-game.
However ...
If I start off with 1 channel and paint it, then make a second channel -> the paint info from the first is carried into the new one -> and then when a third channel is created it has the info from the both other channels -----> which is really the same as using just one channel.
I too was also thinking about underwater plants!
06/07/2010 (3:33 pm)
Konrad - Disclaimer: I'm using an older version of Blender I've found that if I use 3 seperate channels - only the one that is selected gets exported ...Starting off with 3 "black" channels
So if I have only red selected - I only get red movement in-game.
However ...
If I start off with 1 channel and paint it, then make a second channel -> the paint info from the first is carried into the new one -> and then when a third channel is created it has the info from the both other channels -----> which is really the same as using just one channel.
I too was also thinking about underwater plants!
#30
I've decided to slightly alter settings compared to those in Russell's tutorial to make the effect look better. Make sure you watch the vid in 480p, otherwise you could miss the finer movements. Perpahs it's too natural moving for a demo, but it's something that is or close to game ready imho.
Made in about 6 to 8 seconds. :)
Instead of having it on our site, I'll create a resource that adds this to the engine. I want to circumvent trust issues about uploading models to our site. But this will take more time, unfortunately.
06/07/2010 (4:31 pm)
Lo and behold my procedurally colored palm tree!I've decided to slightly alter settings compared to those in Russell's tutorial to make the effect look better. Make sure you watch the vid in 480p, otherwise you could miss the finer movements. Perpahs it's too natural moving for a demo, but it's something that is or close to game ready imho.
Made in about 6 to 8 seconds. :)
Instead of having it on our site, I'll create a resource that adds this to the engine. I want to circumvent trust issues about uploading models to our site. But this will take more time, unfortunately.
#31
06/07/2010 (4:57 pm)
cool :)
#32
06/07/2010 (4:59 pm)
Looks pretty good, Konrad! It's amazing how even subtle movement can really bring foliage alive.
#33
@Konrad: OMG I am soo looking forward to trying out your procedural vertex painting. I have way too many trees to manually paint even if I were a 'Blender Pro'.
Thanks all!
06/09/2010 (8:16 am)
Now this is what I call timing :) I was planning to inquire as to how I would do this to a Blender tree yesterday but was too busy :) I come back today and all my answers are here waiting for me!@Konrad: OMG I am soo looking forward to trying out your procedural vertex painting. I have way too many trees to manually paint even if I were a 'Blender Pro'.
Thanks all!
#34
We can't take advantage of hardware instancing with skinned models but it should be possible to adapt the flutter or sway movements of foliage and trees to a simple animation like the flapping wing of a butterfly, but will we be able to path it around a level or will it only work on a fixed position mesh like a tree?
Any pointers would be very helpful.
06/09/2010 (8:49 am)
Considering the new hardware instancing in the upcoming beta2 we are looking into using this kind of vertex painting based animation for meshes other than trees for example insects and birds to add some extra ambience to the forest. We can't take advantage of hardware instancing with skinned models but it should be possible to adapt the flutter or sway movements of foliage and trees to a simple animation like the flapping wing of a butterfly, but will we be able to path it around a level or will it only work on a fixed position mesh like a tree?
Any pointers would be very helpful.
#35
Thank you very much
07/19/2010 (4:34 am)
Russell. do you have the sample max file for downloading? so our artist can have a look inside, he can not figure out some problems. you can send it by email. zhangyuejun@yahoo.comThank you very much
#36
Any progress on uploading the procedural painting engine changes to the resource section?
07/19/2010 (2:16 pm)
@ Konrad;Any progress on uploading the procedural painting engine changes to the resource section?
#37
Oh, and please post a link to it here so I don't miss it. :)
07/19/2010 (2:56 pm)
Quote:Russell. do you have the sample max file for downloading? so our artist can have a look inside, he can not figure out some problems.Yuejun, I will probably release the stock Forest Editor tree as a Max file once I have another pass at it... But I would actually prefer that your artist post his/her question in the forums (in a new thread), so everyone could benefit from it. It's likely that I can solve his issue fairly quickly that way.
Oh, and please post a link to it here so I don't miss it. :)
#38
07/19/2010 (8:55 pm)
@Steve: I'm sorry - I wasn't yet able to spend time on that. I'll try to set some aside for this during the week.
#39
Just in case anyone needs it..
www.wings3d.com
08/02/2010 (4:49 pm)
wings3d is free, easy to learn, it supports vertex colors, and collada. Just in case anyone needs it..
www.wings3d.com
#40
This info also spammed on the imposter/BB thread
10/07/2010 (2:53 pm)
Just to add some info - you can't go straight from a vertex painted mesh (for wind effects) to an imposter LOD, or the object will momentarily LODout (vanish) before it swtiches from mesh to imposters.This info also spammed on the imposter/BB thread
Associate Russell Fincher
Sickhead Games
@Konrad: The default tree does have proper vertex coloring, so it should be a faithful test for you. That is one poorly built tree at the moment... I intend to update it before 1.1 ships. :)
@Doni: Steve is right... the Forest Editor is only currently available in the 1.1 beta. I've updated the post to reflect that. Thanks, guys.
@Steve: Did you get vertex painting set up correctly in Blender? If so, It would be great if you could describe your process, maybe with a screenshot or two? Not everyone around here uses Max and I feel this post is lacking in that respect.
@Konrad: You just blew my mind. Procedurally generating vertex colors for wind effects would be fantastic. I've been doing this manually for about a year now, so I have my process down, but it's still a chore. It seems like you'd still need to select groups of polys to designate which are the trunk, which are branches, and which are fronds. But automating the actual painting part would certainly make things easier.