1 / 20

Implementing Particle Systems in OpenGL

Implementing Particle Systems in OpenGL. Information Goal. What is a Particle System? What constitutes a Particle System? How an OpenGL code is constructed to generate a particle system? Performance in Particle System. Sample Particle System. Fire and Smoke. Water.

wandan
Download Presentation

Implementing Particle Systems in OpenGL

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. Implementing Particle Systems in OpenGL

  2. Information Goal • What is a Particle System? • What constitutes a Particle System? • How an OpenGL code is constructed to generate a particle system? • Performance in Particle System

  3. Sample Particle System Fire and Smoke Water

  4. What is a Particle System? • A particle system - collection of many minute particles that together represent a fuzzy object. (fog,explosions,water,dust etc) • Particles are generated into a system, move and change from within the system, and die from the system. • 1983,William T. Reeves • Realized conventional modeling for • creating objects with smooth, • well-defined surfaces wouldn't do • the trick • Natural phenomenon- better modeled as • a system of particles – behave within • a set of dynamic rules. Star Trek, The Wrath of Khan 1982

  5. Particle Systems differ in three ways from normal representations An object is represented as a cloud of primitives particles that define its volume and not as surface elements like polygons A particle system is not a static entity; its particles change form and move. Particles are created and destroyed. An object represented by a particle system is not deterministic, its shape and form is not completely specified. (Stochastic processes)

  6. Advantages: • Particle(point) simplest surface representation then polygon (same time, complex image). Simple –Easily Motion blur • Model definition – procedural & random numbers(Design time less) • Model “Alive” objects. Surface based modeling –no complex dynamics • Basic Model of Particle Systems: • For each frame of an animation sequence • New particles are generated • Each new particle - own set of attributes • Particles - existed for a predetermined time are destroyed • Remaining particles - transformed and moved according to their • dynamic attributes • Remaining particles is rendered • Procedural –Any computational model describe object dynamics

  7. Particle Phases: Generation, Dynamics, and Death. • Generation : generated randomly with a shape that may change attributes –initial value, fixed or stochastic process • Particle Dynamics : particle attributes change over time. (color, position) Particle attributes functions of time or other attributes Example- position dependent on velocity and time • Extinction – age and lifetime attributes deal with length of existence Age – Time a particle has been alive. It is “0” when particle created Lifetime – Max time the particle can live if age matches lifetime –destroyed There can be other criteria for destroying particles

  8. Particle attributes: For each new particle initial position initial velocity (speed and direction) initial size initial color initial transparency shape lifetime The generation shape describes the initial direction of new particles. Position in 3d define its origin,2 angles of rotation giving orientation, Generation shape –new particles placed.

  9. Particle Structure: Struct Particle { float pInitial ; // Initial Position float vInitial ; // Initial Velocity float tInitial ; // Time when particle was created float acceleration; // Particle acceleration floatpFinal ; // Final Position float color ; // Particle color float size ; // Particle size float globalTime; //Global time float time; // Relative time or age } Particle system behave according to simple vector kinematic equations from physics.

  10. Computing Particle Attributes: Global time is “0”,incremented How long a particle is active? float time = globalTime - tInitial; Final Position : float pFinal = pInitial + vInitial * t + 0.5 * acceleration * t * t; Color and size functions of time (Random) Xnew = Xold + Vold * Time change; Vnew = Vold + a * Time change; F = ma;

  11. The basic process is: Emitter Random Number Generator Update Render

  12. Emitter: Acts as 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. If Dead removed from emitter. Functions define behavior of particles as they move through the scene Render: How particles are displayed on screen? Points, Polygons around the points ,then apply textures(Billboard),3D model or Point Sprites. Point sprites assigns texture coordinates for each corner vertex, alter the particle appearance from Square to any textured image.

  13. Particle Manager • It is used to control many particle systems • In charge for creating, releasing, updating and rendering systems. • Array of pointers to particle systems • Functions like AddSystem, RemoveSystem, Update ,Render can • to deal with the particle systems. Particle Manager Particle System Particle System Particle Particle Particle Particle

  14. Optimizing Particle systems: Minimize texture swapping : advantage to render particles with similar texture in sequence Implementing Level of Detail : number of new particles must vary based on existing particles Particle effect is far from the camera, occupy only a few pixels of screen space - not necessary to introduce many particles. Efficient Memory Access: Tag dead particles as inactive and use them once again for introducing new particles. Reduces overhead due to creation, initialization and destruction Render particles in batch so that GPU is busy.Longer loads make GPU idle

  15. Optimizing Particle systems: Reduce Memory and Computation Requirements with Custom Structures and Update Routines : code several different types of particle classes for certain effects Store shared variables only once. Increases efficiency - referencing one variable many times. Fast Random Number Generation: avoid random numbers pre-computing several effects and storing them and use the stored effect. Drawback : more memory, no random effect Fast Dynamic Storage Structures: Vectors, lists and arrays. Vectors are faster than Lists in terms of initialization speed and access speed.

  16. Environment and system interaction: Global environment Gravity Environment has external factors acting on particles Particles effect environment, vice versa Single global environment handles little interaction between particle systems and environment

  17. Environment and system interaction: Local Environment 1 Gravity Local Environment 2 Gravity Influence of different parameters in different environments For more interactions, subdivided into localized environments

  18. Environment and system interaction: • Degree of control –small and more or few and large • Rising Smoke –top of flame • Lower part –Larger environments particle movement uniform • Upper part –more environments to give a chaotic behavior

  19. Environment and system interaction: Local environments borders can overlap Drastic change in parameters reflect on particle behavior Overlap- Parameters are averaged Computation cost Increase environments increases rendering time

  20. Questions …..

More Related