View Single Post
Old 02-10-2013, 06:43 AM   #1   Add To Ignore List  
Developer Fairy
Solais's Avatar
Croteam Representative
Joined: Nov 2009
Solais is offline
Default Cloth and Wind Tutorial for Serious Editor 3/3.5

A few days ago, out of curiosity, I've checked out the Cloth entity. Originally buggy, this entity now is working mostly properly (it's still buggy sometimes, though).

So what is the Cloth Entity? Cloth entity is a mostly two dimensional plane that have the physics of working just like a cloth hanging from somewhere, or just like a flag. Remember those Mental flags from the first Serious Sam 3 teaser? Those are Clothes.

Setting up Clothes are actually quite easy.

What you can see there is what I think is the ideal set up for the Cloth entity, after many experiments. I might be wrong, and I might change it, but this is what I've been using now.

As for the fields:

Width/Height in meters - The size of the Cloth.
Nodes per Width/Height - How many "nodes" the Cloth is made out of; basically, how many polygons. Having this to be high can make the Cloth look more realistic, but it can eat your performance FAST! Having 9 Clothes with 31/31 nodes will cause the game to slow down to 0.5 FPS. Not kidding.
Verlet iterations - I have no idea what this is. Default is always 2 and can't be less.
Thickness - Determines the collision size of all of the nodes. This is most noticeable to the player if they rub up against the cloth.
Render nodes/constraints - Render the nodes and the polygons, even in the game. Set them both off so the Clothes look normal in game.
Structural/shear/bend spring stiffness - These fields control how much the cloth can bend, bounce or how stiff the thing is. Experimenting with this can cause some interesting results. My ideal is 1/1/0.01.
Shader preset - Where you set your shaders and textures, the regular stuff. More about this downwards.
Cast shadows - Set if you want the Cloth to cast dynamic shadows.
Fix cloth points - Now this is an important one. You have to set to fix either the edges and/or the corners of the Cloth to work properly. Without a fixed point, the Cloth will just fall down and through the floor.
Parent part - I have no idea. Maybe it's to set which part of the cloth is parented to another model. Haven't tested it yet.
Mass per square meter [kg/m^2] - This sets how heavy the cloth is. Important when it comes to Wind. I set it to be pretty light (0.01).

About Shader Preset

This is mostly the same as the usual stuff when it comes to texturing. The Cloth itself has a default "Texture" UVmap, so you can use those. For ideal results, I suggest using the default fabric normal texture for normalmap and detail normalmap, since it makes the flag to feel like some sort of fabric from close.

MOST IMPORTANT THING: Set the "Double sided" field to be on. It's most important, otherwise your Cloth will be invisible from behind, and all buggy.

What the Cloth entity can do:

- Look cool.
- Naturally affected by the Wind Entity.
- Naturally affected by the player and LeggedCharacter puppets. Dunno about Aircraft and other puppets though.
- Naturally affected by projectiles.
- It can bug out the most weirdest ways.
- Destroy your framerate if not set up properly.

What the Cloth entity can't do:

- Shockwaves (like those from explosions) can't affect it.
- Non projectile shots (from hitscan weapons, and possibly Magical projectiles) can't affect it.
- It can't be destroyed, aka if you shoot it with a rocket, it will just go through it.
- Can't collide with other cloth and Simple Models. Just goes through them. It might collide with Static Models, though.

About the Wind Entity

The Wind entity is what it sounds like, it generates wind. In SS3, it is barely used, but you might have seen some fields here and there, how some stuff could be set to be effected by it (like particle effects). One usage of it is on the first level "Summer in Cairo", where it's used on the Khnum street where it blows paper into your face.
Cloth entities are naturally affected by them, so Wind is important if you want those flags flutter in the wind.

My current setup of the Wind entity, which I use with the flags in a set area (aka not on the whole level), is this:

Most of the fields are self explanatory.

It can be three types of Wind: Directional, Point and Vortex.

Directional makes the wind blow in a certain direction. Now this is when the entity can bug out, and blow to a different direction than it should do.

I haven't tried Point wind yet.

Vortex wind is wind that blows up from the ground. Could be used for vents.

About Drift

Drift is basically the strength of the wind and is important when it comes to your Cloth fluttering. I usually use a Drift of 0.1, which can be described as "light wind".
A Drift of 1 however is "strong wind", so it makes the Clothes flutter wildly.

EDIT: The Speed of the wind is also important here, forgot that.

I hope this little tutorial was helpful to you fellow mappers, in understanding the basic workings of the Cloth and Wind entities. Using these entities properly could make some scenes look really cool.
Since Old Lost Age I Shine

My Serious Sam 3/HD Workshop

While I do work for Croteam, I'm first of all of this community, so my opinions are my own and do not represent Croteam's views.

Last edited by Solais; 02-10-2013 at 01:59 PM.
  Reply With Quote