Survey of Physics Engines for Games Thursday October

Survey of Physics Engines for Games Thursday, October 11, 2012

Contents • General information of Physics Engines - Description - Real-time vs. high-precision physics engines - Basis for a physics engine - Real-time physics engines • Havok, Bullet, Phys. X and ODE - Introduction - Comparison

General information of Physics Engines

Physics Simulations by a physics engine These are four examples of a physics engine simulating an object falling onto a slope. The examples differ in accuracy of the simulation: 1 No physics. 2 Gravity, no collision detection. 3 Gravity and collision detection, no rigid body dynamics. 4 Gravity, collision detection and rotation calculations.

What is a physics engine? • A physics engine: - computer software - approximate simulation of certain physical systems - in the domains of computer graphics, video games and film - Mainly used in video games (simulations are in real-time) A physics engine in the context of a game application

Real-time vs. high-precision • There are generally two classes of physics engines: realtime and high-precision. • Real-time physics engines - video games & interactive computing - simplified calculations - decreased accuracy - compute in time • High-precision physics engines - scientists and computer animated movies - more processing power - precise

Basis for a physics engine • Identifies and provides approximate simulation of certain simple physical systems. • Rigid body dynamics • Soft body dynamics • Fluid Simulation • Collision detection & response …

Rigid body dynamics • Rigid body dynamics is used heavily in analyses and computer simulations of physical systems and machinery where rotational motion is important, but material deformation does not have a significant effect on the motion of the system. • The Rigid body dynamics basically must deal with: - Rigid body linear momentum - Rigid body angular momentum - Angular momentum and torque

Soft body dynamics • Soft body dynamics focuses on visually realistic physical simulations. Generally, it only provide visually plausible emulations rather than accurate scientific/engineering simulations. • This simulation can be done by using a variety of approaches: - Mass-spring models - Finite element simulation - Energy minimization methods - Shape matching - Rigid body based deformation

Fluid Simulation • Fluid simulation is increasingly popular. A fluid simulator uses the Navier-Stokes equations. Simulations range in complexity from extremely time -consuming high quality animations for film & visual effects, to simple real-time particle systems used in modern games. • Some techniques for liquid simulation is as follows: - Eulerian grid-based methods - Smoothed particle hydrodynamics (SPH) methods - Vorticity-based methods - Lattice Boltzmann methods

Collision detection & response • Collision detection typically refers to the computational problem of detecting the intersection of two or more objects. • Collision response deals with simulating what happens when a collision is detected. • Solving collision detection problems requires extensive use of concepts from linear algebra and computational geometry: - Collision Detection for Flexible Surfaces - Collision Detection for Convex Polyhedra - Collision Response Using Springs - Collision Response Using an Analytical Solution - Collisions of Dynamic Objects with Non-Dynamic Objects

Real-time physics engines • Commercial Physics Engines (usually written in C++) • Most have license options that are attractively priced for indie and hobby developers Havok 3 D free for non-commercial and inexpensive commercial PC games, fee-based for games above a price limit, non-game applications, and consoles. NVIDIA Phys. X 3 D free for PC-based games, free for PS 3 through Sony prepurchase, fee-based for other consoles Oxford Dynamics 3 D vehicle sim - appears to be dead Digital Molecular Matter (DMM) 3 D fee-based licensing

Real-time physics engines SPE Simple Physics Engine 3 D free for noncommercial, fee-based for commercial Chrono : : Engine 3 D free for noncommercial use, fee-based for commercial True Axis 3 D free for noncommercial, fee-based for commercial with a reasonable indie license option Gino van den Bergen's SOLID collision detection library 3 D fee-based for commercial, open sourced for GPL/QPL projects Sim. Vex 3 D Addon library for Havok enabling game-quality vehicle creation of any configuration, cars, motorcycles, aircraft, etc Car. X 3 D C++, fee-based licensing Matali Physics crossplatform commercial physics engine, free for use in non-commercial games

Real-time physics engines • Open Source and Freeware Physics Engines Bullet 3 D open source Zlib license Open Dynamics Engine 3 D open source BSD license Box 2 D open source permissive Zlib license Tokamak Physics 3 D open source BSD license - Sourceforge Link Newton Game Dynamics 3 D custom free-use license Jig. Lib 3 D open source Zlib license Chipmunk 2 D open source unrestrictive MIT license Open Tissue various open source Zlib license

