Wednesday, May 12, 2010

Voronoi shatter ReadMe

Voronoi Fracture OTL
This OTL contains a Voronoi Fracture SOP,
as well as Fracture Solver and Fracture Pieces DOPs that does dynamic, impact location-based fracturing,
and a few other helper assets that provide base functionality for these assets. 

Assets overview

Voronoi Fracture - SOP - provides Voronoi fracturing capability
Reattach Pieces - SOP
asset that iteratively, randomly fuses groups of geometry as output from the Fracture SOP or the Shatter SOP 
Fracture Solver - DOP - create fractured geometry for RBD objects within a DOPnet based on impacts Fracture Pieces - DOP - responsible for creating new objects in the DOPnet from the fractured geometry Nearest Points - SOP - support Vex SOP that uses point clouds or neigbour information to put the N nearest points into an attribute on each point
If you're unfamiliar with what a 2D Voronoi diagram looks like, google "Voronoi Diagram" and you should get plenty of examples. Or look at the "basic_2d" examples in the example fracture file.

Voronoi Fracture SOP Overview
The Voronoi fracture SOP takes two inputs: the mesh to fracture, and the points around which to build each Voronoi cell.  Typically these points will be generated by one of two SOPs, the Scatter SOP, or the PointsFromVolume SOP. 

If doing a solid fracture, where the interior surface of the object is built for each piece, it is very useful to have all the points reside within the volume. That will ensure you'll get one piece/fragment for each cell point.  Both PointsFromVolume and an IsoOffset to a FogVolume followed by a Scatter SOP will do that.  PointsFromVolume is useful if you know the approximate size of the pieces you want, since it operates on point separation.  Scatter is useful if you know the total number of pieces you want. 

It's also useful for location-based fracturing, as you can modulate the density from the IsoOffset SOP to generate more points within particular regions of the object. 

Where there is higher point density, the Fracture SOP will generate more, smaller pieces. 

The provided .hip files have examples of both types of point generation, as well as location-based fracture. At the moment the Fracture SOP takes a very brute-force approach to building the Voronoi cells. 

For each input cell point, it incrementally clips the input mesh by the half-plane that divides the current cell point and another cell point.  If building the input surface, it caps the resulting hole in the mesh, then continues iteratively clipping and capping. 

