1 / 31

Particle Systems

Particle Systems. Advanced 3D Computer Graphics Behzad akbari Professor Burton Ma CSE 4431, Winter 2011. History of Particle Systems:. For the first time in 1978 in a short movie” Asteroids” in “Star Trek II: The Wrath of Kahn” 1983 it used , they used planetary fire wall.

miller
Download Presentation

Particle Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Particle Systems Advanced 3D Computer Graphics Behzadakbari Professor Burton Ma CSE 4431, Winter 2011

  2. History of Particle Systems: For the first time in 1978 in a short movie” Asteroids” in “Star Trek II: The Wrath of Kahn” 1983 it used , they used planetary fire wall. The first CG paper about particle systems by William T. Reeves published in that year. [4]

  3. What is particle system? a system to control collection of a number of individual elements (points, line, triangle or Sprit texture) which act independently but share some common attributes: [6] • position (3D) • velocity (vector: speed and direction) • color +(transparency) • lifetime • size, shape

  4. Applications solution to modeling fuzzy, amorphous(changeable), dynamic and fluid objects likesmoke,fire,sparks,Rain,snow,Waterspray,explosions, Galaxies

  5. Process Steps for Particle System Random Generator: the input of Emitter Emitter:source of particles and its position determine where they are generated.Controls number of particles, direction and other global settings Update:Particles attributes are updated before Dead(extinction) some unctionsdefine behavior of particles as they move through the scene

  6. Process Steps for Particle System(cont) Render:How particles are displayed on screen? • Points • Lines (from last position to current position) • Sprites (textured quad’s facing the camera) • Geometry (small objects…)

  7. Basic particle system physics Particles in 3D space affected by forces (e.g. gravity or wind) which accelerate a Particle and acceleration changes velocity and Velocity changes position. We have two integration about movement: a)Euler Integration [14]

  8. Basic particle system physics(cont.) b)Verlet Integration [15] Integrate acceleration to position: This formula needs no storage of particle velocity but time step needs to be (almost) constant. (complex velocity operations like collision reaction )

  9. Particle Simulation on the GPU In the graphic systems we have 2 type of particle systems: ● Stateless simulation It only can use for simple effects. The Simulation is in vertex shader (possible on first generation programmable GPUs) ● State-preserving (iterative) simulation Simulation with textures and pixel shaders (can execute only on recent generation GPUs)

  10. Stateless particle systems • No storage of varying particle data • Evaluation of closed form function describing movement/attribute changes • Computed data depends only on initial values and static environment description

  11. Constant acceleration (cont)[1] When a is constant:[1]

  12. Attributes ● Position depends on initial position, initial velocity and gravity: ● Orientation depends on initial orientation and rotation velocity: ●Color and transparency depend on linear function with four key (k0,k1,to,t1) variables

  13. Algorithm of Stateless PS in GLSL We change Particles in 2 stages:

  14. Computing Particle Attributes • Global time is “0” • How long a particle is active? time = globalTime– tInitial; • Final Position : pFinal = pInitial + vInitial * t + 0.5 * acceleration * t * t; • Color and size functions of time (Random) or staticfunctions Compute the new : • Xnew = Xold + Vold * Time change; • Vnew = Vold + a * Time change;

  15. State Preserving Simulation ● Position and velocity stored in textures ● From these textures each simulation step renders into equally sized other textures ● Fragment shaderperforms iterative integration ● Position textures are “re-interpreted” as vertex data ● Rendering of point sprites/triangles/quads

  16. Storage of particle data in SP • Position and velocity stored in 2D textures. • Textures treated as 1D array. Precision can be position 32bit FP, velocity 16bit FP . • Static information are: Time of birth, type ID.

  17. Algorithm for one time step(preserve state) 1. Process birth and death 2. Velocity operations (forces, collisions, dampening) 3. Position operations 4. Sorting for alpha blending (optional) 5. Transfer pixel to vertex data 6. Rendering

  18. Birth of a particle/allocation[1] ● Perform allocation on the CPU: – Determine next free index – Determine initial particle values – Render initial values as pixel-size points

  19. Death of Particles ● Processed independently on CPU and GPU ● CPU: Free particle index, re-add it to allocator ● GPU: Move particles to infinity (or very far away) ● or particles fall out of view,

  20. Velocity operations ● Update velocity textures with various operations: – Global forces(gravity) – Local forces – Dampening – Collisions – Flow field [12]

  21. Global and local forces ● Global forces are position-invariant: Gravity, wind ● Local forces fall off based on distance: Magnet, orbiting, turbulence, Fall off with ● change scaleeffect based on mass, air resistance etc.

  22. Global and Local Forces (cont.) ● Add all forces to one force vector ● Convert force to acceleration (f = m.a) (identical if all particles have unit mass)

  23. Dampening and Un-dampening – Scale down velocity vector – Simulates slow down in viscous (sticky) materials ● Un-dampening: – Scale up velocity vector – Simulates self-moving objects, e.g. bee swarm

  24. Collision ● Collision on GPU limited for efficiency: ● Algorithm: 1. Detect collision with expected new position 2. Determine surface normal at approximate point 3. React on collision, i.e. alter velocity ● Split velocity (relative to collider) into normal vn and tangential vt component:[1]

  25. Position update ● Euler integration: – Simply apply velocity ● Verlet integration: – Apply acceleration caused by forces – Apply other effects like dampening and collision.

  26. Sorting for Alpha-Blending ● Alpha-blended particles show artifacts when rendered unsorted The GPU can sort nowadays... – Put viewer-distance and index into a texture – Sort this texture (at least partially)

  27. Sorting networks GPU needs parallel sorting We need to use a data-independent algorithm..Efficient algorithm is Odd-Even Merge Sort which is like this: [1]

  28. Transfer particle to sprites • we need to transfer particle positions to geometry data. • Point sprites allow most efficient transfer only one vertex per particle. • Triangles or quads need replicated vertices. • Several methods to transfer texture data to vertices exist:Über-Buffer • It can Store any data in graphics card memory. Copy from one buffer (here texture) to another buffer (here vertex buffer). • Available on (GFFX, R9xxx).OpenGL-only, OpenGL extensions: ARB_super_buffer, NV_pixel_buffer_object, NV_pixel_data_range.

  29. Multiple particle textures We can Combine several textures as sub-textures of one larger texture – Adjust texture coords. accordingly – For point sprites: Transform tex.coords. in fragment shader

  30. Rendering Particles display as(OpenGL points, (Textured) billboardedquads, Point sprites[6]) Sample code: glTexEnvf(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE); glEnable(GL_POINT_SPRITE); glBegin(GL_POINTS); glVertex3f(position.x, position.y, position.z); glEnd(); glDisable(GL_POINT_SPRITE);

  31. Reference: • [1][Building a Million Particle System Lutz Latta Massive Development GmbH] http://www.2ld.de/gdc2004/MegaParticlesSlides.pdf • [2]OpenGL Extensions & Advanced rendering https://home.zhaw.ch/~frp/CGr/Unterlagen/12_OpenGL_Advanced.pdf] • [3] Implementing Particle Systems in OpenGL SPSU (southern polytechnic state university) • [4]http://www.lri.fr/~mbl/ENS/IG2/devoir2/files/docs/fuzzyParticles.pdf • [5] http://www.naturewizard.com/tutorial08.html • [6] Jürgen P. Schulze, Ph.D.University of California, San Diego Fall Quarter 2011, Lecture #18 • [7]Computer Graphics Lecture Notes University of Toronto November 24, 2006 • [8]lecture on Advanced Computer Graphics by Bas Zalmstra and Marries van de Hoef • [9] Procedural Smoke Particle System with OpenGL 2.0 Tommy Hinks – tomhi761@student.liu.se • [10]http://en.wikipedia.org/wiki/Particle_system • [11] http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter06.html • [12]Particle Animation and Rendering Using Data Parallel Computation Karl Sims • [14] http://en.wikipedia.org/wiki/Euler_equations_(fluid_dynamics) • [15] http://en.wikipedia.org/wiki/Verlet_integration

More Related