Real-time physics engines • XNA-Compatible ports Jig. Lib. X XNA port of Jig. Lib Bullet for XNA • Other ports Jig. Lib. Flash port of Jig. Lib to Flash via Action. Script 3 • "Abstraction Layers" Physics Abstraction Layer (PAL) Open Physics Abstraction Layer (OPAL) Gangsta Wrapper

Havok, Bullet, Phys. X and ODE

Introduction-Havok • Havok Physics is designed primarily for video games, and allows for real-time collision and dynamics of rigid bodies in three dimensions. • Features: - Collision Detection - including Continuous Physics - MOPP Technology - for compact representation of large collision meshes - Dynamics and Constraint Solving - Vehicle Dynamics - Data Serialization and Art Tool Support - Visual Debugger for in-game diagnostic feedback

Projects • Crash Nitro Kart、Half-Life 2、Max Payne 2、 Medal of Honor、F. E. A. R. 、Lord of the Rings: Middle Earth Online

Introduction-Phys. X • Phys. X is a proprietary real-time physics engine middleware SDK. • Phys. X SDK is only solution with fully-functional GPU/PPU physics acceleration pipeline. • Features: - Massively Parallel Physics Architecture - High-speed GDDR 3 Memory Interface - Universal Continuous Collision Detection - Physical Smart Particle Technology - Complex Object Physics System - Scalable Terrain Fidelity - Dynamic Gaming Framework

Projects • Game engines: Unity 3 D, Gamebryo, Vision (version 6 onwards), Instinct Engine, Panda 3 D, Diesel, Torque, Hero. Engine and Big. World. • Games: Bulletstorm, Need for Speed: Shift, Castlevania: Lords of Shadow, Mafia II, Alice: Madness Returns, Batman: Arkham City. • Software: Active Worlds (AW), Autodesk 3 ds Max, Autodesk Maya and Autodesk Softimage, Dark. BASIC Professional (with Dark. PHYSICS upgrade), DX Studio, Futuremark 3 DMark Vantage, Microsoft Robotics Studio. , Nvidia Super. Sonic Sled and Raging Rapids Ride, technology demos, OGRE (via the Nx. Ogre wrapper)

Introduction-Bullet • Bullet is an open source physics engine featuring 3 D collision detection, soft body dynamics, and rigid body dynamics. • It is used in games, and in visual effects in movies. • Features: - Multi Platform support - Supports various shape types - Discrete Collision Detection for Rigid Body Simulation - Single Queries - Sweep and Prune Broad phase - Documentation and Support - Auto generation of MSVC project files, comes with Jam build system

Introduction-Bullet - Bullet Collision Detection works with Bullet Dynamics, but there is also a sample integration with Open Dynamics Engine - Framework with 2 different Constraint Solvers - Hinge, Point to Point Constraint, Twist Cone Constraint (ragdolls) - Automatic de-activation (sleeping) - Generic 6 Degree of Freedom Constraint, Motors, Limits - LCP Warm starting of contact points - Collada 1. 4 Physics Import using F Collada and COLLADADOM - Convex Decomposition Code

Projects • Movies: 2012, The A-Team, Hancock, Sherlock Holmes. • Games: Toy Story 3, Grand Theft Auto IV, Red Dead Redemption, Trials HD by Red. Lynx, Free Realms, Hot. Wheels, Madagascar Kartz, Regnum Online, 3 D Mark 2011, Blood Drive, Hydro Thunder Hurricane. • Tools: Blender, Cheetah 3 D.

Introduction-ODE • • • The Open Dynamics Engine (ODE) is a physics engine in C/C++. Its two main components are a rigid body dynamics simulation engine and a collision detection engine. It was quite popular in 2005 -2006. Currently ODE’s development seems to be suspended. ODE is a popular choice for robotics simulation applications, with scenarios such as mobile robot locomotion and simple grasping. Features: - Rigid bodies with arbitrary mass distribution. - Joint types: ball-and-socket, hinge, slider (prismatic), hinge-2, fixed, angular motor, linear motor, universal. - Collision primitives: sphere, box, cylinder, capsule, plane, ray, and triangular mesh, convex. - Collision spaces: Quad tree, hash space, and simple. - Simulation method: The equations of motion are derived from a Lagrange multiplier velocity based model due to Trinkle/Stewart and Anitescu/Potra.

