Presentation is loading. Please wait.

Presentation is loading. Please wait.

CO Games Concepts Week 22 Particle systems

Similar presentations


Presentation on theme: "CO Games Concepts Week 22 Particle systems"— Presentation transcript:

1 CO1301 - Games Concepts Week 22 Particle systems
Gareth Bellaby

2 Particle systems A particle system is a simulation of phenomenon such as smoke, rain or fire as a set of discrete particles. Discrete means separate. The different type of effects are created by changing: textures blending colour physics of the system

3 Efficiency Typically quads are used. Faster than a model with depth.
Orientated towards the camera so that they always appear 3D.

4 Emitters A particle system has an emitter.
Particles come out of the emitter. They have an initial velocity. They have a lifetime. This could be dependent upon time (e.g. die after a certain point) or location (e.g. die when they hit the ground) You could re-use a particle after it has died. A particle that has died is re-emitted. In this way the particles cycle around and around. A system has been created.

5 Basic physics of the system
Central concept is that particles have an initial velocity. Gravity is then applied to them. This will change the velocity of the particle over time. Different particles in the system will be moving at different speeds. Gravity only affects the y-component. Could apply other forces, e.g. drag because of air resistance. Swirling because of wind.

6 Types of particle systems
The appropriate physics is applied to the particles. No hard and fast rules. It is a matter of aesthetics and the effect you want to achieve.

7 Fountain Single point emitter. Emitted in a small fan.
Fast initial velocity. Blue particles Blend so that overlaid textures darken. Physics is an initial velocity outwards. Gravity then pulls the particles downwards. Gravity causes them to fall after a period. Destroyed when hit the ground.

8 Smoke Single emitter Grey particles.
Blend so that overlaid textures darken Smoke gently rises (because smoke is light and the emitter is a heat source) The air is hot so it rises and the smoke is light and gets carried along. A small amount of gravity. Destroyed after a certain amount of time. Could use swirling, e.g. employ noise.

9 Rain Surface emitter Grey particle. Maybe use a streak.
Blend with high transparency. Probably little or no overlay. Drop downwards with a constant velocity.

10 Fire Red/yellow particles Blend so that overlaid textures lighten.
Single emitter Short lifetime. Higher velocity. Die quickly.

11 Explosion Red/yellow particles Single emitter.
May all be emitted at same time. Some may be delayed. Emitted in all directions or in a wide fan. High velocity. See Steve Rabin, "Powerful Explosion Effects Using Billboard Particles", Game Programming Gems 5.

12 Particle maths Velocity is distance divided by time.

13 Particle maths So after a period of time the new velocity will be
Constant acceleration is: So after a period of time the new velocity will be

14 Particle maths Need to look at velocity and acceleration
Velocity is units per second, e.g. metres per second Acceleration is units per second per second, e.g. metres per second per second This is important when taking time into account. Using the frame time, apply the velocity but multiply the velocity by the frame time.

15 Particle maths If we want to calculate the effect of acceleration:
calculate the new velocity using the frame time apply the velocity and again multiply the velocity by the frame time. Note the way that frame time is implicitly taken into account twice because it is units per second per second.

16 Programming: data structure
Could use an array to store all of the particles The particles cycle around Can use a dynamic data structure such as the STL <vector> class. The <vector> class is like a dynamic array. It has nothing to do with the vectors of 3D graphics despite its name. Why not research this yourself. I may well add it to the summer work.

17 Euler integration Stateful version. Version you will use in the lab.

18 Euler integration Expressed as a position

19 Varying the direction Want all of the particles to have the same initial velocity. Nice to have the particles "fan out" from the emitter. Random element. Offset in the along the x-axis. Use the maths of right-angle triangles to calculate the components of the movement vector.

20 Varying the direction

21 Closed function There is an alternative way of thinking about the maths of particle systems. Stateless version. Used by Luna in his chapter on particle systems. Simple. Drawback is that it only uses the one acceleration: so you can't apply other physics to the particles in mid-movement.

22 Closed function Do not need to record the velocity frame by frame.
Simply need the starting velocity, acceleration and the time passed since the particle was at that starting velocity.

23 Closed function

24 Maths Average velocity is displacement over time
Want to find the average velocity over a period of time. Acceleration is a constant. Therefore can do a simple average. Average velocity is displacement over time

25 Maths These are equivalent, so let's put them together.

26 Maths Can substitute one of the earlier equations into this (from slide 13)

27 Other variants exist May want sometimes to employ other variants.
Also useful to combine different accelerations. See Latta and the maths books

28 References Jeff Lander, "The Ocean Spray in Your Face", Lutz Latta, "Building a Million Particle System." In GDC 2004 Proceedings, Lutz Latta, "Everything about Particle Effects", More articles at his site: John van der Burg, "Building an Advanced Particle System".

29 References Van Verth, Essential Mathematics for Games and Interactive Applications: A Programmer's Guide. Wendy Stahler, Beginning Math and Physics for Game Programmers NVidia developers site ATI developers site


Download ppt "CO Games Concepts Week 22 Particle systems"

Similar presentations


Ads by Google