Chapter 4 · Recipes
4.13Wind
TenPix Wind is a wind made for cloth: it blows on every face as air, with gusts of real sizes and a wind shadow. It acts on a cloth only through that cloth's Tnpix Forces list. Speeds are in m/s and sizes in metres, whatever the scene's unit. Set its properties on its base object.
undo "TenPix: wind" on (
local pos = [-150, 0, 100] -- scene units, upwind of the cloth
local w = TenPixWind pos:pos name:"TPWind"
w.transform = matrix3 [0, 1, 0] [0, 0, 1] [1, 0, 0] pos -- rows: icon X, icon Y, arrow (icon Z), position: blows along +X
local b = w.baseObject
b.mode = 0 -- 0 Automatic, 1 Map
b.windType = 0 -- 0 Planar, 1 Fan, 2 Point
b.speed = 5.0 -- m/s: 1 a light air, 5 a moderate breeze, 15 a near gale
local fx = tpaFirst $Flag Tnpix_Forces
if fx == undefined do fx = tpaAddBelowSolver $Flag (Tnpix_Forces())
append fx.forceNodes w
append fx.forceMuted 0 -- parallel to forceNodes: 0 acting, 1 muted
)
Aiming. The arrow is the icon's own Z axis, and the icon's X and Y are the direction map's "across" and "up". Set the transform with the rows X, Y, arrow and position. These rows keep the map's "up" pointing up in the world:
| Blows along | w.transform = matrix3 X Y Z pos |
|---|---|
| +X | matrix3 [0,1,0] [0,0,1] [1,0,0] pos |
| −X | matrix3 [0,-1,0] [0,0,1] [-1,0,0] pos |
| +Y | matrix3 [-1,0,0] [0,0,1] [0,1,0] pos |
| −Y | matrix3 [1,0,0] [0,0,1] [0,-1,0] pos |
Any right-handed set of rows works. For example, matrix3 [0,0,-1] [0,1,0] [1,0,0] pos also blows along +X; with it, the icon's X points down, so the map's "across" is vertical.
The other TenPix Wind settings:
- Gusts.
terrain0 Open land, 1 Suburb, 2 City; or setgustStrengthandbiggestGustyourself. - Direction drift.
wanderis how far the direction drifts, in degrees. - Fade.
fallofffades the wind with distance. - Repeatability. The gusts come from
seed, and two bakes of the same scene are the same. - Shelter.
shadowis on by default: cloth behind a fold, another garment of the Solver, a collider, or an object inshadowNodesgets slower, gustier air.
Map mode and direction maps. In Map mode (mode = 1), map shapes where and how hard the wind blows: white is the full Speed, black none. With no map, the full Speed blows everywhere. directionMap turns the wind. Its colours are read in the picture's own frame:
| Colour | Turns the wind toward | 0 .. 1 means |
|---|---|---|
| Red | Across the map, left to right: the Wind icon's X | −1 .. +1 |
| Green | Up the map, bottom to top: the icon's Y | −1 .. +1 |
| Blue | Along the arrow | −1 .. +1 |
(0.5, 0.5, 1), or (128, 128, 255), blows straight along the arrow. The map's 0,0 is on the Wind's arrow, and one map (0..1) covers the Wind's mapSize, in metres.
- Moving maps. A map that changes over time, such as an animated map or an OSL map driven by its Time input, is read every frame and stays fast. The first frame after opening the scene, or after editing such a map, takes longer, because the map is read once along the timeline.
- What shows the swirl. Air running along the cloth's surface grips it through
dragAlong(Drag along, default 0.02). Air meeting it face on pushes throughpushAcross(Push across, default 1.2). A flat sheet facing the wind therefore shows a swirl only faintly, while folds, flags and garments show it.
The samples. The installer's samples\Wind direction maps folder sits beside the TenPix scripts folder. It holds 8 OSL shaders and 8 PNG pictures with the same names (TenPix_WindDir_01_Straight … 08_Turbulent). Every OSL sample has a UVW input and a Time input in seconds that follows the time slider, plus its own settings, all of which can be animated. Leave UVW unconnected and the Wind provides it; connect a UVW Transform map to move, scale or turn the pattern. Anyone can copy a sample to write their own: keep its tpWindColour and tpWindTurn functions and change what the shader computes.
| Sample | The wind | Settings (MAXScript name = default) |
|---|---|---|
| 01 Straight | One direction everywhere; can sway | Across=0, Up=0 (deg), Sway=0 (deg), SwayPeriod=2 (s), SwayWaves=0 |
| 02 Swirl | Turns around a centre; the middle is calm | CenterU=0, CenterV=0, Turn=40, Calm=0.18, Clockwise=0, DriftU=0, DriftV=0 |
| 03 Spread | Blows outward from a centre, like a fan or a blast | CenterU, CenterV, Turn=35, Calm=0.25, DriftU, DriftV |
| 04 Gather | Blows in toward a centre, like a draught into an opening | CenterU, CenterV, Turn=35, Calm=0.25, DriftU, DriftV |
| 05 Rising | Lifts more toward the top, as over a slope | Bottom=0, Top=45 (deg), DriftV=0 |
| 06 Split | Parts left and right, as around something | Position=0, Turn=31, Softness=0.1, DriftU=0 |
| 07 Wave | Swings side to side in bands that travel up the map | Waves=2, Swing=29, Speed=0.5 (waves/s), Phase=0 |
| 08 Turbulent | Swirls that change over time and can drift | Swirls=4, Turn=37, Speed=0.25, Phase=0, DriftU, DriftV |
Centres and drifts are measured in maps from the Wind's arrow (drifts in maps per second); turns are in degrees.
-- the OSL Swirl in the Wind's Direction map
(
local d = if TenPixCloth_Dir == undefined then "" else (getFilenamePath (trimRight TenPixCloth_Dir "\\")) + "samples\\Wind direction maps\\"
local f = d + "TenPix_WindDir_02_Swirl.osl"
if not (doesFileExist f) then ("No sample at " + f + ": ask the artist where the TenPix samples folder is.") else (
local m = OSLMap()
m.OSLPath = f
try ( m.OSLAutoUpdate = true ) catch ()
m.name = "Swirl"
local b = $TPWind.baseObject
undo "TenPix: wind direction map" on (
b.mode = 1 -- Map
b.directionMap = m
b.projection = 0 -- 0 along the wind (projected from the icon along its arrow), 1 3D around the icon
b.mapSize = 1.0 -- metres: one map
b.travel = false -- the pattern stays where the Wind puts it
)
m.Turn = 40.0 -- the shader's settings are properties of the OSL Map
"Swirl set"
)
)
-- a PNG sample instead: bt = Bitmaptexture filename:(d + "TenPix_WindDir_02_Swirl.png"); bt.filtering = 2; b.directionMap = bt
A 3ds Max Wind (or Drag, Vortex, Gravity, Motor, Push, PBomb) in a Tnpix Forces list acts with its own 3ds Max force; only a TenPix Wind is air. A Wind at Strength 1 pushes about as hard as gravity pulls. A Wind created from MAXScript starts with Decay, Turbulence and Frequency at 1.0, so pass decay:0.0 or it dies off within a few units:
w = Wind pos:[0,-200,80] strength:1.0 decay:0.0 turbulence:0.3 frequency:2.0
w.rotation = eulerAngles 90 0 0
fx = tpaFirst $Flag Tnpix_Forces -- the garment's own Tnpix Forces, if it has one
if fx == undefined do fx = tpaAddBelowSolver $Flag (Tnpix_Forces())
append fx.forceNodes w
append fx.forceMuted 0
Tnpix Forces settings:
- Each garment is pushed by its own Forces. One instance shared across a Solver group pushes every garment alike.
- Strength.
strengthmultiplies every warp in the list. - Mute.
forceMuted[i] = 1mutes one warp without removing it. - Push only part of a garment.
forceChannellimits the push to a painted channel, such as a sleeve or a hem. - Zones.
zoneOnwithzoneHelpers(Influence Helpers) limits the push to a zone.
The toolbar's Forces window lists every Tnpix Forces in the scene with its warps' dials.