Introduction-ODE - A first order integrator is being used. It's fast, but not accurate enough for quantitative - engineering yet. Higher order integrators will come later. - Choice of time stepping methods: either the standard ``big matrix'' method or the newer iterative Quick. Step method can be used. - Contact and friction model: This is based on the Dantzig LCP solver described by Baraff, although ODE implements a faster approximation to the Coulomb friction model. - Has a native C interface (even though ODE is mostly written in C++). - Has a C++ interface built on top of the C one. - Many unit tests, and more being written all the time. - Platform specific optimizations.

Projects Blood. Rayne 2, Call of Juarez, S. T. A. L. K. E. R, Titan Quest, World of Goo, X-Moto and Open Simulator

Comparison-Methods • Most multi-purpose physics engines usually implement several methods: several different constraint solvers, friction models, collision detection method etc. • ODE for example has both a pivoting/direct method and iterative methods such as blocked projected Gauss–Seidel (PGS). • Bullet has similar iterative methods and is exploring nonsmooth nonlinear conjugate gradient methods as well. • Phys. X and Bullet has focused on using GPUs in their simulators. The algorithmic choices are still based on iterative methods in these works. • Most game physics engines use a constraint solver based on iterative methods like the ones known from ODE and Bullet. The methods are confusingly named “sequential impulses” by the computer gaming community but the models are based on the constraint based paradigm and are solved using an iterative method such as PGS or similar.

Comparison-Methods • A collision detection module and an object joint module are very important for physics engines. • The physics engine calculates the joint value of the inside object and the collision detection, and the changed position of the object and rotation value. • Newton's equation of motion is applied in this case.

Comparison-Methods • The Euler method approximates y(x) ignoring more than the first differential coefficient in the process by Taylor series when differential equation and initial condition were given in the Eq.

Comparison-Methods • The improved Euler method approximates to the second differential coefficient. The following way shows the process of calculating to the second differential coefficient in Eq. )

Comparison-Methods • The Runge-Kutta method approximates to the fourth differential coefficient in the Taylor series. The following method shows the process that calculates to the fourth differential coefficient in Eq. • Runge-Kutta methods achieve the accuracy of a Taylor series approach without requiring the calculation of higher derivatives.

Comparison-Use • Physics Engines in 3 D DCC Tools

Comparison-Use • To understand what is really needed and adopted by game industry • 2006 -2009

Comparison-Use • • • Phys. X SDK is preferred by small teams, is dominating PC market. Currently Phys. X SDK is widely adopted by russian (mostly trash games) and korean (mostly specific MMOs) developers. Havok is currently best choice for AAA titles – extensive toolset, orientation on consoles, best-in-class developer support. In spite of the fact that ODE has some good games in its library, 54% of all titles are based on Chrome Engine from Techland – mainly that’s trash shooters from CITY Interactive or Russian UAZ 4× 4 and it’s countless add-ons.

Comparison-Use • Phys. X SDK is dominating on PC market. Standalone console versions of Phys. X SDK existed even in 2005 (even certain games from PS 3 and Wii start-up line were based on Phys. X SDK), but still most of it’s console titles are based on UE 3. • Havok is dominating on AAA and console market. Only Havok has advanced support for various platforms – not only PC and modern consoles, but Xbox, PS 2 and even PSP. • ODE was used in several games for Wii, but majority of titles are still Chrome engine based games for PC. • Bullet is used in several of today’s hyperrealistic video games and feature film visual effects.

Comparison-Performance • Criteria: There are six essential factors that determine the overall performance of the physics engine: - Simulator Paradigm, determines which aspects can be accurately simulated. This affects the accuracy in resolving constraints. - The integrator, determines the numerical accuracy of the simulation. - Object representation, contributes to the efficiency and accuracy of collisions in the simulation. - Collision detection and contact determination, also contribute to the efficiency and accuracy of collisions in the simulation. - Material properties, determines which physical models, if any, the simulation can approximate (eg: Coloumb friction). - Constraint implementation, determines which constraints are supported and how accurately they can be simulated.

Physics Engines common features & Grading

