Cloth TOP
This project demonstrates how to use NVIDIA FleX solver for GPU cloth simulation in a TouchDesigner Custom Operator. It also shows how to render dynamic meshes from texture data using custom vertex/geometry shaders and TouchDesigner's PBR lighting functions.
Features:
- Soft body (cloth, inflatable) simulation with controllable anchor points.
- Static and dynamic triangle mesh collision.
- Spheres, boxes and planes collisions.
- Radial forcefields.
- Configurable parameters like wind, gravity, adherence, etc.
Samples
Cloth body with animated anchor points (sample_clt_cloak.toe)
Inflatable body with dynamic pressure constraint (sample_clt_inflatable.toe)
Complex triangle mesh collider with multiple bodies (sample_clt_dali.toe)
Install NVIDIA FleX
- Download FleX 1.2 (get access here).
- Create a new environment variable called
NvFlexDir
that holds the path to/flex
(folder you've unpacked).
Compilation
- Install the CUDA SDK you want to use.
- Generate a Visual Studio 2019/2022 project using CMake. For example, run this command on Windows Terminal:
cmake -Hc:/Documents/git/TouchDesigner/Plugins/ClothTOP -Bc:/Documents/git/TouchDesigner/ Plugins/ClothTOP/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
- Building will automatically copy the .dll to the Plugins folder. If using a release dll, manually place it here.
- Open a sample with TouchDesigner 2021.14360+ (tested on Windows 11).
Assets
- Dali 3D model (download and place the .fbx next to sample_clt_dali.toe)
- Cloak 3D model (already locked in sample_clt_cloak.toe)
References
- The FlexCHOP by Vincent Houzé provided a starting point for this project.
Known Issues
- Moving anchors too fast can cause crashes when the solver can't converge for large position deltas.
- Lack of robust error checking for input meshes.