• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created about 6 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GPU Mass-Spring Simulation Cloth in Unity

GPU Cloth Simulation

cloth with force visualization cloth with diffuse render
titleimage titleimage

This repository is about GPU based Mass-Spring Simuation in Unity. Based upon Compute Shader, calculates physics in parallel.

This project is a sub project of ReclothSimulation-master, a private repository, some of features are removed in this repo.

  • Mass Spring System Cloth
  • Inter Object Collision-Response
  • Self Collision-Response
  • Dynamic Collider Generation

Currently Confirmed working on following platforms:

  • Unity Engine version 5.6.1f2 ~ 2018.2.0b10
  • Windows(OpenGL Core)
  • Android(OpenGL Core)

How to use

Create a empty GameObject on hierarchy panel and append ClothSimuation and ClothRenderer scripts on it. Since this simulation calculates with its own system, you'll need special materials and dedicated shaders for rendering. There are two example materials(Face Normal Rendering, Diffuse Rendering).

Attributes

Cloth Simulation

Compute Shaders
attributes description
NodeUpdateComputeShader a compute shader which updates forces, positions, velocities, etc.
TriCollisionResponseComputeShader a compute shader which calculates collision with floor
NormalComputeShader a compute shader which calculates all face normals of the cloth model
Attribute of Cloth
attributes description
VertexColumn numbers of nodes in a Column
VertexRow numbers of nodes in a Row
ClothSize Size of cloth object in Unity world scale
ClothMass Mass of cloth object
Looper amount of looping compute shaders per frame, larger number for precise, slower simulation
Constant for Cloth
attributes description
SpringK spring force from Hooke's Law
Damping damping coefficient for cloth simulation
External Force external forces such as wind, water etc. since it is public member, you can pass from external scripts

Cloth Renderer

attributes description
Mat a material for Cloth Object.
LightGameObject a light-type Gameobject, especially for diffuse rendering. Directional light recommended.
MeshTopology which element to draw Cloth: currently triangles supported, but you can write your own shader for others.

Caveats

Since the simulation is not pretty stable, certain values for the clothSimulation scripts are recommended:

recommended parameters of Attribute of Cloth

attributes values
vertexColumn 8 ~ 64
vertexRow 8 ~ 64
Looper 20 ~ 500, larger values for more stable simulation

recommended parameters of Constant of Cloth

attributes values
SpringK 10000~ 50000, but for a non-elastic behaving typical cloth, values around 35000 is recommeded
Damping 100~200, can be vary by SpringK

recommended parameters of Cloth Renderer

attributes values
Mat requires custom shaders, look at the normalShader and DifwithShadows in shader->render directory.
LightGameObject Directional Light is highly recommended
MeshTopology You can use all of MeshTopology types, but you should write your own shaders. The embedded two shaders use MeshTopology.Triangles.

Performance

Since this project uses Unity engine and GPU computing, it runs on most platforms, even mobile in real-time. But the performance heavily depends on the size of the model's triangles which you want to make it collided

Contact

You can contact Minsang Kim via e-mail([email protected]).

License

This Project is licensed under the MIT License

Copyright (c) 2018 Minsang Kim

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Acknowledge

This work was supported by the National Research Foundation of Korea(NRF) grant funded by the Korea government(Ministry of Science, ICT & Future Planning) (No. 2017R1A2B1005207).

More Repositories

1

Functional-Study_

A Functional programming study area
F#
5
star
2

Jameson

JSON comparing tool written in F#
F#
3
star
3

picomi

๐Ÿ“ธ take a picture when git commit happens. seize the moment!
TypeScript
3
star
4

eslint-plugin-strict-pattern-matching

TypeScript
3
star
5

Layer-Card

3-D deconstructable card layout
CSS
2
star
6

focusable-card

a fancy style card-carousel
Vue
2
star
7

Al-Kata

Python
2
star
8

PROJECT_GAMEMAKER-V2

C
2
star
9

ts-pattern-bench

comparing ts-pattern's performance with its nested ifelse/ternary altnatives
JavaScript
2
star
10

ts-training-wheel

๋†“์น˜๋Š” ๊ฒƒ๋“ค์„ ๋„์™€์ฃผ๋Š” ๋„๊ตฌ
TypeScript
2
star
11

Rescript-soup

my own rescript hardlanding histories
1
star
12

React-soup

Learning React Study Area
1
star
13

GoogleWebHackaton

Vue
1
star
14

shopping-milk-but

a sample code example for shopping-milk-and-egg-but scenario
TypeScript
1
star
15

TIL

1
star
16

splay

Java
1
star
17

JSTM

justie.dev
TypeScript
1
star
18

Development_Literature

์šฐ๋ฆฌ๊ฐ€ ์šฐ์ฃผ์— ์ƒˆ๊ธฐ๋Š” ํ ์ง‘๋“ค์˜ ์‚ฐ๋ž€
1
star
19

-LEFT

Lite Edition of Functional-Typescript
TypeScript
1
star
20

FlowerSoup

F# language study area
F#
1
star
21

phone-kr-ts

๋Œ€ํ•œ๋ฏผ๊ตญ์˜ ์ „ํ™”๋ฒˆํ˜ธ ์ฒด๊ณ„์— ๋งž๋Š” ๋ฌธ์ž์—ด๋“ค์„ ์œ„ํ•˜์—ฌ
1
star
22

OS-ya

A Single-thread CPU scheduling simulator for operating system class term project
C#
1
star
23

graphics-Catmull-RomSpline

C++
1
star
24

bootcamp-aoc

ยฏ\_(ใƒ„)_/ยฏ PPAP : Parse, Process, Aggregate, Print
ReScript
1
star
25

boro-belt-snippet

TypeScript
1
star
26

aoc-2023

TypeScript
1
star