MassFX Dynamics Modifier 

 

Videos 

 

Description 

Ornatrix dynamics for 3ds Max 2013 and above uses the integrated MassFX dynamics system that is built into 3ds max. This allows for a powerful dynamic simulation that uses the tools you already know from 3ds max. To simulate Ornatrix hair just add the OX Dynamics modifier above your guides and press the MassFX play/simulate button in 3ds max.
Ornatrix employs a sophisticated physics that simulates many of the real-world properties encountered with hair and stranded structures. The dynamics integration in Ox is done in such a way that the user is only directly concerned with parameters that have an effect on how hair behaves. While it is impractical to simulate every single hair strand in a dense structure due to the large number of strands it is possible to run dynamics on guide level, thus limiting the total number of world parameters greatly. Every guide represents a volume of nearby hairs so the overall look is pleasing and with a proper setup can be very close to real-world dense hair behavior.


A braid untangles itself using mutual collisions and gravity
Because we are dealing with a physical simulation, the user must try to specify the best parameters for each simulation. Although a wide variety of parameters can be used to represent a vast range of hair types and styles, a simulation can easily become unstable due to a faulty setup. For example, none of the objects in real world can have an mass of 0, or be in two places at once. Simulator stability would probably be the number one problem with animating hair, and here is some information to help you avoid it.


External sphere object collides with simulated hair, causing a volumetric disturbance response

 

Simulation parameters 

 

Differential Solver (Integrator) [3ds Max 2012 and below only] 

  • Constraint solver
    This is the solver used for solving world constraints. There are two variations of constraints available. In most cases you only need to use LCP Reduced solver. This solver requires much less memory than LCP Implicit and on average performs faster than the accurate solver. Only use the non-reduced solver when you don't have any collisions and you must have a completely accurate simulation model.
  • Steps per frame
    Number of simulation steps taken during every frame, or every refresh (when doing real-time preview). Note that taking 2 steps with 0.5 step size is equivalent to taking two consecutive steps of 0.05 size. Therefore if you would like your step size to remain constant and simply want more steps per frame all you have to do is multiply the step size by number of steps per frame. For example, if you want 8 steps per frame each at 0.05 step size you set the steps parameter to 8 and step size parameter to 0.4. This is useful when you want to speed up the hair animation while retaining precision.
  • Iterations
    When using reduced solver this parameter adds additional control over the precision of simulation. Number of iterations relationship to simulation time is inverse square meaning that setting a higher number doesn't mean that simulation will slow down linearly. Usually 20-40 iterations are sufficient.
  • Stack size
    As mentioned previously, Ox solves all of its constraints at once. When there are too many collisions (mutual or external) there are a lot of constraints. Ox needs enough space to store them and with this parameter you allocate the space that Ox is allowed to use. If there isn't enough space you will get a simulation error. 10 MB is usually enough, but just in case you run out you should know about this parameter.
  • Timeout
    Whenever an error occurs in simulation Ornatrix simulator 'freezes'. Using this parameter you can set how long does Ox wait before it considers that an error has occurred. If, during a simulation, you feel that its not going anywhere you have to wait until the timeout elapses at which point you can resume your work. Default value is 15 but if your scene computes relatively fast 1-5 seconds will also do.
 

Simulation Control 

  • Compute simulation
    Use this option to start computing a 'hard' simulation. All of the changes to the hair will be keyed and committed within the specified time interval.
  • Real-time preview [3ds Max 2012 and earlier only]
    Sometimes it is convenient to have a fiddle with your hair interactively before you do actual simulation. This option uses all of the exact same procedures that actual simulator does but instead of keying changes it simply updates the viewport. You can interact by moving your objects manually or scrolling through the time slider. All of the parameters can be adjusted and previewed in real-time. If the guides below in the stack are edited the simulation will automatically restart. The system performs much faster when it doesn't need to check for collisions. Therefore turning off all collisions (external, mutual, per-strand) will result in a speed increase.
  • Auto-Detect Distribution Object [3ds Max 2013 and later]
    When on, the simulator will automatically try to detect to which object inside the scene currently simulated guides are attached. If such an object is found the simulation guides will be attached to it instead of having animation-driven roots.
    This is useful, for example, to have a ragdoll head with hair attached to it or any other scenario where other objects inside the scene need to interact with the hair.
    Note: The algorithm used for such detection currently just find another object at the same position as the hairs and as such can mistakenly find another MassFX object in the scene and try to attach the hair to it. In this case the hair simulation may fail. To solve this you may either move another object to a different position in the scene or turn this option off.
  • Start time
    Controls which frame the simulation is started at. Should always be greater than end time parameter.
  • End time
    Controls which frame the simulation is ended at. Should always be less than start time parameter.
  • Key step
    Controls how many frames are passed without encountering a keyframe. 1 meaning that hair is keyframed every hair. 2 means that hair is keyframed every 2'nd frame, and so on.
  • Start segment
    This tells the simulator which segment from root in every strand should be the first in the strand chain. When the hair is attached to a surface, for example, simulating the very first (root) segment will result in constant collision of that segment with the surface. Setting this parameter to 1 will skip the first segment of every strand and will start simulating from 2 segment(s) thus preventing any collision trouble.
 

