Introduction

This document contains the API documentation, usage examples, etc., for the Trilinear Mesh Interpolation plugin available for Unreal Engine 5 on FAB.

This is a form of simplified mesh deformation, which allows you to twist, squash and stretch any mesh by manipulating a small number of control points.

The deformation can be applied at run-time, either computed on the GPU for cosmetic effects or on the CPU for meshes whose deformation influences gameplay (e.g. when a mesh's collision needs to match its deformed state), or during level editing to allow designers to tweak and reuse existing meshes in new and interesting ways.

Usage & Examples

Concepts

The basic idea behind Trilinear Mesh Interpolation is this: enclose your mesh in a box (typically referred to here as the Lattice). The default state of the box essentially matches the mesh's bounding box. When the corners of the box are moved, the mesh deforms to move with it, with vertices close to the moved corner moving about the same as the corner and vertices far from the moved corner not being affected at all. Vertices will always move to maintain their position within the lattice, relative to each corner.

This allows, for example, a mesh to be greatly deformed while maintaining its footprint on the ground:

Lattice values are treated as offsets. If the lattice corners all have the value (0,0,0), then the mesh will be untransformed and will appear in its original state.

Two Approaches to Interpolation

This plugin provides two approaches to trilinear interpolation. Visually, they will produce the same results, but which approach you should prefer to use may depend on your use case.

WPO-Based Material Shader

The trilinear interpolation can be performed entirely in a shader, allowing for the effect to be performed on the GPU.

This is very fast, and can be used on meshes with a high vertex count and can support a large number of meshes all deforming together in a scene at real-time. However, the effect is purely visual, the collision geometry of the mesh, etc., is unchanged.

If you need to animate the effect, particularly if you need a LOT of objects all bouncing and twisting around in a scene together, this is the recommended approach.

If you just need to apply the effect once, for example in-editor or during a procedural level generation step, or if you need collision geometry to match the deformed mesh, then you should use the DynamicMesh-based approach.

DynamicMesh

In this approach, the trilinear interpolation is performed on the CPU to modify a given mesh. The underlying C++ code has been optimized to parallelize this work where possible, so you can still use this to perform real-time deformation on detailed meshes or on a number of simple meshes in a scene, but performance will be limited by the total number of vertices you need to process in a given frame.

But, because we are processing the mesh data on the CPU we can also process a mesh's collision data, so you can use this to tweak the angle of a slope and then have your character walk on it.

This approach is best used sparingly or on meshes which only need to be deformed once (e.g. in-editor or as part of a procedural level generation step).

Pages






For any questions, help, suggestions or feature requests, please feel free to contact me at nbpsup@gmail.com