Giter Site home page Giter Site logo

cis565-final-webgl-cloth-simulation's Introduction

WebGL Cloth Simulation

by: Ziwei Zong

  1. Overview

Cloth Simulation using transform feedback for WebGL 2.0 supported browsers and ping-ponging texture method for browsers only supporting WebGL 1.0.

Using Brandon Jones's WebGL 2 Particle Simulation as framework.

WebGL 2.0 version tested successfully on Chrome(Windows), Chrome Canary (Windows), FireFox(Mac)

WebGL 1.0 version tested successfully on Chrome(Windows,Mac), Chrome Canary (Windows), FireFox (Windows)

  1. Instructions

1.1 How to use

1.1.1 Enable WebGL 2.0

Follow the instruction from WebGL Wiki to enable your browser with WebGL2.

1.1.2 Features

  • WebGL 1.0 & WebGL 2.0

    If the project is running on browser that supports only WebGL 1.0, there would be a "WebGL Cloth Simulaiton" object in the scene. Otherwise, if the browser supports WebGL 2.0, there would be "WebGL 2 Cloth Simulation" instead and the simulation is using transform feedback.

    WebGL 1.0 ScreenShot WebGL 2.0 ScreenShot
  • Settings and Basic Animation Control

    |

    • Render Mode

      Points Triangle
  • Interactions

    • RigidBody

      Cloth-Rigidbody collision is more stable in WebGL2 implementation than in WebGL1.

      WebGL 1.0 Rigidbody WebGL 2.0 Rigidbody
    • Wind

      TODO: add pic here

    • Pins

      There are two kinds of pins: pin points and pin edges. Select them under Interaction_Folder->Edges or ->Pins

      WebGL 2 version is supporting movable pin.

      TODO: movable pin gif.

1.2 Implementation

Ping-ponging Texture

Transform Feedback

Mass-Spring Cloth Simulation

Unsolved

  • Different Browsers

  • Uniform Buffer Object

  1. Performance Analysis

2.1 Cloth Dimension (Particle Number)

Performance

Simulation Result

Cloth Dimension could also effect simulation results.

When the mass of single cloth particle is constant. Same set of string parameters could turn into different cloth behavior with differenct particle counts. Below are clothes with 2020, 5050, 100100 and 150150 particles respectively and they are simulated with the same set of settings.

20*20 50*50 100*100 150*150

To get the same simulation result as cloth with lower particle count, we need to decrease the value of single particle mass, or increase the value of string parameters. Either way, a smaller timestep is always needed to ensure a stable system.

timestep:0.001 timestep:0.003

2.2 Code Quality

  • WebGL1 version is simulating within fragment shader. Most of the code are through Three.js shaderMaterial. WebGL2 version is using transform feedback and doing the simulation in the Vertex Shader. Thus, there are more OpenGL codes and operations. This makes the WebGL1 version's code more readable and compact.

3.References

WebGL 2.0 Particles

OpenGL Insights.Chap 17

Game Engine Gems 2.Chap 22

cis565-final-webgl-cloth-simulation's People

Contributors

zammiez avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.