Collada plugin for After Effects

More info here
Plugins and Scripts > Lightwave

Blender Fluids Importer

Lightwave 11.5 python script for loading the files generated by the Blender fluids simulation. It reads the geometry, velocity and particles information to generate a series of lwo files.

right click the link above to download

To install copy the read_blender_fluids.py file to the python script's plugin folder, something like:

"C:\Program Files\NewTek\LightWave11.6\support\plugins\scripts\Python\"

Below process may or may not be needed to run the script

Since Python 2.7.2 cannot load shared libraries from a Zip file, you must extract the Python library files found in "bin/python27.zip" to a folder called "bin/Lib". Once extracted, delete or rename "python27.zip", run LightWave, and Python should be able to locate and use all the shared libraries bundled within the "Lib/" folder (including "bin/Lib/pyexpat.pyd").

click below to see the animation

lightwave fluids panel

Controls:

  • Undo Levels - reminder must be set to 1 or will crash
  • Fluid type - choose one of the 3 fluid types generated by Blender
  • Select a fluid file - choose any of the files bobj.gz, bvel.gz, gz. The fluid type setting will determine which set of files gets imported.
  • First frame - start frame for the animation range
  • Last frame - end frame for the animation.  If both First and Last frame are left at -1 the script will automatically determine the correct values for the entire range
  • Subpatch the geometry - useful for smoothing out the geometry of preview type fluids. Final fluids are generally too dense to benefit from subpatching.
  • Include particle data - will import the particle files as point clouds when the fluid type is set to final. If the fluid type is set to "only particles" this check is ignored.
  • Flip normals - use if the fluid mesh is inside out
  • Delete unknown particle type - removes what looks like error particles
  • Particle Drops to their own sequence - drops saved to a seperate file sequence
  • Particles Floaters to their own sequence - floaters saved to a seperate file sequence
  • Particles Tracers to their own sequence - tracers saved to a seperate file sequence
  • Minimum particle size - remove very small particles to match Blender sim results.  Fewer particles should translate to better performance in Layout.  Set to 0 to get all the particles.
  • Scale X,Y,Z - scale the imported mesh. There are seperate controls for xyz to account for non-uniform fluid domain scaling.
  • New file name prefix - the lwo files will use this prefix instead of the default "fluidsurface". Can load several sequences into Layout. Clear the field to use the prefix of the files generated by Blender.

Modeler's Undo Levels must be set to 1 or a memory leak will crash Modeler.

Tutorial Link: Blender Fluids to Lightwave

Usage:

The easiest way to use this is to choose final or preview fluid, select any fluid file and press OK.  When the Blender simulation is set for subdivision value of 2 or more, the particles get incorporated into the final version of the fluids mesh.

preview vs final

This image shows the difference between preview and final fluids, both set to the same resolution. The difference is that the final fluid takes advantage of the combination of domain boundary subdivisions combined with particle generation.

Usage:

  1. Generate a fluid simulation in blender
    1. including the particles set value between 0 and 1
    2. subdivision level 2 if the particles will be generated into the fluid mesh
    3. might be able to control particle with explicite particle objects(size ?)
  2. Open modeler and set the undo levels to 1, this reduces the memory leak.
  3. Create dummy object with the desired material applied to it. The first surface of this object will be copied to the new fluid meshes.
  4. Run the script and choose any of the files generated by Blender. A set of lwo files are generated from the fluid meshes. Optionally particle mesh series are also produced.
  5. Wait - there is some feedback but it's sporadic at best
  6. Close modeler without saving.
  7. Open layout and create a null.
  8. Load the first lwo file of the set and parent it to the null.
  9. Rotate the null -90 degrees in pitch to turn the system right side up.
  10. Open the geometry tab for the mesh and set the object replacement to object sequencer.
  11. Open the deform tab for the mesh and add morph mixer.
  12. Create anorther null and animate it over 1 frame to move 1 m in Y. The value in Y will be used to scale the overall motion blur(1m=100%).
  13. Open the graph editor for the null and set post behavior on Y motion to repeat.
  14. Load the mesh into the graph editor and add a channel follower motion modifier and have it follow the animated null's Y position.
  15. Set the camera to use motion blur.

Notes:

  • Modeler undo levels needs to be set to the lowest value because of a memory leak
  • Note: If you get a "delete unknown particles" message followed by an "error 2904" try turning off the unknown particle deletion option
  • The velocity creates 4 sets of weight maps for the x,y,z directions and one weight map for speed. It also creates a morph based on the velocity which can be used for motion blurring.
  • The particles mesh gets a weightmap for size and like the mesh the velocity is translated to a morph map.
  • Particles will import into 4 selection sets: Drops, Tracers, Floats and unknown.
  • When subdivisions are set to 2 or more and generate particles is greater than zero then particle data is used in the generation of the fluid mesh.
  • Setting tracer to specific count does not make for constant count so not an option for MDD format.
  • The material for the sequence can be changed in Layout by loading/creating an object in the scene with the same surface name and setting the surface editor to "edit by scene" instead of object. The object sequencer fluid will adopt the new surface settings. This only works when the surface is not nodal.
  • Fluid boundary with subdivisions(>=2) is required for particle detail enhancement to the fluid mesh.
  • The morph map of the fluid is animated to produce motion blur.
