EaseClin solucion para la clinica dental We are renewing the page, please stay tuned facebookfacebook Select language
Español
English
 

Unity TORNADO Tutorial (Versión en español aquí)

System requirements: Unity 3.5.7 or above (Works in Unity free and Pro)

This is the same Tornado shown in 3dnemo's Youtube channel with some improvements.





Download the package here.

After decompression, you'll find a Unity Package and a plugins folder. You can experience some problems after decompression depending on the software used.

Please keep me informed of any issue sending a message to contact@3dnemo.com

IMPORTING THE ASSETS

I recommend you to experiment in a new empty Unity project. All you need to see the Tornado is in the download.

Once in Unity, go to menu Assets:Import Package: Custom Package
Look for the downloaded package and import all the assets.

1

After import you will get an error in the console. This is due to the lack of the Perlin.cs script that must be in a Plugins folder, so drag and drop the folder in the Project pane, not the script alone or you'll get the same error.

The correct hierarchy must be as in the image below.


2

BEFORE PLACING THE TORNADO

Before placing the tornado, select the default camera in the scene and tweak values as in the image below . To see the tornado because of its size, you must be somehow far away and looking slightly upwards.

At the same time, the clipping plane far must be of 2000 or more to not crop the top particle effect.

3

PLACING THE TORNADO IN THE SCENE

Now you can place the Tornado in the scene. Go to the prefabs folder in the Project pane and drag the Twister_Prefab to the hierarchy pane to locate it near 0,0,0 position.

It wil start to grow inmediatly. Give it several seconds to get the whole height.

At the moment you can see a straight Tornado with three main characteristics. A main body from ground to sky, a subttle dust effect in the ground and a cloudy effect at the top.

Press play.

The Tornado comes to life and start to displace smoothly giving a more lifelike effect. Again you must geive several seconds to let it develop and start moving.

If you want, you can add the Tornado to whatever scene you want and let it as is, but maybe you want to experiment a little more and get some impressive effects of your own so keep reading.

At this moment you must see something like this.

4

CONTROLLING THE TORNADO

There are lots of things you can change to improve the Tornado at your liking but keep in mind that almost all of them have some influence over the rest, so be cautious and follow the guidelines on the tutorial.

The main behavior and look is controlled mainly by:

- Three particle emmiters. One for the ground effect, one for the main body and one for the top effect.
- Three materials for each one of the emmiters.
- Two textures, one of them shared by two materials.
- One script to move the Tornado ramdomly (it needs the Perlin noise plugin or drops an error).

As a bonus, the Tornado comes with a windy sound effect already attached to the main object. It's a 3D sound so it get louder as you approach the Tornado.

Firstly, as you can see in the image above, the effects is achieved with really scarce elements, only 4 drawcalls and 1.6k tris. Forget about the 119.6 FPS, Unity is giving me different figures anytime I start it from 400 FPS to 70 FPS. I dont't know why, maybe not profiling well my graphic card or something else. (Nvidia GT 120 on 8 core Mac Pro).

TECHNICAL NOTE: All three emmiters are the older type found in previous versions of Unity that you can find now in menu Component:Effects:Legacy Particles. So, no Shuriken particles are used because they lack of a tangent velocity property, what is exactly what makes the tornado work. Of course this has a couple of drawbacks, but I could't find a way to make it with shuriken.

- The legacy particles lack of a prewarm property (as far as I know), so you must hide the Tornado in some way when launched in a scene, to let it develop before showing.

- The second problem is not for deployment but for development and is missleading in many ways and I think is the reason to not have a lot of Tornados like this running everywhere. The exact problem is that this kind of particles suffer from instability anytime a parameter is changed so you need to wait several seconds to see what is really happening. Actually it tooks a lot of time and trial and erro changing a parameter at a time until getting the correct behavior.

It is very important to keep in mind that changes and tweaks must be made sparingly and waiting for the particles to recover it's path to get the desired result when in edit mode, so be patient.

Anyway I'll give you some clues and values for you to see what you can get.

THE EMITTERS

As said, there are three particle emitters to make the complete Tornado, but you can use two or only one if you want.

Twister_Prefab - Is the main object that generates the ascending flow. Is located at ground level and particles grow upwards until they reach the top emitter.
TwisterUp - Is an emitter that creates just a bunch of very huge sized particles to merge with the surrounding sky.
TwisterDown - This one is to create the sensation of debris been absorved by the Tornado. Interesting effects can be done just changing the colour of particles. For example you can make them more green if over vegetation or more red if over a desert or just white if over water.

