For this project, we created a cloth simulator that uses point mass and spring to mimice the behavior of cloth. In order to inmitate the physical features of cloth, I took account of springs constrains and gravity via numerical simulation. I also implemented the scenario where the cloth collides with other projects and itself. Later I added different shaders that run in parallel on GPU with GLSL language. Resulting in faster rendering.
For Part I: First we need to creat a space of masses. Then depending if the orientation is Horizontal or Vertical to set y corrdinates to 1 or set z corrdinates offset. Then use a bool pin to keep track which point is being pinned. Then construct spings depending on their functions: STRUCTURAL, SHEARING, or BENDING.
|
|
|
For Part II: Inorder to mimic the behavior of cloth we need to enable spring constants depending on the type of the spring through out movements(Because the bending constraint should be weaker). Then we need to compute each point mass's change in position via Verlet integration and update constrain positions.
|
|
|
|
Ks is the spring constant. Changing which theoriticaly would change the "hardness" of the cloth. As we can see in the images where k = 5000, 2000, 500, 10; the bigger the ks value is the more hard or streched the cloth is. And the smaller the ks vlue is the more elastic the cloth is.
|
|
|
|
Density value indecate how "heavy" the point mass are. With the same ks value the smaller the density value is the more powerful the springs are thus more "held together". With greater density value the more elastic the cloth is, the more pulled down the cloth is by gravity.
|
|
|
|
One thing that stands out is that with greater damp value the slowier the motion is. And when the damping value is 0% the motion does not seem to stop. Damping value affects the energy that is lost in the process of motion. Thus with low damping value where there is no energy loss, thus resulting in the cloth swings back and force non-stop. With a higher damping value the more energy is lost in the process thus the motion takes longer due to the effects by air resistance.
For Part III: First I impemented what happens when cloth collides with a sphere. We will know if those have interaction when the pointmass' position is within r away from the origin of the sephere. Then, we calculate the tangent and correction. Finally we update point mass' positions. Secondly, I inplemented what happens when the cloth collides with a plane. Simmilar to what we did with sphere collisions, we need to determine if the poinmass is on the other side of the plane.
|
|
|
Like what we discovered earlier, with greater ks values comes greater hardness. Meaning the higher the ks value is the less soft the colth is. As we can see in the images: with ks of 500 the cloth is very soft and it drips all the way down, while when ks is 50000 the cloth is like it is made of rubber or other harder materials. PS: I used phong shades with a little transparency.
|
For Part IV: We devide all of the cloth into individual 3D boxes with different pointmass. For each 3Dbox we hash through the positions of pointmass. And build a hash table to determine which pointmass is close to other pointmass. And finally we can go through all pointmass with reference of the hash table to determine if pointmass contacts with others.
|
|
|
|
|
|
I used "Normal" shader to deliver this part since it shows better results.
|
|
|
|
With smaller ks value, we can clearly see that the cloth is more elastic. Thus resulting in more motions until reched to the resting phase. It seems like the cloth is tinkling for quite a bit.
|
|
|
|
With smaller ks density, we can clearly see that the cloth is less elastic. Thus giving the cloth a rubber or leather feel. Resulting to fewer wrinkles.
For Part V: A shader is a smaller program runs on GPU which manipulate the scene before the image is drawn on to the screen. For this assignment we used vertex shaders which uses to modify the position of vertex, color, and texture coordinates. Adding more elements like color to the vertices that already exits(Mesh is made up by 3 vertex). We pass in gl_position to tell the shader where the vertex is rendered. Than we put the vec4 into the fragment shader to get the values of the pixels in that vertex.
To better understand, Blinn-Phong Shading takes ambient shading(where we can get the geometric shapes since there is no relection), diffuse shading, and specular shading(Or High lights) and put them together to give a more realistic shader.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For bump shader the main idea is to modify the normal vectors of a mesh thus resulting a texture feel. As we but tags -o16 -a16 and -o128 -a128 on to the sphere inorder to change the quality of the sphere(more pointy). As we can see the result does not differ that much.
For displacement shader the main idea is to also modify the positions as well as the normal vectors like what we did in bump shader. As we but tags -o16 -a16 and -o128 -a128 on to the sphere inorder to change the quality of the sphere(more pointy). As we can see the sphere changes dramticly. The one with 16 tag maintained the pointy look while the one with 128 tag is more similar to the original.
|
|