Wind Physics
The APS_SDK now includes scripts to add wind effect to your existing DynamicBone asset, only requiring modification of a single line in DynamicBone.cs
You can now add custom wind effects that are fully compatible with avatars that include DynamicBone. This new custom wind solver update allows adding "emitter objects" to scenes for generating wind effects and turbulence from fans, jet engines, even weather conditions, or negative values to create inward flow like tornados.
Wind sims for avatar clothing and hair during mocap, really fun, saves time, use interactively in mocap scenes to create fun animations! Here are a few simple examples:
Emitter Type: Directional
Flow Type: Exhaust Forward
Emitter Type: Directional
Flow Type: Intake Exhaust
Emitter Type: Directional
Flow Type: Exhaust Exhaust
The Directional flow type is easy to understand since force is concentrated along the forward axis. While Spherical flow type emits wind from the center point outwards, or by specifying negative Force values creates inward flow like a black-hole, or tornados. The Global flow is the simplest where the force is equal at all points in space and flows all in the same direction, just like a windy day..
Emitter Type: Spherical
Force: 1
Emitter Type: Spherical
Force: -1
Emitter Type: Global
The various combinations of Emitter Type and Flow Type make up the majority of the different possible effects. The simplest is the forward exhaust which emits wind along the forward axis only so nothing would be affected if behind the emitter. Note that both wind and vacuum effects are possible. Imagine scenes in space eg. the ship is damaged and air is rushing out of the corridors, or add negative emitters near the doorways.. But also way more subtle effects can be created too, such as a window with rigged curtains.
Clothing is the best use for this features as it allows animators to add wind effects directly to their custom avatars at mocap time so the effect is visible even during recording in VR. The animator may also review mocap with wind in the scene, and of course even export the results, all created naturally and in a single take and ready for render in Blender with no need for post simulations.
To get things working all you need is to add a "Wind Emitter" to a scene, then add "Wind Options" to each dynamic bone chain you would like affected by wind. Note that if you already have a existing custom avatar but doesn't include Wind Options you can disable the "Requires Options Component" checkbox for each wind emitter so that existing avatars should just work!
Two new components were added to the APS_SDK: DynamicBoneWindEmitter and DynamicBoneWindOptions. Together they make up the complete solver extension. I will try to go over and explain both components and what some of the options and parameters are for.
The DynamicBone Wind Emitter Component
The wind emitter component shown in the Unity inspector.
🍎This component can be added to game objects in custom scenes to create wind effect.
Adding a wind emitter to a prop also works, currently the prop can not move and must stay in the original location it was at when recording starts (dynamic prop support coming soon!).
You can also add any number of wind emitters within reason. Each wind emitter will add some overhead, depending on the number of dynamicbone chains that respond to wind. You can also use wind groups to target specific chains, using wind groups is a optional feature!
The DynamicBone Wind Options Component
Add this to gameobjects that include DynamicBone scripts
🍎Extends a DynamicBone component's options.
Adds finer control over individual chains.
Use lower Wind Strength values for short bangs, heavy clothing and parts of body.
Use higher Wind Strength for long flowing hair.
How To Install! The complete wind solver is available in the latest APS_SDK!
All that's needed is to change one line and copy a single function to the DynamicBone.cs script to add this custom wind solver in your project!! Lets get started:
First you will need to download the APS_SDK version 9.3.4 or later. At the time of writing this tutorial the latest SDK can be downloaded on the Discord here (be sure to join the Discord server first!)
When building custom avatars for APS it's recommended to use Unity 2019.4.40f1, which is the version I am using for this tutorial. The wind solver will work in any version of Unity that DynamicBone supports.
Once you've started a new Unity project, import your DynamicBone unitypackage, then import the APS_SDK unitypackage, these are the only two packages required, then to add the wind solver code open the DynamicBone.cs file from the ../Assets/DynamicBone folder and locate and change one line of code. Let's go!
From your project's Assets folder locate the ../DynamicBone folder and navigate to the file DyanmicBone.cs
Open DyanamicBone.cs in a IDE or text editor.
Locate or search From: p.m_Position += v * (1 - damping) + force + rmove;
Change the line To: p.m_Position += v * (1 - damping) + force + rmove + AddWind(p);
Note how it's just simply adding the + AddWind(p); part.
Lastly copy this entire function and paste it somewhere in DynamicBone.cs
private DynamicBoneWindOptions m_windOptions; //CUSTOM ADDED
Vector3 AddWind(Particle p) //CUSTOM ADDED
{
if (m_windOptions == null)
m_windOptions = GetComponent<DynamicBoneWindOptions>();
return DynamicBoneWindEmitter.GetWindForce(m_windOptions, p.m_Position);
}
That's it! The custom wind solver is now added to DynamicBone!
Here is how the modified DynamicBone.cs file should appear once all edits have been added:
Start The Scene! Now to actually use the wind solver and add a wind emitter.
Next step is to add a wind emitter to a scene and run the scene to see the effect!
From the Unity project create a new scene.
Add a empty gameobject to the scene and name it "WindEmitter".
Attach a DynamicBoneWindEmitter component to the WindEmitter gameobject.
If you already have a avatar with DynamicBone setup add the prefab to the scene.
If you press play likely nothing will happen, you need to disable the "Require Options Component" checkbox first.
Pressing play again you should see the emitter is affecting DynamicBones along the forward axis.
Move the emitter around the scene and see how the avatar reacts.
Now try adding DyanicBoneWindOptions to each DynamicBone on the avatar you want affected by wind.
re-enable the "Require Options Component" checkbox.
Pressing play and now only specific bones are affect by wind.
You can adjust the Wind Strength slider for each DynamicBoneWindOptions on the avatar,
eg. short bangs, heavy clothing and body parts should set lower Wind Strength than long flowing hair and light clothing.
Some considerations when setting up a DynamicBone component is that wind force should become more noticeable along the bone chain rather than the same along the entire chain, for things like long hair the stiffness should be higher near the scalp bones and drop off quickly, which would help avoid over animating the hair bones near the scalp while allowing the rest to flow more easily.
The curve below shows the stiffness curve for a long tail, stiffness should be controlled entirely by the distribution curve. Setting the first few bones to have a much higher stiffness than the lower bones:
DynamicBone settings:
When working with tails or long hair it is especially important to setup a distribution curve for a stiffness gradient. This is so that the bones near to the origin are not affected by wind forces as noticeably as bones further towards the end.
Example Distribution Curve:
I also added the CC0 fan model from Blendswap as a prop and uploaded it to the Steam Workshop. This asset includes the "DynamicBoneWindEmitter" component with "Require Options Component" checkbox disable, so it works with all existing avatars!
Download this prefab and check out the new Wind Sim using any avatar in the latest APS Playtest Beta!
That's the end of this tutorial 🎉🎉🎉 Thanks for reading I hope you enjoy this free addon! This feature is still in development so check back soon for updates !! 😃
Thanks for reading ❤️