Particle Systems - Overview

721 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
721
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Particle Systems - Overview

  1. 1. Particle System - Overview Luca Mella Universit` di Bologna a luca.mella@studio.unibo.it 9 dicembre 2011
  2. 2. Outline I Introduction Particle systems Newtonian Particles ODEs evaluation Particle System Dynamics Newtonian Particles System Taxonomy Indipendent particles Interdependent particles Complexity Contraints Collisions Detection Reaction Soft Constraints Particle System Design Particle Attributes Particle Generation Particle Dynamics Particle Extinction Particle Hierarchy Particle Rendering A Particle System Model
  3. 3. Introduction I Problems with classical modelling techniques Modelling geometric objects describing them in terms of surfaces or sets of convex (planar) polygons could have limits in several cases. For instance physical objects could not fit very well with this kinds of modelling techniques, in fact model complex behaviour or natural constraints had led to procedural modelling techniques wich enforces an algorithmic approach that consider polygons generation at least only.
  4. 4. Introduction II Procedural modelling Fractals exploiting self-similarity of this particular mathematical objects for generating complex objects. Shape Grammars interpreting AST nodes and leaf with a graphical behaviour for generating complex object (even with simple grammars) Particle Systems systems of particles that are capable of complex behaviors
  5. 5. Particle systems An informal definition Particle systems are collections of particles, typically point masses, in which the dynamic behavior of the particles can be determined by the solution of sets of coupled differential equations. Modelling capabilities Fluid dynamics, wave action, turbulent behavior. Solid objects, deformable solid can be modeled as a 3-dimensional array of particles that are held together by springs. Birds behaviour Explosions Smoke and fire ...
  6. 6. Newtonian Particles I Particles obey to Newton’s second law: f = m · a Thats pretty good for calculating the state of something representable as a point. . . In fact: vi = pi ˙ 1 ai = vi = ˙ m · fi whit i ∈ 1 . . . 3 So, the state of a system of n particles is governed by a set of 6n ordinary differential equations (ODEs). In addition determinating system behaviour is possible through a set of forces {fk }
  7. 7. Newtonian Particles II Euler method Is a basic method for ODE solution approximation, relies on curve’s linear approximation. Consider p = f (p, t) ˙ t+h t+h t pdτ = p(t + h) − p(t) = ˙ t f (p, τ )dτ , supposing p ˙ closed. if h is small is possible to approximate the value of the curve with: p(t + h) ≈ p(t) + h · f (p(t), t) Approximation error results ∝ h
  8. 8. Newtonian Particles III Verlet integration method Starting from euler method is possible to directly calculate position in one step. Assumption: time step ∆t = (tn − tn−1 ) is constant pn = pn−1 + ∆t · v (∆t), vn = vn−1 + ∆t · a(∆t) pn −pn−1 pn−1 −pn−2 ⇒ vn = ∆t , vn−1 = ∆t −p n = pn−1 + (vn−1 + a∆t)∆t = pn−1 + ( pn−1∆t n−2 + a∆t)∆t and then . . . pn = 2pn−1 − pn−2 + a(∆t)∆t 2 With this equation we avoid to keep track of particle velocity, saving precious memory. NOTE: particles calculation is recently moving to GPU, so memory’s consumption issue is relevant
  9. 9. Newtonian Particles IV Particle system dynamics So the system might be described in this way: p(t) = v (t) ⇒ p(tn+1 ) ≈ p(tn ) + (tn+1 − tn )v (tn+1 ) ˙ 1 v (t) = m f (t) ⇒ ˙ v (tn+1 ) ≈ v (tn ) + (tn+1 −tn ) f (tn+1 ) m Where p : R3 → R3 , location differential form v : R3 → R3 , velocity differential form f : R3 → R3 , force differential form m ∈ R , mass scalar t ∈ R , time scalar
  10. 10. Newtonian Particles V Skeleton of a particle System Dynamics float time, delta; float state[6 ∗ n], force[3 ∗ n]; state=getInitialState(); for(time=t0; time¡timeFinal; time+=delta){ /* compute forces */ force=forceFunction(state, time); /* apply standard differential equation solver */ state=ode(force, state, time, delta); /* display result */ render(state, time); } NOTE 1: this is a possible skeleton for particle dinamics calculation, particle system design is more compex and will be discussed further NOTE 2: force computing routine might be considered a key component of the system.
  11. 11. Newtonian Particles System Taxonomy I A possible taxonomy of newtonian particle system might be done considering the type of relation needed between particles Indipendent particles , no relations between particles Interdependent particles , relations between particles
  12. 12. Indipendent particles I Indipendent particles This is the basic and simplest particles type to manage, each of them will evolve indipendently. A representative instance could be Fireworks explosion, where:   0 accelleration is a const field a = −g  0 lifetime of particles is random initial position is known initial velosity is random More generally we have can describe in similar way a lot of phemomen’s classes, like explosions, bullets or rain (richochets might require additional considerations)
  13. 13. Interdependent particles I Interdependent particles More complex system to manage, each particle is in relation with other particles. A good case study for this kind of systems is represented by deformable objects like clothes, where: particles are meant as mesh vertices. external force fields act on each particles (eg. gravity, wind. . . ) forces between adjacent particles is considered, at least till the first ring (eg. f = ks(p2 − p1))
  14. 14. Interdependent particles II Hooke’s Law, Particles and Meshes A better description of the interaction between particles could be done by this way: s = resting length of the “spring” p, q ∈ R3 as particle position (eg. adjacent particles) d = pq as spring force direction’s ks spring constant ˆ ˆ f = −ks( d − s) · d as the force, with d = d (versor) d
  15. 15. Interdependent particles III A little consideration We could also consider friction in order to better modelling this kind of interaction. . . ˙ d = p − q as velocity difference between particles. ˙ ˙ kd damping constant ˙ ˆ ff = −(ks( d − s) + kd d·d ) · d d . . . Other forces We might consider also other forces, for instance attractive or repulsive radial force fields. . . This could be good for simulating planet interaction forces for instance kr radial constant f = −kr d 3 dˆ d
  16. 16. Interdependent particles IV Complexity Considering couples of particles will increase drastically problem complexity, in fact we have O(n2 ) forces to calculate. Data structure might be used in order to keep complexity under control. Do you remember few lesson ago? Buonding volumes, space partitioning. . .
  17. 17. Contraints I Implementing a group of particles that interact each according to a set of ODEs migh not be enough to model all the real-world behaviour. In fact, model object’s collision with particles and ODEs could be not so easy in reasonable times. A possible solution is to introduce contraints in our particle system. Hard Constraint , constraints that have to be satisfied exactly, like ball bounce. Soft Constraint , need only to come close to satisfying, for exemple contraints on particle separation or distance.
  18. 18. Collisions I Collisions In order to better model this typical situation we should consider 2 phases in collision management: Detection Reaction
  19. 19. Collisions II Detection a priori algorithms which will be able to predict the trajectories of the physical particles. The instants of collision are calculated with high precision, and objects never actually interpenetrate. (not so easy in real-time scenario) a posteriori algorithms check if any objects are intersecting something. At each simulation step, a list of all intersecting objects is created, positions and velocity of these objects will be “fixed”. NOTE: real time graphics uses massively a posteriori algorithms
  20. 20. Collisions III Detection optimization Collision detection is an issue already discussed during global illumination lectures, in particular we found the same problem on raytracing algorithms. A way to speed-up detection is to use smart data structures and tecnhiques, like space partitioning (Octree, Binary Space Partition tree. . . ).
  21. 21. Collisions IV Reaction Collision reaction is similar to what happens when light reflects from a surface. In other word: Po is particle position Pc is previous position v = Po − Pc or also we might use velocity vector directly n is the surface’s normal ˆ r = v − 2(ˆ · v )ˆ n n This equation might be good in case of elastic collision, where quantity of motion (mv ) is constant before and after collision, but in case of inelastic collision is at least necessary to consider a coefficient of restitution as fraction of the normal velocity retained after the collision.
  22. 22. Soft Constraints I Soft Constraints Implementing hard constraints might result computationally hard, and maybe not feasible in real-time scenario. Another approach to implement physical laws is by relaxing contraints and, for instance, use penality function in order to make particles approximate in a good way the target law. With this approach could be possible to implement constraints in term of minimization of common energy functions like potential or kinetic energy in particle systems.
  23. 23. Particle System Design I Particle System Design Untill now we have discussed about what is a particle system and which physics is needed in order do model realistic phenomena, now we will describe what a particle system need and how could be modelled via software. In detail we need to model this aspects: Particle Attributes Particle Generation Particle Dynamics Eng Particle Extinction Particle Hierarchy Particle Rendering
  24. 24. Particle Attributes I Particle Attributes a particle is a particular object that is characterizer by:   px position = py  pz   vx velocity = vy  (applied vector in position) vz mass ∈ R+ color = a r g b shape: classical sprite or an arbitrary graphical object (mesh, plane, line. . . ) lifetime
  25. 25. Particle Generation I Particle Generation Several way can be chosen to generate particle, but considering generation a stochastic process could led to better effects. Here some example of generation: NPartsf = MeanPartsf + rnd(−1.0, +1.0) · VarPartsf In this example particles generated at frame f are calculated considering a mean rate and a semi-random variance. NPartsAf = NPartsf · PSScreenAreaf Considering particle system’s screen area as generation scale factor, in this way if particle system cover a little region of the screen there is no need to generate a lot of particles. A trick to control particle system intensity during generation might be enforced by over time the mean number of particles generated per frame. MeanPartsf = InitMeanParts + DeltaMeanParts · (f − f 0)
  26. 26. Particle Dynamics I Particle Dynamics As seen before, this is the core of all particle system. Here forces are considered and new particles position and velocity are calculated. Shapes and colour variation could be calculated too, maybe through a stochastic model.
  27. 27. Particle Extinction I Particle Extinction Several policies could be adopted in order to remove particles, for instance we can consider lifetime value, or maybe particle color intensity/transparency or also considering dinstance from particular objects.
  28. 28. Particle Hierarchy I Particle Hierarchy Key concept: particles might be particles system too. In this scenario parent’s variations (velocity,position,color. . . ) might be used as reference value for child particles system’s transformations. Through this approach is possible to realize complex particle system, for instance clouds might be modelled as an hierarchy where the root particle attribute’s defines clouds global behaviour and child particle system’s could model regions of water particles that evolve depending by root state (meant as position and velocity).
  29. 29. Particle Rendering I Particle Rendering Several techniques could be used, for instance: Single pixels or light source Triangles/quads or mesh Alpha blended sprites Marching cubes algorithms
  30. 30. Particle Rendering II Alpha blended sprites Typically particles are rendered as alpha blended sprite into the scene, and in case of particles that map to the same pixels, they are considered additive (eg.total colour of the pixel as sum of particles color). The disadvantage though is that particles are always axis-aligned and do not have a 2D rotation about the screen space z axis. To overcome this limitation, a 2D rotation e could be applied to the texture coordinates (maybe inside pixel shader).
  31. 31. Particle Rendering III Soft Particles Using particles to draw dynamic fog with sprites is not so trivial. In fact Z-buffer behaviour might lead to artifact: due to pixels is visible or not, depth values of particles are inconsistent with the true nature smoke’s cloud. A solution to this problem could be reach by accessing depth values for additional processing: if sprite is close to background, then fade sprite with background. if sprite is away from background, then sprite will be opaque. if sprite is behind background, then ignore it.
  32. 32. Particle Rendering IV Marching cubes algorithms This class of algorithm reconstrunct isosurfaces from voxels (3d pixels). Rendering particles system through isosurfaces reconstruction might be pretty good when using particles to simulate fluids dynamics.
  33. 33. A Particle System Model I And now some structural schema that might be a starting point for a Particle System implementation. . . Modules
  34. 34. A Particle System Model II Particle System
  35. 35. A Particle System Model III Particle Manager
  36. 36. References I William T. Reeves Particle SystemsmA Technique for Modeling a Class of Fuzzy ObjectsI Graphics, Vol. 2, No. 2, April 1983. Edward Angel Interactive Computer Graphics: A Top-down Approach Using OpenGL Addison-Wesley, 5th Edition (2008). Tristan Lorach Soft Particles Nvidia Simon Green Particle-based Fluid Simulation Nvidia
  37. 37. References II Lutz Latta Building a Million Particle System My Game Developers Conference 2004
  38. 38. Questions ?

×