GPUClothSimulationInUnity
Trying to replicate what this legend did: https://youtu.be/kCGHXlLR3l8
Install / Use
/learn @nixonyh/GPUClothSimulationInUnityREADME
GPU Cloth Simulation For Real-time Application
This repository is still currently under development, so everything is still in testing mode. A lot of things will break, download at your own risk :/
Disclaimer: This project is in a paused state so there won't be more updates. In the future, if there are any changes to this project, I will post an issue update on this repository. Stay tune!
My goal is to replicate what this legend did: https://youtu.be/kCGHXlLR3l8 (A smooth and interactive cloth simulation)
Currently, my cloth simulation uses Postion Based Dynamics and supports:
- Distance Constraint
- Bending Constraint
- Point Triangle Distance Constraint (Self Collision)
- Aerodynamics (Wind Effect)
Features comming soon:
- Vivace Gauss Seidel Method for optimization on GPU (random graph coloring)
- Primitive Shape Collision (Sphere, Box and Capsule)
Check out my YouTube Playlist where I record my journey on how I approach this problem!
Support me on Patreon so that I can allocate more time to work on this project!
How to use?
*Note: The GPU version is not fully developed yet, this tutorial section will not work for the GPU version.
- Create a mesh in Blender that you want to simulate.
- Use my custom Blender Addon - Blender Mesh to JSON to transform your mesh into PBD form and export it into your Unity's
StreamingAssetsfolder. - Create an empty GameObject in Unity.
- Drag and drop
CPUClothSimulation.csorGPUClothSimulation.csscript onto the GameObject. (Check Cloth Configurations for more cloth parameters' information.) - Select the correct JSON file that the Blender Cloth Exporter Tool exports using the button -
Select JSON File. - Press the button -
Load Data from JSON. - Put in your
Front MaterialandBack Material. - Press
Build Meshto build the mesh that you have modeled in Blender. - Press
Create Back Sideto build the other side of the mesh. - Press
Apply Materialsto apply materials on both sides.
Cloth Configurations
These are the similar parameters in both CPU and GPU Cloth Simulation:
This determines the front material and back material for the cloth.
Tweak these parameters to change the behaviour for the cloth.
- Gravity: Constant acceleration.
- Compression Stiffness: Coefficient for distance constraint when 2 particles are too close together.
- Stretch Stiffness: Coefficient for distance constraint when 2 particles are too far away.
- Bending Stiffness: Coefficient for bending constraint when 2 neighbor triangles are not at their rest angle.
- Thickness: Cloth thickness for all collisions.
- Damping: Multiplier of velocity for every simulation to reduce velocity (as air resistance).
Tweak these parameters to balance between accuracy and performance.
- Iteration Steps: Number of iterations to solve constraints for every simulation.
- Delta Time Step: Time pass between 2 simulations.
- Start Simulation On Play: Choose if you want to start the simulation once you enter play mode.
License
This project is under MIT License.
Related Skills
node-connect
335.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
335.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.5kCommit, push, and open a PR
