Presentation is loading. Please wait.

Presentation is loading. Please wait.

Particles and their home in Geometry Shaders Paul Taylor 2010.

Similar presentations


Presentation on theme: "Particles and their home in Geometry Shaders Paul Taylor 2010."— Presentation transcript:

1 Particles and their home in Geometry Shaders Paul Taylor 2010

2 Portal is Free on Steam!!! Till the 24 th May

3 Polygons are not so hot! Great for representing objects like A Cup A Robot A Pyramid Not so hot for creating Hair Snowflakes Rain Sparks Clouds Lightning Steam

4 Procedural Methods This is a big Umbrella for creating objects based on procedures (algorithms) With these models Polygons are rendered only as necessary – Necessary is defined as: The Polygon will be visible to the screen & The polygon will be more than 1 pixel in size

5 Why Use Procedural Methods Limitations on Polygon Rendering are not the only reason – Speed (sometimes) – Realism (a lot of the time) – Special Effects – Physics Systems

6 4 Procedural Methods Particle Systems Language Based Models Fractal Geometry Procedural Noise

7 Particle Systems http://2ld.de/gh2004/images/PSCollisions.jpg http://ccl.northwestern.edu/netlogo/models/models/Sample%20Models/Compute r%20Science/Particle%20Systems/Particle%20System%20Basic.png

8 Language Based Models Very similar to CSG Constructive Solid Geometry

9 A fractal system http://tabrizarchitecture.blogfa.com/post- 314.aspx

10 Fractal Geometry http://neatorama.cachefly.net/images/2008 -01/fractal-art-alfred-laing-spiral-fantasy.jpg

11 Procedural Noise http://www.naixela.com/alex/screens/cuda_p erlin_3d.jpg

12 Particle Systems In Detail http://www.cinema.com/image_lib/4319_heading.jpg

13 Particle Systems Particles can be used to represent many objects that are difficult or near impossible to create utilising polygons

14 This is particle #1 Particles are generally considered to be a point mass – All the mass of particle #1 is located at its infinite centre.

15 Visually a Particle can be anything A Particle can be just about anything – A Vertex in a Mesh – A Texture – A Billboarded Texture – A Polygon – An Entire Mesh

16 Independent Particles Independent Particles are the simplest form – Each particle receives input only from the ‘world’ Great for: Clouds Wind Sparks Water Spray

17 Newtonian Particles http://www.physics.mun.ca/~danielb/ Courses/P1050_2009/GodfreyKneller- IsaacNewton-1689.jpg

18 Newtonian Particles – These guys are not anything really specialised – The only requirement is that they respect Newtons laws of physics 1)Velocity will remain constant when there is no net force 2)The net force is equal to the objects mass multiplied by its acceleration 3)The force A exerts on B is equal and opposite to the force B exerts on A *For Independent Particles we can Ignore the 3 rd rule

19 F = m * a Force = mass x acceleration

20 Position, Velocity and Acceleration The Derivative (Gradient) of Position is Velocity The Derivative (Gradient) of Velocity is Acceleration All three components can be defined using just position, time and current velocity * You could do away with velocity and use just Position and Time but then we would need to store previous position and previous time-step to calculate the new position.

21 Given a Point Mass We only need Position, and Velocity to define a Newtonian Particle Position {x, y, z} Velocity {Vx, Vy, Vz} To calculate the motion of the Particle we need one more value, Time deltaTime (Change in time)

22 Calculating Movement On an Independent Particle System of Q Particles – For each of Q Particles Compute the Forces Applied to the Particle Given mass doesn’t change generate the new velocity vector using currentPosition, currentVelocity, and force Display the particle This gives an algorithmic complexity of 1(Q)

23 In Practice Particle at Pos 0,0,0 with velocity 1,0,0 We shall use a force vector of gravity (0,- 9.8m/s/s,0) V = Vi + acceleration(deltaTime) V = {0,0,0} + {0,-9.8,0} (deltaTime) So for a 1 second timestep V = {1,0,0} + {0,-9.8,0} (1) 1 st step: V = {1,-9.8,0} 2 nd step: V = {1,-19.6, 0}

24 Adding Frictional Forces Adding a term that is proportional to velocity will simulate friction on the particles (such as air and water)

25 Particle Emitters http://en.wikipedia.org/wiki/Particle_system

26 Particle Emitters Typically of high importance in video games Used to efficiently generate many of the effects (Eye Candy) Generate Newtonian Particles with an applied randomness

27 Dependant Particles Dependent Particles are connected together by a mesh, as strings or a even a theoretical mesh Great for: -Water -Fluids -Deformable Objects -Reactive Surfaces -Hair -Fur http://people.csail.mit.edu/acornejo/images/g rid.png

28 Particle Meshes In the most complex form each particle may receive input from every other particle in the mesh (A complexity of N 2 ) More typically we will only allow input from each of the adjacent particles in the mesh, requiring only 4N calculations.

29 Forces on Particle Meshes There are many ways to calculate the forces between particles in a Mesh or String One of the most common is utilising Spring Forces When created a spring has a length, spring Constant, and a dampening Term (drag)

30 Spring Equations The Basic Spring from a to b F = -springConstant * distanceStretched With Dampening F = -springConstant * distanceStretched * dampeningTerm

31 Attractive and Repulsive Particles Spring Forces are used to keep particles together Repulsive and Attractive Forces can be used to make Objects interact – Functions such as gravity, and inverse-square-law are typical Computational Complexity again goes out to N 2

32 Force Fields These can be used to replace many point-to- point force calculations An example is using the gravity field of Earth – Without this force field, we would need to do the calculations between each particle and the centre of the earth

33 Utilising the Geometry Shader There are two excellent uses for the Geometry Shader 1)Rendering your Geometry 2)Moving your Particles (Updating Positions)

34 The Render Pass This will use an updated Shader Technique: Old: technique10 Render { pass P0 { SetVertexShader( CompileShader( vs_4_0, VS() ) ); SetGeometryShader( NULL ); SetPixelShader( CompileShader( ps_4_0, PS() ) ); } New: technique10 UpdateParticles { pass P0 { SetVertexShader( CompileShader( vs_4_0, VS() ) ); SetGeometryShader( CompileShader( gs_4_0, GS() ) ); SetPixelShader( NULL ); }

35 So what work does our GS do? It takes in Points or triangles, and generates extra vertices In the simplest form we can use it for billboarding In a more complex way we can use it to create dynamic particle effects, which exist only on the GPU These particles live out their lives on the GPU dying before they every see the CPU

36 The Update Pass We only need to utilise the Geometry Shader – However we still need to set the pass for each stage of the pipeline This can also be done utilising a Compute Shader – Supported officially in Dx11 – Some Dx10 (Including the GTX260) support Compute Shader version 4.0 and 4.1 – It’s not a requirement for Dx10 cards

37 A Null Vertex Shader VSParticleIn VSPassThroughmain(VSParticleIn input) { return input; }

38 To be continued... With Compute Shaders

39 The End http://wiki.directxers.com/index.php?title=Tutor ial_5:_Geometry_Shader#Effect


Download ppt "Particles and their home in Geometry Shaders Paul Taylor 2010."

Similar presentations


Ads by Google