340 likes | 514 Views
HavokFX. Next Gen Physics on ATI GPUs. Andrew Bowell – Senior Engineer Peter Kipfer – Senior Engineer. Why use physics in games?. A brief history of the Havok SDK Havok 1 Large feature set; rigid bodies, cloth, rope, soft bodies, water, particles Havok 2
E N D
HavokFX Next Gen Physics on ATI GPUs Andrew Bowell – Senior Engineer Peter Kipfer – Senior Engineer
Why use physics in games? • A brief history of the Havok SDK • Havok 1 • Large feature set; rigid bodies, cloth, rope, soft bodies, water, particles • Havok 2 • Rigid body physics for the PS2 generation • Havok 3 • Ultra realistic physics • Havok 4 • Next-gen physics
What is “next gen” physics? Gameplay physics Fx physics • Performance • Performance • Performance • Performance • Performance • Quality • Customization • Controllability
What is FX physics? • Physics based effects on a massive scale • 1,000s to 10,000s of objects • Rigid bodies • Particles • Fluids • Cloth • and more to come • Running on PC and consoles (Xbox 360, PS3)
Why use the GPU? • The GPU is a next-gen platform • Can be thought of as a 1000 multiprocessor machine • It is unbelievably fast when given the right task • Rendering, for example • Huge existing install base of graphics cards capable of running GPU physics
Havok and ATI • Strong partnership • Working specifically on HavokFX in the run up to its showcase on ATI at Computex 2006 Best Innovation – Computex 2006 [Hexus]
How does the GPU work? • GPUs are very powerful data parallel processors • 1000 simultaneous threads • Very high memory bandwidth • 1 cycle latency per instruction • Can execute up to 4 instructions per cycle • ATI X1900 XTX • 48 pixel processors • Over 350 GFLOPS • Issues • Normally only up to 16 float outputs in SM3.0 • Limited inputs too
Ballistic physics refresher course Collide Solve Collisions Integrate
Find overlapping pairs Integrate
Is physics a data parallel task? Collide Solve Collisions Integrate Anatomy of a clock tick
Is physics a data parallel task? Integrate Step Body 1 Step Body 2 New Positions Position & Velocity Step Body 1000
Is physics a data parallel task? Collide Solve Collisions Integrate Anatomy of a clock tick
Is physics a data parallel task? Collide Collide Pair 1 Find pairs Collide Pair 2 Contacts New Positions Collide Pair 4000
Is physics a data parallel task? Collide Solve Collisions Integrate Anatomy of a clock tick
Is physics a data parallel task? Solve Collisions Body 1 5 1 Body 6 4 6 11 Body 4 New Velocities Contacts & Velocities Body 2 12 Body 7 3 7 2 10 9 8 Body 5 Body 8 Body 3
Is physics a data parallel task? Solve Collisions Body 1 Body 6 Body 4 New Velocities Contacts & Velocities Body 2 Body 7 Body 5 Body 8 Body 3
Solve link 1 Solve link 1 Solve link 1 Solve link 2 Solve link 2 Solve link 2 Solve link 1200 Solve link 1000 Solve link 800 Is physics a data parallel task? Solve Collisions New Velocities Contacts Batch 1 Batch 2 Batch 3
Physics is a data parallel task Collide Solve Collisions Integrate 100% data parallel 80% data parallel 95% data parallel
Havok Fx Features Overview • FX Rigid Bodies • Convex collision bodies • Simple stable stacking • FX Particles • Inelastic particle-particle collisions • Fluid effects • Cloth • Lightweight framework • Fully integrated with Havok 4.0 • Everything collides with everything else
FX Particles • Particles are like simple rigid bodies • Much faster to simulate and render • One vertex per particle (point sprites) • Havok FX particle framework gives you • Particle-particle collisions • Particle-rigid body collisions • User-defined behaviours and emitters
FX Behaviors and Emitters • Executed on GPU • Uses SM3.0, e.g. HLSL • Alter velocities and positions • Wind, gravity • Per object user data • for custom properties
Integrated Toolchain • Leverages Havok physics exporters and tools pipeline
Simple behaviors GPU Memory CPU Memory Positions Velocities Readback from GPU Write back to GPU Modify on CPU
Game play physics interaction Once per Simulation GPU Memory CPU Memory Collision Shapes Textures Collision shapes Once per Frame Positions Textures Rigid Bodies Velocities Textures Game play physics FX physics
Rendering and CrossFire • Rendering needs careful consideration! • Most renderers will not render 20K objects well • Must use custom / vendor techniques • Havok FX returns handle to vertex buffers • Current rigid body transforms • Current particle positions • Optionally other particle / body state useful for rendering • The future is multiple GPUs
Dual and Triple GPU Physics Second (or third) GPU can be used for graphics or physics simulation, or share the primary card
FX Rigid Bodies again • We said the GPU was fast…
Future of Havok FX • Distributing physics across multiple GPUs • e.g. 2 GPUs for physics, 2 for rendering • Brittle fracture • Advanced smoke/cloud rendering • Volumetric shadowing • Advanced fluids • Smoothed particle hydrodynamics • Isosurface extraction using DirectX 10 Geometry Shader