Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ......
-
Upload
phungtuong -
Category
Documents
-
view
218 -
download
0
Transcript of Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ......
![Page 1: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/1.jpg)
Particle Based Simulations Using GPUs
Yalmar Ponce
Claudio Esperança
![Page 2: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/2.jpg)
Outline
• Environment configuration
– Linux, Windows, OSX (if necessary)
• Particles simulation
– Collision detection
• Rigid bodies simulation
– From particles to bodies
– Collision detection
– From bodies to particles
• Soft bodies simulation (similar to rigid bodies)
• SPH
![Page 3: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/3.jpg)
ENVIRONMENT CONFIGURATION
![Page 4: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/4.jpg)
C++ and CUDA
• Currently C++ and CUDA are supported by the most popular operating systems
– Linux
– Windows
– OSX
![Page 5: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/5.jpg)
What is required in Linux?
• Suppose we have a NVIDIA card (ATI must be similar)
– Fedora
• Install gcc compiler (4.8 or later)
• Download driver from NVIDIA
• Run Fedora on runlevel 3
• Install the driver and restart
• Download and install CUDA SDK and ToolKit
• A good source code editor like Geany is recommended
![Page 6: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/6.jpg)
What is required in Windows?
• Similar to Linux but more easy
– Download NVIDIA driver and install it
– Download and install CUDA SDK and Toolkit
– A good source code editor or IDE will be required
• All CUDA samples have Ms Visual Studio Projects
• Therefore, will be necessary to have installed the Ms Visual Studio 2008 or a later version
![Page 7: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/7.jpg)
What about OpenCL?
• Notice that, so far, only OpenCL 1.1 is supported by NVIDIA hardware.
• On Linux, it is required to install the drivers from NVIDIA web page. Other drivers (from yum repositories) have no support for OpenCL
– Check if the libs libOpenCL .so.* have been copied to the correct libs directory
• For Windows there are no problems
![Page 8: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/8.jpg)
FREE PARTICLES SIMULATION
![Page 9: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/9.jpg)
Particles representation
• Particles typically are represented by small spheres with properties:
– Position
– Velocity
– Radius
– Mass
• Ideal for simulating granular materials
![Page 10: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/10.jpg)
Collision Detection
• Particles are represented by small spheres
• Brute force
– n(n-1)/2 O(n2)
• Particles interact in a small region
– Well suited to spatial subdivision methods
• Using an uniform grid
– World is a cubical grid
– Grid cells store particles
– Collision occurs only between particles on neighbor Grid cells (3d-1)
![Page 11: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/11.jpg)
Collision Detection
• Spatial Subdivision
– Uniform Grid
– Collision test only if the objects belong the same cell or adjacent cells
– A particle can be involved in more than one collision
– Cells must be processed in parallel
– NVIDIA CUDA is made for that
![Page 12: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/12.jpg)
Uniform grid
• Particles are mapped onto cells based on their centers
• Cell size = particle diameter
– For equal sized particles, assuming no inter-penetration, up to 4 particles per cell
• Collision test examines a neighborhood of 33 cells
– O(n)
![Page 13: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/13.jpg)
GPU Collision detection
• Sorting (radix sort)
• Grid is updated efficiently using sorting and search
• Supports unlimited number of particles per cell
• 3 stages
– Cell hash for each particle
– Sort particles based on hash, and
– Search sorted list of each cell
![Page 14: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/14.jpg)
GPU Collision detection
![Page 15: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/15.jpg)
GPU Collision detection
![Page 16: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/16.jpg)
GPU Collision detection
![Page 17: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/17.jpg)
Collision response
• Compute forces between collided particles
• Update positions and velocities
![Page 18: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/18.jpg)
Results
![Page 19: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/19.jpg)
RIGID BODIES SIMULATION
![Page 20: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/20.jpg)
Rigid Bodies on GPU
• Introduced by Takahiro Harada
• All operations computed on GPU (FBO-R2Tex)
– Particle dynamics
– Grid generation
– Collision detection
– Momenta computations
– Body dynamics
![Page 21: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/21.jpg)
From bodies to particles
• The goal
– Discretize the mesh body on small boxes and place a particle at each box
![Page 22: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/22.jpg)
From bodies to particles
• There are many methods
– Octree based
• Build an octree for the 3D mesh
• Can be implemented on GPUs
• Query for occupied voxels
– Image based
• Define image resolution
• Suitable for GPU
• Ray casting for getting the ocuppied voxels
![Page 23: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/23.jpg)
From bodies to particles
Ray casting technique
![Page 24: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/24.jpg)
Free particles
![Page 25: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/25.jpg)
But for Rigid Bodies?
• Particles depend on rigid body attributes
– Position and orientation
![Page 26: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/26.jpg)
Collision detection
• Similar to free particles
– First, the particles attributes are computed by using the rigid bodies positions and orientations
– Here, collision detection is done in the same way as free particles, generating repulsion forces
– Finally, these forces are added to compute a total force and total torque.
![Page 27: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/27.jpg)
Momenta computation
• Using the forces and torques compute the linear and angular velocities
• Next, compute the new positions and orientations
![Page 28: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/28.jpg)
Rigid bodies positions
Rigid bodies orientations
Particles positions
Particles velocities
Particles relative positions
Computes particle values
Uniform Grid
Forces on particles
Collision detection
Update the grid
Rigid bodies linear momentum
Rigid bodies linear momentum
Momenta computation
Update rigid bodies positions and orientations
![Page 29: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/29.jpg)
Rigid bodies formulae
• Update particle’s properties
• Compute forces on particles
• Compute forces on bodies
• Momenta computation
• Update rigid bodies’ properties
![Page 30: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/30.jpg)
Results
![Page 31: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/31.jpg)
SOFT BODIES SIMULATION
![Page 32: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/32.jpg)
Motivation
• Soft bodies' simulation opens a huge range of solid objects for many applications like games.
![Page 33: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/33.jpg)
Soft deformations
• Simulate soft bodies deformations in a computationally efficient and plausible way
![Page 34: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/34.jpg)
Simple model
• Shape matching [Muller 05]
– Solids represented by particles
– No conectivity information is needed
![Page 35: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/35.jpg)
• Given n point with positions , which represents a soft body
• Animate these points considering ext forces and it becomes deformed
• At every time step, match the current configuration to the original shape yielding goals
Basic algorithm
![Page 36: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/36.jpg)
Basic algorithm
• Pull the actual points (black) towards the goal positions (red)
![Page 37: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/37.jpg)
Basic algorithm
• It’s like applying a translation and a rotation
• In fact, we need to compute a transformation matrix
f(R,t)
![Page 38: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/38.jpg)
Algorithm
1. Find the optimal transformation matrix in order to compute the goal points.
– This is shape matching
2. Move the particles towards those goal points
![Page 39: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/39.jpg)
Shape matching
• Given and , the original shape points and the actual shape points, respectively.
• Find the rigid transform minimizing
• Optimal is center of mass of the
• Optimal is center of mass of the
![Page 40: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/40.jpg)
Optimal transformation
• Define and
• Minimize
• With optimal linear transform
![Page 41: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/41.jpg)
Optimal transformation
• Extract the rotational part
– can be precomputed
– Get the optimal R from polar decomposition of
– R is the rotation matrix
– S is a symmetric matrix
![Page 42: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/42.jpg)
Extracting R
• R is related with A
• How to find S?
– First, sqrt computation can’t be applied to matrices directly
– Then, we need diagonalize the matrix for computing the matrix sqrt
– D is a diagonal matrix and have the eigenvalues and U have the eigenvectors of the decomposition process (diagonalization)
![Page 43: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/43.jpg)
Matrix diagonalization
• Authors suggests to use Jacobi rotations
jacobi(AtA, v, U);
– 5 - 10 Jacobi rotation should be sufficient
• D is formed by the vector of eigenvalues v
• Finally,
• Note that D is inverted directly
![Page 44: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/44.jpg)
Goal positions
• After R is computed, we can compute goal points for each time step
![Page 45: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/45.jpg)
Integration
• Control stiffness setting by (rigid for = 1)
• So far, only rigid deformations can be achieved
![Page 46: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/46.jpg)
Linear deformations
• Recall that R is the polar decomposition of ( , where )
• Instead of using only R to compute the goal point, also use the matrix A
• Now, objects can get stretched
![Page 47: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/47.jpg)
Quadratic deformations
• Further, quadratic deformations allows for more awesome effects like twisting and bending
![Page 48: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/48.jpg)
Quadratic deformations
• Again, reformulate the equations considering quadratic terms and mixed terms
![Page 49: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/49.jpg)
Objects representation
• Two representations
– Particles for simulation
– Mesh for rendering
![Page 50: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/50.jpg)
From bodies to particles
• Bodies are discretized by placing particles near to mesh faces
– Naive approach
• Place small spheres for all the vertices
• Try to place using negative normals
• Remove those that are very close
![Page 51: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/51.jpg)
Soft body representation
• When bodies have complex geometries
– Particles are used for collision detection and to compute an optimal deformation matrix
– Later, the deformation matrix is applied to all vertices and normals (on faces or vertices)
![Page 52: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/52.jpg)
Original particles positions x0
i
Current particles positions xi
Updated particles positions xi
Update particles with external forces
Uniform Grid
New moved particles positions (model is deformed)
Collision detection for generating forces
Update the grid
Goal positions gi
Integrate
Compute quadratic deformation matrix
![Page 53: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/53.jpg)
Results
![Page 54: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/54.jpg)
SMOOTHED PARTICLES HYDRODYNAMICS (SPH)
![Page 55: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/55.jpg)
Motivation
• Fluids enables to simulate a large variety of natural phenomena
– Smoke
– Fire
– Liquids, etc.
![Page 56: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/56.jpg)
Introduction
• There are two main methods for modeling fluids
– Eulerian
– Lagrangian
• Point based Lagrangian methods yield high performance and easier to implement
– SPH (Smoothed Particles Hydrodynamics)
– Mesh free
![Page 57: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/57.jpg)
Introduction
• In recent years, point based simulations have become increasingly popular
• Some of the main contributors were
– Matthias Müller
– Takahiro Harada
– Simons Green
![Page 58: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/58.jpg)
What is SPH?
• Particle system with inter-particle forces/interactions
– Interactions at infinite distance yield O(n2) computational complexity
– Define interaction cutoff distance
• Less complexity
• Easier to parallelize
• First developed for use in astrophysics
– Simulation of stars / galaxies
![Page 59: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/59.jpg)
What is SPH?
• Different from other fluid simulation methods (FEM)
– Mesh free (does not consider any “surfaces”)
– Interpolation method for particle systems
![Page 60: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/60.jpg)
What is SPH?
• Each particle is affected only by the particles within a limited radius h(cutoff distance)
– Uses a “radial symmetrical smoothing kernel” to define the cutoff
h
![Page 61: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/61.jpg)
Why use SPH?
• Advantages
– Very fast/efficient compared to other fluid simulation methods
– Easy to parallelize
– Guarantees conservation of mass (particles themselves are the mass) if weighted functions are normalized
– Computes pressure from weighted contributions of neighboring particles (instead of solving linear systems of equations)
![Page 62: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/62.jpg)
But …
• Disadvantages
– Still has to reconstruct a surface to render (marching cubes, splatting, etc.)
– Needs a lot of particles for realistic simulation
![Page 63: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/63.jpg)
How to parallelize
• Use a spatial subdivision data structure
– An uniform grid
– Fill/map particles onto the grid
– Only search within a neighborhood
• For each particle, the cell to which belongs and the adjacent cells in a radius must be checked
![Page 64: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/64.jpg)
SPH dynamics
• Compute density and velocity
– Query on a neighborhood of radius h to verify particles which can contribute
h
![Page 65: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/65.jpg)
The equations of SPH
• The particle at location x is computed as a weighted sum of neighboring particles
• In the discretized functions
![Page 66: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/66.jpg)
The equations of SPH
• The governing equations (mass and momentum conservation) are simplified Navier-Stokes
•
•
•
•
•
![Page 67: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/67.jpg)
Particles’ positions Particles’ densities
Uniform Grid
Particles’ densities
Particles’ velocities
Particles’ velocities
Obstacles’ distance function
Particles’ positions
Compute densities
Update velocities
Update the grid
Update positions
![Page 68: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/68.jpg)
Results
![Page 69: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/69.jpg)
SPH rendering
• Based on gaussian smoothing
– Particles are renderized as small spheres
– This is stored as textures for smoothing
– Two buffers are used
• Depth buffer
• Normals buffer
• After the images are smoothed we can apply effects for
– Illumination, shadow, reflection and refraction
• This technique is simple and cheap
![Page 70: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/70.jpg)
EXTENSIONS
![Page 71: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/71.jpg)
Extensions
• Rigid bodies using impulses instead of forces
• Cloth simulation
• Solid-liquid coupling
• Cloth-liquid coupling
![Page 72: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/72.jpg)
Rigid bodies using impulses instead of forces
• Disadvantages for the method using forces
– Representing high resolution objects • A large particles' set could be necessary
![Page 73: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/73.jpg)
Disadvantages
• Collision response behavior looks a bit springy
• Collision between particles OK
– But with obstacles?
![Page 74: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/74.jpg)
Disadvantages
• Interpenetration between objetcs or obstacle-object
– Large forces can carry for interpenetrating objects
– Small particles do not guarantee correct separation or even any separation in some cases
![Page 75: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/75.jpg)
Rigid bodies using impulses
• Is more adequate to generate correct dynamic behavior
• In our prototipe, we use variable sized particles
![Page 76: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/76.jpg)
Rigid bodies using impulses
• Collision detection – Estimates contact points
• Collision response – Apply impulses at contact
points
• Differs from forces approach because impulses are applied sequentially
![Page 77: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/77.jpg)
Algorithm
• Save positions and orientations of objects
• Update obtects’ properties (positions, velocities and orientations)
• Update particles properties (positions and velocities)
• Update the grid
• Detect collision on particles and process them by applying impulses at contact points
– Changing objects properties
• Retrieve the objects’ saved attributes
• Update velocities of the objects
• Detect and process contacts, if still there are, by applying impulses
• Update positions and orientations of objects
![Page 78: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/78.jpg)
Cloth simulation
• Mass-spring approach
• Resolution
– Efficiency vs Performance
![Page 79: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/79.jpg)
Cloth simulation
• Collision detection
– Grid for mapping triangles
– Similar to particles collision detection
• Search on a neighborhood
![Page 80: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/80.jpg)
Solid-liquid coupling
• Collision detection unified
– SPH particles
• computes pressure and viscosity forces
– Solids particles
• computes forces for separating collided objects
![Page 81: Particle Based Simulations Using GPUs - Arequipa · Visual Studio 2008 or a later version . ... –Discretize the mesh body on small boxes and place a particle at each box ... •Particles](https://reader031.fdocuments.in/reader031/viewer/2022022021/5b9ef5a209d3f204248c8124/html5/thumbnails/81.jpg)
Cloth-liquid coupling
• Collision detection uses two grids
– Fine resolution for SPH particles
– Coarse resolution for cloth triangles
• Collision detection is done in two stages
– One for particles, searching on the two grids
– Second for triangles, searching on the two grids too