The emitters have a lot of parameters on it's three main components, the Ellipsoid Particle Emitter, the Particle Animator and the Particle Renderer, but we need to setup just a few of them.

Please think that, as said, this is a result of a process of trial and error so maybe some values can be changed without affecting the effect too much, while I know others can destroy completely it.

Lets start with the main object "Twister_Prefab" in the scene. As you can see when press play, the Tornado grows from bottom to top what is wrong in some way because actual Tornados go the other way, top-down, but is the only way I found to get the thing running. From there, the effect is correct as tornadoes are mainly a flow of rotational ascending air.

At the sametime, this is the parent of the other two emitters, so when it moves, the others do, and althoug the top emitter moves at the sametime, due to the huge size of particles and persistence, the effect remains coherent.

Of course you can alter the hierarchy to get more control over each element, but I wanted to keep it as simple as it could be.

5

To get the correct behavior you need of course an ascending force so you give a value of "20" in World velocity Y and some random values in Rnd velocity to break uniformity. Then you find a value of "10" in Tangent velocity X what gives part of the rotational behavior to the particles.

I tried (and you can at his point) to use Y and Z, but even getting the rotational behavior aswell, the effect is slightly different and not of my liking. If you just set Tangent Velocity at "0" (zero) in the three axis, you will see only some smoke going up.

But Tangent Velocity is only part of the story, go a little further to the Particle Animator component, you will see that Local Rotation Axis has a value of "2", just set it to "0", the effect is completely destroyed, just set it to "2" and the Tornado is back again.

6

So this two values alone, Tangent Velocity X and Local Rotation Axis, just generate the effect.

Knowing this, you can make any other kind of vortex as made, in this case, for the TwisterDown object. I used the same values as in the main Tornado body to make rotation coherent, but the World Velocity is "0", so a little wortex over the terrain is created. To inject some life and randomness I used a value of "1" in Rnd Force Y in the Particle Animator and "0.5" of Force Y.

For the TwisterUp the Tangent Velocity is increased to 50, due to the size of the particles. and the ellipsoid, and a "0.9" Damping in the Particle Animator. Again "0" World Velocity and a subttle "0.1" in Local Rotation Axis Y in the particle animator.
PARTICLES AND TEXTURES

I must say that this was another nightmare and counter intuitive at first. When you think in a Tornado, you start by making a vortex of thousands of tiny particles as you think it might be, but you never see what you expect.

In the contrary, I found that a bunch of big particles with a correct texture are far better in all ways, more compact looking, better performance and easier control.

The texture used for the main body and the top emitter is the same low reolution puff of smoke retouched by hand without very much purpose but making it randomly looking. The final texture is just what looked correct, no more no less.

In the other hand, there is a debris texture for the TwisterDown that you can change at any time to get different results depending on environmental conditions, but just a little change on the color property of the material is enough to get great results.

The materials use the Particles/Alpha Blended built in shader, so you can affect the opacity of the Tornado changing the alpha property of the Tint Color. Furthermore, because the texture used is black and white, you can tint them of any color to mach the surrounding light and atmospheric conditions.

You can change that also in the particle animator with color animation, but be careful or the particles will start to pop up or dissapear breaking the smooth flow and the whole effect.

Finally, to get a better looking tornado, the Twister_Prefab "Stretch Particles" property in the Particle Renderer are of type "Sorted Billboard" to have the correct order in the alpha channels rendering.

The TwisterUp particles, use the Horizontal Billboard value because it's supposed that you allways see them from below.
SCRIPTS

There are two scripts, NoiseMove.js and Perlin.cs from the Unify Wiki. Those scripts are only to give some movement and to see how particles develop, but you can move the Tornado at will with your own script.

The Perlin.cs must be in a Plugins folder in order to work and is a library so nothing to do with it.

The NoiseMove.js is attached to the parent object Twister_Prefab with some vars you can change.

- Speed. Keep it low. Default value is "0.02" to give the sensation of slow displacement and give time to particles to build up in a credible fashion. Values over "0.1" are too fast and destroy the effect.

- Move size. Keep Y at "0" to move on the ground. By default the values are 400 that equals to 400 m to the right, 400 m to the left and the same for front and back, taking as center the point where the Tornado is place when press play.
sponsored by EaseClin
Copyright © 2013 - Lauret Producciones - contact@3dnemo.com