Basic accuracy • Testing the physics engines with some physical fact in the real world, might give a hint on how correct the engine is. • This test has a simple configuration of a pendulum and a free-fall then each engine’s simulation will be compared to the “correct” physical behavior.

Basic accuracy Positional error from cumulative numerical integrators relative to the idea case normalized to the Symplectic Euler integrator error Period time error

Constraint Stability • Constraint stability is one of the areas of importance for game designers. • If constraints are unstable numerical errors can cause constrained bodies to slowly drift apart. • This results in unrealistic looking results. • This is also of critical importance for simulation engineers simulating multi-body robotic systems, the traditional application of dynamic simulation systems.

Constraint Stability Constraint error Average time per constraint Constraint timing

Bounce • Objects that collide and bounce of each other is a common scenario. • This test looks at how the different physic engines handle this.

Bounce results with different values of restitution Maximum bounce height for varying values of restitution

Scalability of contacts • A common way to demonstrate a physics toolkit is to have a scene with a big pile of boxes which is then destroyed. • This scene is not always that common in real applications. Despite this, piling seems to be a way of measuring how good a physics toolkit is, the following test will look into how the different toolkits scale when boxes are piled on top of each other.

Scalability of contacts Computational Effort of Stacked objects Time to solve contacts

Sources • General Information: http: //en. wikipedia. org/wiki/Physics_engine http: //www. gamedev. net/topic/475753 -list-of-physicsengines-and-reference-material-updated-7 -march-2011/ http: //elybob. wordpress. com/2011/05/21/physics-engines/ http: //www. ibm. com/developerworks/opensource/library/os -physicsengines/index. html http: //baike. baidu. com/view/721450. htm http: //www. adrianboeing. com/links. html#physics Physics Engine for Simulation. By R. Gaurav Agarwal. From http: //www. scribd. com/doc/36296208/Physics-Enginefor-Simulation

Sources • • • Features of different physics engines and their applications : Havok: http: //www. havok. com, http: //en. wikipedia. org/wiki/Havok_(software) Bullet: http: //bulletphysics. com http: //en. wikipedia. org/wiki/Bullet_(software) Novodex: http: //www. geforce. com http: //en. wikipedia. org/wiki/Novode. X ODE: http: //www. ode. org http: //en. wikipedia. org/wiki/Open_Dynamics_Engine Comparison: http: //physxinfo. com/articles/? page_id=154

Sources • Videos: • ODE: http: //www. youtube. com/channel/HCi. Sy. CR 5212 Ls • Havok: http: //www. youtube. com/user/havokchannel? feature=results_main • Numerical Integration Methods: Performance Evaluation of Numerical Integration Methods in the Physics Engine. By Jong-Hwa Choi, Dongkyoo Shin, Won Heo and Dongil Shin. From http: //www. springerlink. com/content/rpxwqcbccmwhlcb 0/fulltext. pdf Interactive Simulation of Rigid Body Dynamics in Computer Graphics. By Jan Bender, Kenny Erleben, Jeff Trinkle and Erwin Coumans. From http: //www. cs. rpi. edu/twiki/pub/Robotics. Web/Lab. Publications/BETCstar _part 1. pdf

Sources • • Comparison: Phys. X vs. Havok: http: //en. wikipedia. org/wiki/Physics_processing_unit Bullet vs. Novodex vs. ODE: Evaluation of real-time physics simulation systems. By Adrian Boeing, Thomas Bräunl. From http: //www. adrianboeing. com/pal/papers/p 281 -boeing. pdf Havok vs. Bullet vs. Novodex vs. ODE: COLLADA physics. By Erwin Coumans, Keith Victor. From http: //www. bulletphysics. com/ftp/pub/test/physics/Collada%20 Physics/collada_physics_sho rtpaper_web 3 d_6. pdf Novodex vs. ODE: Evaluation of Physics Engines and Implementation of a Physics Module in a 3 d-Authoring Tool. By SEUGLING, A, and ROLIN M. From http: //www 8. cs. umu. se/education/examina/Rapporter/Seugling. Rolin. pdf Evaluating Physics Engines For Games – PAL: http: //3 dexperiences. blogspot. com/2008/12/evaluating-physics-engines-for-games. html ODE vs. Bullet: http: //blog. wolfire. com/2010/03/Comparing-ODE-and-Bullet

Thank you
- Slides: 50