PHYSX 4: RAISING THE FIDELITY AND PERFORMANCE OF PHYSICS SIMULATION IN GAMES Kier Storey, Principal Software Engineer | Date | Booth S466| South Hall
www.nvidia.com/GDC PHYSX
Scalable, robust rigid body simulation
Cross-platform
Multi-threaded and GPU accelerated
Visual debugging and profiling tools
Integrated into numerous tools and existing game engines
2 RIGID BODIES
Efficient and accurate distance-based contact generation
Sweep-based CCD and speculative CCD
Support for common joint types (spherical, revolute, fixed, prismatic, distance, custom)
Fast and robust iterative solver
Efficient scene query system
Flexible filtering system
Extensions for vehicles and characters
Two interfaces: “retained” and “immediate” mode
3 PHYSX 4
Open-source BSD license
TGS: New, more robust, non-linear rigid body solver
New reduced coordinate articulation implementation
Provides game-level performance with robotics-quality simulation fidelity
More scalable broad phase
Overhauled joint implementation
Optimizations for complex multi-shape actors
4 TGS SOLVER
Non-linear iterative solver
Improved robustness to ill-conditioned cases
Significantly faster converging than PGS
Improved high-mass ratio simulation
Provides “gentle de-penetration” without damaging convergence
Improved joint drive handling
Similar performance to PGS solver
5 TGS COMPARISON Revolute Chains with Drives
0.3
0.25
0.2
0.15
0.1
0.05
0
1
27 53 79
105 131 157 183 209 235 261 287 313 339 365 391 417 443 469 495 521 547 573 599 625 651 677
PGS TGS
6 TGS COMPARISON High-mass Ratio Chains
0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1
0
1
90
179 268 357 446 535 624 713 802 891 980
1069 1158 1247 1336 1425 1514 1603 1692 1781 1870 1959 2048 2137 2226 2315
PGS TGS
7 TGS COMPARISON Toy-scale Kapla tower
20 18 16 14 12 10 8 6 4 2
0
1
130 259 388 517 646 775 904
1033 1162 1291 1420 1549 1678 1807 1936 2065 2194 2323 2452 2581 2710 2839 2968 3097 3226 3355 3484
PGS TGS
8 TGS CONVERGENCE 10,000:1 Mass Ratio Chain error 100 iterations
0
0.5
1
1.5 Error
2
2.5
3
TGS PGS
9 REDUCED COORDINATE ARTICULATIONS
Hierarchical kinematic tree multi-body system
Currently supports fixed, revolute, spherical and prismatic joints
Support for limits, PD drive controllers and joint friction
Loop joints, self-collisions and interactions with external bodies handled through PGS/TGS solver
Inverse dynamics
Closely-matches analytical models
Deep integration with TGS solver yields improved simulation robustness
10 RESULTS PhysX Warehouse Demo
11 RESULTS ANYmal training
12 IMMEDIATE MODE
Direct access to PhysX low-level functionality
Contact generation
Constraint definitions (contacts and joints)
Low-level rigid body solver
Extremely low-overhead. Ideally-suited for simulating small sets of bodies with as little latency as possible.
13 RETAINED MODE IMMEDIATE MODE PxScene* scene = gPhysics->createScene(desc); using namespace physx::immediate; const int nbBodies = 10; scene->addActor(*PxCreatePlane(*gPhysics, PxRigidBodyData bodyDescs[nbBodies]; PxPlane(0,1,0,0), material); PxSolverBodyData data[nbBodies+1]; PxSolverBody solverBodies[nbBodies+1]; PxShape* box = gPhysics->createShape PxConstraintDesc contacts[nbBodies]; (PxBoxGeometry(PxVec3(1.f), material); PxConstructStaticSolverBody( PxRigidDyn* dyn; PxTransformFromPlaneEquation(PxPlane(0,1,0,0)), data[0]); for(int i = 0; i < 1000; ++i) PxConstructSolverBodies(bodyDescs, &data[1], 10); { PxReal dt = 1.f/60.f, invDt = 60.f; dyn = gPhysics->createRigidDynamic (PxTransform(PxVec3(0.f, 1.f+2.f*i, 0.f)); for(int frame = 0; frame < 100; ++frame) dyn->attachShape(*box); { updateMassAndInertia(*dyn, 1.f); applyGravity(&data[1],gravity,nbBodies,dt); scene->addActor(*dyn); int cts = 0; } for(int i = 0; i < nbBodies; ++i){ if(generateContacts(boxGeom, planeGeom, for(int frame = 0; frame < 100; ++ frame) data[i+1],data[0],contacts[cts])) { cts++; scene->simulate(1.f/60.f); scene->fetchResults(true); for(int i = 0; i < cts; ++i) } createConstraints(contacts[i], invDt);
solveConstraints(contacts, solverBodies); integrateSolverBodies(solverBodies); } 14 GPU RIGID BODIES
Hybrid CPU/GPU rigid body simulation
Enabled with flags on the scene
Exact same interface and feature set as CPU simulation
Highly-scalable GPU broad phase
GPU-accelerated distance-based contact generation
GPU-accelerated PGS and TGS solver
Automatically handles transfer of data between host and device
Designed for interactive/gameplay-effecting simulation, not just visual effects
15 PHYSX 4.1 Michelle Lu, Principal Software Engineer | 14 March, 2019 | Booth S466| South Hall
www.nvidia.com/GDC PHYSX 4.1
Extends immediate mode to support articulations and TGS solver
GPU-accelerated articulations (coming soon)
Significantly optimized CPU articulations
Optimizations and bug fixes
17 ARTICULATION SOLVER
Forward dynamics optimizations and fixes
Optimized contact/joint solver solves simple constraints (articulation-rigid) in O(1) time rather than O(logn) time
Improved accuracy of joint drives/limits
Improved convergence
Improved spherical joint support
18 PERFORMANCE IMPROVEMENTS 1000 24 DOF Articulations on the ground
25
20
15
10
5
0
1 6
11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96
101 106 111 116 121 126 131 136 141 146 151 156 161 166 171 176 181 186 191 196 201 206 211 216 221 226 231 236 241 246 251 256 261 266 271 276 281 286 291 296 301 306 311 316 321 326 331 336 341 346 351
PhysX 4.0 PhysX 4.1
19 IMMEDIATE MODE ARTICULATIONS
Small/simple API
Direct access to link/joint properties
Direct simulation functions for forward dynamics on a single articulation
Coupled solver function that solves constraints between articulations and rigid bodies
New snippets showcasing immediate mode articulations and joints
20 IMMEDIATE MODE PERFORMANCE 1 Articulation
0.2
0.18
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
0
1 4 7
10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97
100 103 106 109 112 115 118 121 124 127 130 133 136 139 142 145 148 151 154 157 160 163 166 169 172 175 178 181 184 187 190 193 196 199
PxScene 4T PxScene 0T Immediate Mode
21 MULTIPLE INDEPENDENT SIMULATIONS 400 simple articulations
22 IMMEDIATE MODE PERFORMANCE 400 Articulations
14
12 Thousands
10
8
6
4
2
0
1 4 7
10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97
100 103 106 109 112 115 118 121 124 127 130 133 136 139 142 145 148 151 154 157 160 163 166 169 172 175 178 181 184 187 190 193 196 199
PxScene 0T PxScene 4T Immediate Mode Immediate Mode 4T
23 WHEN EVERYTHING INTERACTS! 400 Articulations
60
50 Thousands
40
30
20
10
0
1 4 7
10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97
100 103 106 109 112 115 118 121 124 127 130 133 136 139 142 145 148 151 154 157 160 163 166 169 172 175 178 181 184 187 190 193 196 199
PxScene 4T PxScene 0T Immediate Mode
24 GPU ARTICULATIONS
Work-in-progress
Extends GPU PGS and TGS Rigid Body solver to support articulations
Supports mixed simulation (rigid bodies + articulations)
Provides significant performance uplift compared to CPU-based articulations
Ideally-suited to simulations of 100s or 1000s of articulations and rigid bodies
25 GPU ARTICULATION PERFORMANCE 1800 swinging 18-dof chains with limits
Chart Title 18
16
14
12
10
8
6
4
2
0
1
10 19 28 37 46 55 64 73 82 91
100 109 118 127 136 145 154 163 172 181 190 199 208 217 226 235 244 253 262 271 280 289 298 307 316 325 334 343 352 361 370 379 388 397 406 415 424 433 442 451 460 469 478 487 496 505 514 523 532 541 550 559 568
PhysX 4.1 CPU PhysX 4.1 GPU
26 GPU ARTICULATIONS Future work
Faithful port of PhysX 4.0 articulation solver completed
Multi-body interaction between articulations and rigid bodies/other articulations complete
GPU version of optimized PhysX 4.1 contact/joint solver currently in the works
Articulation support in GPU TGS solver in progress
27 PHYSX FOR GAMES
PxScene simulation provides a scalable, asynchronous n-body simulation
Ideally-suited for simulating the main gameplay-effecting bodies
Immediate mode ideally suited for smaller-scale physics simulation
Local secondary physics for characters, network replays etc.
GPU simulation can be used to scale simulations massively
e.g. scalable destruction, server-side destruction/simulation etc.
28 NON-GAMING APPLICATIONS
Industrial simulation
Robotics
Reinforcement learning
Immediate mode for low-latency small-scale simulations
GPU articulations for larger-scale simulations
Model-based control
Forward and inverse dynamics
Visual FX
29 BEYOND GAME VEHICLE PHYSICS? Gordon Yeoman, Developer | 14 March, 2019 | Booth S466| South Hall
www.nvidia.com/GDC OUTLINE
PhysX Vehicles are now being used in non-gaming vehicle simulation applications such as NVIDIA DriveSim.
Using games technology in non-gaming applications leads to an obvious question.
Q: What is the integrity of the PhysX vehicle model in scenarios currently of interest?
A: Let’s compare with world class, industry-standard vehicle dynamics simulators and analyse the results.
31 PHYSX VEHICLE FEATURE SET What is a PhysX vehicle?
Engine (1-d rigid body, drive torque curve, damping)
Drivetrain (clutch, gearbox, final drive, differential)
Suspension (spring-damper)
Wheels (1-d rigid body)
Tires (longitudinal/lateral slip angles/forces, non-linear response, friction)
3d rigid body (jointed to sidecars, trailers etc)
32 SIDE BY SIDE COMPARISION I Test methodology
Run PhysX side by side with leading 3rd party simulator used widely by automotive industry
Configure vehicle data to be as closely matched as possible
Run PhysX and leading 3rd party simulator and compare simulation results
Test acceleration, braking, steering conditions that represent usual and safe driving behaviors
33 SIDE BY SIDE COMPARISION II Test methodology
Drive PhysX and 3rd party simulator with identical driving input (steer, brake, throttle) updated at 75Hz
PhysX and 3rd party simulator drive on the same road geometry and friction
Run PhysX and 3rd party simulator at 1KHz
Sample simulation state (wheel rolling speed, vehicle speed) at 60Hz.
Plot trajectory of maneuver
34 THROTTLE AND BRAKE
Rev the engine Engage the clutch Accelerate to top speed in 1st gear Apply the brake at 30 seconds
35 LANE CHANGE MANEUVER
Rev the engine Engage the clutch Throttle forwards Steer maneuver to change lanes (note: placeholder images)
36 QUESTIONS Gordon Yeoman| [email protected]
www.nvidia.com/GDC BEYOND GAME VEHICLE PHYSICS? Gordon Yeoman, Developer | 14 March, 2019 | Booth S466| South Hall
www.nvidia.com/GDC OUTLINE
PhysX Vehicles are now being used in non-gaming vehicle simulation applications such as NVIDIA DriveSim.
Using games technology in non-gaming applications leads to an obvious question:
Q: What is the integrity of the PhysX vehicle model in scenarios currently of interest?
A: Let’s compare with world class, industry-standard vehicle dynamics simulators and analyse the results.
39 PHYSX VEHICLE FEATURE SET What is a PhysX vehicle?
Engine (1-d rigid body, drive torque curve, damping)
Drivetrain (clutch, gearbox, final drive, differential)
Suspension (spring-damper)
Wheels (1-d rigid body)
Tires (longitudinal/lateral slip angles/forces, non-linear response, friction)
3d rigid body (jointed to sidecars, trailers etc)
40 SIDE BY SIDE COMPARISION I Test methodology
Run PhysX side by side with leading 3rd party simulator used widely by automotive industry
Configure vehicle data to be as closely matched as possible
Run PhysX and leading 3rd party simulator and compare simulation results
Test acceleration, braking, steering conditions that represent usual and safe driving behaviors (accelerate, brake, lane change steering)
41 SIDE BY SIDE COMPARISION II Test methodology
Drive PhysX and 3rd party simulator with identical driving input (steer, brake, throttle) updated at 75Hz
PhysX and 3rd party simulator drive on the same road geometry and friction
Run PhysX and 3rd party simulator at 1KHz
Sample simulation state (wheel rolling speed, vehicle speed) at 60Hz.
Plot trajectory of maneuver
42 THROTTLE AND BRAKE
Rev the engine Engage the clutch Accelerate to top speed in 1st gear Apply the brake at 30 seconds
43 LANE CHANGE MANEUVER
Rev the engine Engage the clutch Throttle forwards Lane change maneuver begins at 10s Lane change maneuver ends at 16s
44 QUESTIONS Gordon Yeoman| [email protected]
www.nvidia.com/GDC