you tube here

Some more notes(WIP):

Assuming most of the scene is setup in Lightwave and Blender is used just for it's fluids simulation. Both programs should be set to the same frame rate.

Export from LW:

  1. Be sure all objects have at least 2 keyframes even if they don't move, otherwise they will be adjusted to Blenders Z-up world.
  2. If an object is animated with Bullet rigid body clone it, turn bullet off on the clone, add follower to it then run mental fish bake keyframes lscript after baking remove the follower then remove the bulleted object from the scene - ?make invisible not export collada? <- test this - nope it exports so delete the bullet animated item if it will interfere...
  3. If the domain is created in Lightwave and does not have scale of 1, rotations of 0 and at the origin then save the object transformed or apply the transforms in Blender before running the simulation.
  4. ?Fluid obstacle meshes need some resolution/detail for good collision?
  5. Export Collada from Layout with no scene scale
  6. Run the Collada Export Fixer found on this page so the animation will transfer properly

Import to Blender:

  1. Open Blender and delete all items from the scene
  2. Import Collada - check on Import Units.  The scene will import on it's side.
  3. Make a cube for the fluid or maybe use an imported item from the scene.
  4. Object > Quick Effects > Quick Fluid
  5. Size the fluid domain to fit the scene and fluid placement.  Set the preview mode to Geometry to see it's extents properly.
  6. The fluid domain needs to be at the origin, with no rotation and a scale of 1 for the easiest translation back to Lightwave.
  7. Object > Apply > scale and rotation with Object > Apply > location will "freeze" the transforms.  This is needed because the fluid files do not have transform information embedded within them.
  8. Scene tab and set gravity to -9.8 in Y and set Z to zero, the change will not show in the domain settings.
  9. If the bake freezes try setting the fluid obstacle volume as "Shell" type. 

Import the fluid to Lightwave:

  1. can set the fluid import scale to 0.01 in X,Y and Z or do it later in Layout
  2. The object sequence surface loader can be used to change the surfaces of the sequenced lwo files in Layout.
  3. If the fluid mesh was imported at full scale of 1,1,1 then set the null scale to 0.01
  4. Parent the fluid mesh to a new null then rotate the null 180 degrees in Heading.
  5. At this point the fluid should be in it's proper position and orientation relative to the original scene that was export to Blender.
  6. Load particle mesh and set it up the same as the fluid mesh
  7. Apply hypervoxels and set the dissolve so they are invisible until their first frame.
  8. Object properties for the particle mesh > deform tab >double click HVParticles and set the weight map to Fluid_Size.
  9. Hypervoxels set gradient texture on particle size using particle weight as the input.  Adjust the gradient to set the particle size.
  10. Make hypervoxels look like the fluid mesh surface.
  11. If the fluid was generated in Blender with gravity in the  Z direction then parent the fluid to a null and set the null rotation to -90 in pitch and 180 in bank.

links:

May 31, 2017 (v 1.12):

  • LW2015 compatible

February 19 2014 (v 1.10):

  • add version number to the title
  • minimum particle size to remove tiny mist like particles and improve performance

December 3 2013:

  • option for each particle type to it's own object file - layers are not compatible with object replacement in Layout
  • can import particles with the preview mesh
  • velocity weight maps added to the particles

December 2 2013:

  • create selection sets for the 3 types of particles: Drop, Float and Tracer
  • unknown type particles deleted - this may be unstable, random error 2904 in testing
  • fluid particle velocity scaled to more closely match the mesh vertex velocity
  • particle groups each to their own layer

November 23 2013:

added ability to rename the prefix of the lwo files created in order to enable the possibility of loading more than one fluid sim in the same scene file. The docs in Blender say you can set your own prefix inside Blender, but I can't figure out how it can be done.

November 19 2013:

fix for LW 11.6 release version changes

October 25 2013:

added reminder in UI to turn undo levels down

October 21 2013:

will not crash when fluids frame is empty

October 20 2013:

  • fixed error when no velocity file is generated from Blender
  • fixed Blender right to Lightwave left handed coordinates
  • added individual scale values for X, Y and Z for the case when the fluid domain is not scaled uniformly in Blender

July 23 2013:

  • reduced the default import scale
  • added import scale field
  • fix random spikes cause by bad triangles
  • added progress indicator with auto console open

July 15 2013:

  • easier to use
  • more error checking
  • discovered a large memory leak and a workaround for it
  • fix bad version upload

July 10 2013:

  • removed scaling from mesh velocity for stronger morphs
  • added velocity morph to the particle mesh
June 29, 2013