Physical Properties 

  • Global scale
    Not currently implemented
  • Mass
    Controls the mass/weight of every strand of hair.
 

Internal forces 

  • Damping
    This is analogous to air (medium) friction. Any velocity that a strand has is simply 'dragged' or pushed in opposite direction with a force to stop it eventually.
  • Flexibility
    This controls how much each strand is allowed to bend from its original shape. For example, if a strand was in a form of a curl (spiral) before simulation and flexibility is low then the hair will always try to preserve its curly state despite the forces acting on it. This in effect introduces the springiness into the hair. A value of 0 should not be used at it might make simulation unstable.
 

External Forces 

  • Gravity
    Sets a global force in -Z direction with a specified magnitude. This force is to resemble Earth's gravitational pull.
  • Multiplier
    Whenever using external Max's force fields (spacewarps) this parameter will act as a global multiplier for every such force.
 

Mutual Forces 

  • Auto-generate wisps
    When this option is on Ox will look at the relative positions of strands to each other and determine the optimal/biggest wisp radii such that no two guides collide initially at the root. The use of this option is not always recommended as it might introduce instability in some cases (for example when tips of two guides are closer than their roots).
  • Global wisp radius
    When above option is off this parameter sets the global wisp radii manually. Using very small radius for a wisp isn't a good idea since it might introduce spatial errors.
  • Wisp scale
    This is simply a multiplier for above two parameters so they can be scaled down from their original values.
  • Use strand self-collision
    If option is on every strand will collide with itself as well as other strands. This is sometimes necessary when simulating chains or hair tied into knots.
  • Segment skip step
    If above option is on this one prevents two consecutive segments to collide with each other.
  • Use mutual collisions
    Use this option when you want hairs to collide with each other. This is necessary to make each guide simulate a volume of strands around it. This option will prevent wisps from coming too close to each other, yet it will not introduce any forces to make them 'stick'.
  • Orientation dependent
    Not implemented (yet)
  • Softness
    Whenever strands collide this parameter sets how soft the wisps are. Softer wisps will stop gradually, while hard ones are stopped right away. Using softer wisps can prevent instability as well as provide more realistic results.
  • Bounce
    When two wisps collide this parameter controls how fast (if at all) they bounce away from each other. This is analogous to the coefficient of restitution.
  • Friction
    If this parameter is 0 then wisps will slide freely when they collide. If it is more than 999 then any sliding is prohibited. Anything in between controls how much friction is introduced between hair wisps.
 

Collision Surfaces 

  • Use collision response
    If on then hair will be tested for collisions against externally specified objects.
  • Use collision primitives
    Internal dynamics system used by Ox can perform collisions much faster with parametric primitives such as spheres, boxes, capsules, etc. When this option is on Ox will see if the object specified is a Max sphere or a box and automatically convert them to the internal representation of same primitive thus improving collision tests.
  • Surface friction
    If this parameter is 0 then colliding hairs will slide freely along the surface that they collide with. If it is more than 999 then any sliding is prohibited. Anything in between controls how much friction is introduced by each surface. If you are using surface velocity then this parameter must be above 0 to let surface 'grip' on the hairs.
  • Surface bounce
    When hairs and a surface collide this parameter controls how fast (if at all) the hairs bounce away from the surface. This is analogous to the coefficient of restitution. A value of 1 introduces an reverse-inertial bounce, while a value of 0 swallows any energy the hair had when going towards the object.
  • Minimum bounce velocity
    This extra parameter lets you control how fast the hair has to be moving towards the surface for bouncing to occur.
  • Surface softness
    Controls how soft/hard surfaces are. A value of 0 will stop the hair right away to prevent inter-penetration. Higher values will let hair pass into the object a little before stopping it. Using a non-zero value is a good idea to prevent instabilities.
  • Surface velocity (U,V)
    This extra parameter lets you specify how fast the surface itself is moving along its tangential direction. For example, if a hair falls onto a stream of water that is moving quickly then the hair is dragged along with the water since water surface is moving. Note that for this parameter to take effect you have to specify a non-zero friction.
 

Preventing simulator instability 

  1. User error
    As mentioned above, it is possible to make the simulator unstable simply by providing extreme or inaccurate parameters. The scale of the objects also plays a great role. Something 2 cm, and 2 km long behaves very differently, even if all the other parameters are scaled proportionally. It is recommended to have all hair and collision objects to be scaled at 1.0-100.0 scale to avoid numerical errors, and to provide realistic 'world' scale.
  2. Numerical error
    Ornatrix, much like the rest of 3dsmax uses floating point format to represent real numbers. Since floating point only takes 4 bytes, its numerical error grows very fast and can easily start affecting the simulation if you use extreme values. As mentioned above, correct scale for objects and forces ensures that numerical instability is kept to the minimum.
  3. Integration error
    Like all the other physics engines, Ornatrix uses a numerical integrator to simulate how the world changes step by step. In real world these steps are infinitely small and thus there are no singularities or errors (well except maybe black holes). However in computer world we are forced to take finite steps. The size of each step directly influences how accurately the simulator changed the world. Therefore taking small steps makes the simulation more accurate but is slower than taking big steps. For different types of simulations the step size may vary. Sometimes big steps are sufficient, however other times the simulation can 'explode' unless you decrease the size of each step.
  4. Constraint/Memory error
    In Ornatrix all the relationships between objects (hair and external objects), as well as actual strands are governed by constraints. Constraints make strands stick together, and the prevent then from going into objects. A special solver has to be used to solve all of these constraints in one go. When the world is complex the number of constraints can grow exponentially and when the time comes to solve them there might simply not be enough memory to hold them. Fortunately you can control the amount of memory allocated by Ornatrix so that any complex scene is solved, but it is up to you to decide these parameters.
 

Troubleshooting 

  • "The simulation has become unstable." Error
    This is caused by one (or more) of the strands losing their stability balance during simulation. The most common causes for this are:
    1. The wisp radius of one of the strands is too small. If auto-generating wisps, check to see that no two guides are located too closely to each other. If that is the case try removing one of those guides before simulation. You might also want to try to specify the wisp radius manually (using global wisp radius) or scale the existing ones. Turn off collisions and check if this instability still happens, if it does then this is most likely the error.
    2. Flexibility is set to 0. Flexibility parameter of 0.0 will cause hair strands to never settle down. In fact in many cases it will amplify hair movement to the point where it becomes unstable.
    3. Damping force is too great. Having too huge of a damping force can cause a negative effect of hair becoming unstable. Although this doesn't happen very often, it is one of the possibilities.
  • "A stack overflow has occurred." Error
    This is the second most popular error. It only happens when you did not allocate enough stack memory for all of the simulation parameters to be computed in a single step. The solution is simple: increase stack size in dynamics parameters. However sometimes you might be more concerned about the cause. If you have sufficient stack space allocated and this error still happens it means that there is most likely too many contacts in the scene or something is wrong with the wisps.
  • "Your timeout interval has expired." Error
    There is a simulator option in Ornatrix that lets you specify time (in seconds) of how long Ornatrix will wait before warning you that simulation is taking too long. If you get this error it means that simply per a single step the simulation is taking more time than set by the timeout. if you know your scene is very large and takes a while to compute you can continue waiting and you won't be bugged again. However you can also cancel the simulation at this point and change some parameters to make it go faster. This option is generally useful to cancel simulations if you don't have a lot of time to spend on them.
  • "Too many contacts between wisps and external objects." Error
    There is a limit to how many contacts are allowed to happen per single frame in Ornatrix. Although that limit is very rarely reached, it is there to prevent possible hangs of Ornatrix. The reason for this is obvious- you have too many objects colliding at the same time. The cause depends completely on your scene. One thing that is most likely to make this error happen is that wisp radii are too big.
  • "Collision detection has encountered an error." Error
    This error should never happen. However if it does, please contact Ornatrix support.
  • "An unknown error has occurred." Error
    This error should never happen. However if it does, please contact Ornatrix support.
  • Whenever I press "Simulate" or "Preview" inside Ornatrix Dynamics modifier it tells me that PhysX SDK cannot be initialized.
    Ornatrix uses PhysX to simulate the hair in its Dynamics modifier. For this to work you need to install the PhysX driver software that is compatible with the version of PhysX used inside Ornatrix.
    • Ornatrix 2.0
      If you experience this error on 3dsmax 2012 x64, please download these PhysX files and copy them into your 3dsmax root directory.
    • Ornatrix 1.8
      If you have an earlier version of 3ds max than 2012 and need the PhysX system software to run PhysX you can use the following link. Please download and install this package, which will ensure compatibility:
      PhysX_9.10.0513_SystemSoftware.exe
      If you are having compatibility issues because another software installed a different version of PhysX (Thinking Particles, Rayfire, Hairfarm etc) the most important thing to check is that you have compatible PhysX dlls. Ornatrix uses the version of PhysX DLLs which come with 3dsmax 2012 SAP and do not require a driver software installed.
      The version of PhysX DLLs used in Ornatrix 1.8 is 1.8.3.17 for 32-bit Max and 1.8.3.36 for 64-bit Max. If you get PhysX SDK error the chances are that you have the wrong version of these DLLs present inside the root directory of your 3ds Max installation. This could be caused by other 3rd party tools installing their own version of these DLLs.
      Please download these correct versions and place them into your 3ds Max root installation directory. Back up your previous DLLs first!
 

MaxScript Access 

You may use standard properties exposed by showProperties myModifier to access and change this modifier.

 

Examples 

You can find examples on usage of this modifier by examining the unit tests in Test_DynamicsModifier.ms.