This project builds a physics simulation system especially for cloth.
Part I: Masses and springs
This part includes populating masses and springs in the simulated cloth, which is simulated using mass and spring model.
Springs consist three types: Structral, Shearing, and Bending.
A Cloth with all its springs shown
|
Shearing Springs
|
Structral and Bending Springs
|
Part II: Simulation via numerical integration
A lower ks, the spring constant, makes the cloth softer and looser. A higher ks, stronger springs, makes the cloth harder and if too high, makes the springs and masses system more chaotic.
Density affects the mass of each mass in the system, so dense cloth makes the spring less effective, and a cloth less dense could show more effect of the spring, and if too low, the system could become chaotic.
Higher density is effectively same as lower ks, the cloth is streched more downwards.
Lower damping makes the cloth swing more before it comes to rest, and it will reduce its damping effect on the system's entrophy: the cloth could explode if damping is too low.
Higher damping makes the cloth come to rest faster with less swings. It also greatly reduces the velocity of cloth masses.
Default Everything
Higher Spring Constant
|
Lower Spring Constant
|
Higher Density
|
Lower Density Makes Chao
|
Higher Damping
|
Lower Damping
|
Part III: Handling collisions with other objects
Watching low ks cloth falling onto a sphere is very satisfying, here we go.
ks=500 N/m
|
ks=5000 N/m
|
ks=50000 N/m
|
and Here Lays the Green Cheese
|
Part IV: Handling self-collisions
Denser cloth and higher ks would make the cloth fold on itself more compactly. On the other hand, less density and lower ks would make the cloth more sparse as it folds.
Part V: Shaders
A shader program is a small parallel program that takes in information per vertex and process that information for the next stage in the pipeline. Multiple instance will be run in parallel on GPU.
A vertex shader processes vertice as in the rasterization pipleine, and a fragment shader takes the output from vectex shader and determines the final color of that fragment.
A fragment shader is like BSDF in raytracing: It determines the overall look to the material and what kinds of lighting effect will be on the surface.
Blinn-Phong Shading
Blinn-Phong shading is a shading model that produce realistic lighting effect without the computing burden of raytracing. It consists of ambient effect, diffuse effect, and specular effect.
Ambient Component
|
Diffuse Component
|
Specular Component
|
Blinn-Phong Model
|
Texture Map Shading
Texture Map Shading with some Custom Texture
Bump Map Shading and Displacement Shading
Bump Mapping
|
Bump Mapping
|
Displacement Mapping
|
Displacement mapping is more realistic but might change the geometery too much. However, the parameter can be adjusted to reduce the change in geometery.
Bump mapping model changes less drastically than displacement mapping model as the coarseness changed.
Bump Map Shading and Displacement Shading
Cloth Mirror
|
Sphere Mirror
|