Cell Fracture VFX
The main trick for this effect is the modification of the pivot point and vertex position.
The first step is to break the 3D model in DCC Software. There are two options: Blender and 3dsMax. While both software are capable of breaking up the 3D model into cells, the outcomes show huge differences.
From the image below we can see that within the Blender Add-On (Fig.1), the gap between each cell is noticeable, which makes the outcome unrealistic as it starts from the breaking model. In contrast, when we use the RayFire plugin 3dsMax, it breaks the model while making the gaps between each cell nearly invisible. Thus, this project uses 3dsMax for the model modification.
* Although RayFire also provides the Unity plug-in version directly, it’s too expensive (around $200), the demo version for 3dsMax is free and qualifies for most of the tasks.
Check below for the 3dsMax modification process.
Q: What is pivot paint (*UE Official Doc), and why do we use it in this project? (* This workflow was originally built for Unreal Engine for better foliage animation, yet this implementation is also achievable on Unity with some manual modification)
Three Main Reasons:
- Efficient: When creating shattering effects on a model, it’s important that each debris fragment rotates/moves/scales around/from its own pivot point to achieve realistic motion. At the same time, maintaining these fragments within a single mesh is crucial for an optimized workflow. The Pivot Painter script facilitates this by saving each fragment’s pivot data into the model’s UV channels 3 & 4. This approach allows the fragments to retain their own data of a single static mesh while enabling them to move individually based on that data. By doing so, when the model shatters, each piece can fly out and tumble convincingly, rotating around its own pivot rather than along with the model’s single origin.
- Better Animation: The Pivot Painter script stores pivot data in the UV3 and UV4 channels of the mesh. Specifically, the R and G channels of UV3 hold the X and Y coordinates of each pivot point, while UV4 contains the Z coordinate along with a random value. These values allow for variation in fragment movement, size, and scale. Instead of hand-animating each piece, artists can manipulate these values to create more dynamic and varied fracture animations. (*Here is a good demonstration showing the difference between paint vertex and using an object’s single original vertex)
- Single-Drawcall: All the debris pieces remain part of one static mesh and are animated through a vertex shader using the encoded data. This eliminates the need for multiple mesh modifications, significantly reducing rendering and computation costs.
After the modification process, we can now jump to Unity, and start shader creation.
Now that we have the pivot data stored in the UV3 & 4, we need to extract it and reassemble it as 3dsMax & Unity share different coordinate systems. The image below shows the process for conversion.
The other crucial thing we need to identify is the orientation axis of the cell, which is the axis that we want the cell to rotate along. ( Here is a detailed explanation of the pivot painter workflow, especially for the XVector). We also need to use Vertex Color to reconstruct the XVector for rotation as it’s already baked in the pivot painter tool.
The core theory behind this VFX involves vertex position and the ASE ‘Rotate Along Axis’ function. The key features are as follows.