This sounds pretty slow, and it is, but two things save it: the Clip SOP is quite fast, especially when it can trivially reject the input geometry (i.e. it won't clip anything), and the Fracture SOP uses pointclouds to start with the closest point and works outwards, short-circuiting any additional work when the Clip SOP won't have any effect, and stopping at the user-defineable "MaxCuts" parameter.  Currently the Fracture SOP also detects then when the input cell points are co-planar, and uses the Triangulate2D SOP to get the adjacent Voronoi cells.  So for most 2D inputs you should not see any artifacts.

Most of this is demonstrated in the example files, but a couple of tips when fracturing:

--Mesh complexity slows down fracturing more than anything.  PolyReduce before fracturing if you can.
 --The Fracture SOP should support most types of geometry, convex or concave.  If you end up with artifacts and are sure the MaxCuts value is high enough, please let me know on the odForce forum.

--When testing fractures, debugging the MaxCuts value, etc, turning off "Create Inside Surface" will speed things up and should look the same on the surface of the object.

--The sign of a too low MaxCuts paramater is overlapping polygons on the surface. Sometimes you can template the initial geometry, put the Display flag on the points, turn on point display and point numbers, and determine which cell point is causing the problem.  Enter that number into the "Cell Point Group" of the Fracture SOP and you can quickly test increasing the MaxCuts param until the artifact goes away. 
There's an example of too low Maxcuts in the example file.

--Sometimes you'll have problems with insufficent point density in long appendages or something in the input object.  Try using IsoOffset and scaling the density up in those areas.  See the "horse" example in the example files.

--Don't use "Convex Interior Polygons" to triangulate the interior surface.  If you want that, apply a Divide SOP after the fact with "inside" as the group.

Dynamic Fracturing Overview
The dynamic fracturing functionality in this asset is provided by the combination of the Fracture Solver DOP and the

Fracture Pieces DOP. 
The Fracture Solver DOP is responsible for creating fractured geometry for any object that needs to fracture on a given timestep (usually due to impact or Magnet Force explosion).  The Fractured Pieces DOP checks for new fractured geo at every timestep, copies the appropriate whole object enough times to create each new piece, assigns the new geometry to these new pieces, and deletes the original whole object.  On most timesteps where there are no impacts, neither DOP does anything.Fracturing usually occurs as the result of an impact.  The basic algorithm for location-based fracturing as performed by the Fracture Solver is demonstrated in the basic_fracture_examples.hip file under the "location-based_fracture" subnet.

Dynamic Fracturing tips(a few of which apply to the Shatter SOP as well):

--If pre-fracturing and using RBD Fractured Object or Glue Object, make sure to set group mask to piece_* or equivalent, else you'll also get an RBD object for inside and outside group, which will mess things up.

--It seems that changing settings inside a SOP solver won't always cause the DOPNet to recook.  Since most of the parameters on the Fracture Solver go straight thru to the SOP Solver, often you have to do force a recook of the DOPNet when changing params (I often bypass and un-bypass the Multisolver DOP)

--If you're not sure whether an object will fracture or not, try it on its own in the SOPs context first with the Voronoi Fracture SOP.

--Use "Visualize Impact Region" to get an idea of where the Fracture Solver thinks the impacts are.

--If you set up a sim from the shelf and have "Ghost Objects" on in the Viewport, Houdini doesn't seem to display most of the new pieces.  Turn off "Ghost Objects" when in DOPs (not a bad idea anyway).

--Even when the sim is done caching, there can be a slight hiccup in the playback when lots of new pieces become visible.  Flipbook to get a better feel for the smoothness of the whole/fractured transition.

--The fracturing operation necessarily occurs after the RBD Solver has already handled the collision, so sometimes the whole/fractured transition looks clunky.  Usually substepping the entire DOPnet makes things look/behave a lot better.  Two is often sufficient; I often use four.

--The pieces created by the Fracture operation tend to have many sided polygons. 

To avoid interpenetration you might have to toggle the collision Surface rep to Edges and toggle on Triangulate (slow).  This is mostly true for stacked up pieces.  Explosions and shattering and such where the pieces go everywhere it's not usually necessary.

--Use as coarse a collision Volume resolution as you can get away with. 
Calculating the SDF for hundreds of pieces can take a long time and is often overkill.  I may add automatic scaling of the resolution, but for now there's an example that shows how to override the resolution on just the pieces.

--RBDAutoFreeze with a relatively high "Enable threshold" is your friend.

--To temporarily turn off fracturing, just bypass the Fracture Solver.

--To avoid fracturing a particular object, set the "Group" field of the Fracture Solver to exclude that object (method may change)

--If you only want one level of fracturing, set the Min Volume to just under the volume (mass/density) of your object, or put "rdbobject1", not "rbdobject1_*" in the group field of the FractureSolver, which will exclude any pieces from further fracturing.

--If you know your geometry will fracture correctly with a high enough MaxCuts value, and you're using less than 100 or so pieces per fracture operation, it might be worth it to set the MaxCuts param of the Fracure Settings to the max number of pieces for the fracture.

Sometimes it's better than having to resim the entire thing because of bad geometry from the fracture operation.

Parameter Reference
Voronoi Fracture SOP
Group to Fracture - Primitive group to fracture
Create Inside Surface - Whether to build interior surface while fracturing
Connect Inside Edges - like Shatter SOP, connects surface polys to interior polys, usually off.
Cusp Interior Edges - just applies a Facet Sop to the "inside" group with Cusp Polygons at 40 degress
Visualize Pieces - colors primitives by piece number (should this be points?)
Piece Group Prefix - the name to prefix all piece group names with Cut Settings
Cell Point Group - a pattern/group expression that specifies a subset of points around which to cut cells
Max Cuts Per Cell - number of other cell points that will be considered when cutting a given cell
Cut Plane Offset - offsets the cutting plane by this amount to put some space between the pieces
Convex Interior Polygons - convexes the polygons generated in the interior at each step
Max Interior Edges - the number of edges a convex Polygon can have when previous option is selected

Reattach Settings
        Reattach Piece - whether to reattach pieces or not
        Iterations - number of reattach iterations
        Seed - a random seed used in picking which pieces to fuse
        Point Tolerance - the tolerance used in the Fuse operation when reattaching pieces
       
Delete Faces at Reattachment -
attempt to remove coincident polygons when reattaching Voronoi cells

Limit by Face Area Ratio - not yet implemented
Limit by Total Face Area - won't reattach if total surface area of combined piece would exceed this value 

Fracture Solver DOP
Impact Settings
Minimum Impact - an impact has to exceed this value to cause a fracture
Minimum Volume - an object has to be larger than this (mass/density) to be eligible for fracture
Re-fracture Delay - a piece must have existed for this many seconds before it can fracture again
Compute Number of Points - have Scatter automatically calculate number of points in impact volume (bit flaky)

Number of Points - min and max number of pieces that will be generated by fracture
Points per Area - used by Compute Number of Points
Location-Based Fracture - fracture based on impact location
Fracture From Magnet Force Metaballs - add the metaball geometry for any Magnet Forces to an object's impact zone
Impact Radius - the radius of each impact for location-based fracturing
Outside Radius Percentage - the point density outside the impact radius
Visualize Impact Region - visualize impact region with red/white ramp
Fracture Settings same as Voronoi Fracture SOP above

Velocity Transfer Settings

Velocity Scale - overall scale for velocity transferred to new pieces
Randomness Scale - overall scale for random velocity added to new piecesPre/Post Velocity scale - blend of pre-post impact velocity to transfer to the new pieces
Group - group of RBD Objects the Fracture Solver should solve for Fracture Pieces DOP
New Pieces Group - name of group that new pieces created by this DOP should be put in (for creation timestep only)
Group - group of RBD Objects this DOP should create new pieces for

No comments: