www.nvidia.com/GDC
Kier Storey, Principal Software Engineer | Date | Booth S466| South Hall
PHYSX 4: RAISING THE FIDELITY AND PERFORMANCE OF PHYSICS SIMULATION - - PowerPoint PPT Presentation
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
www.nvidia.com/GDC
Kier Storey, Principal Software Engineer | Date | Booth S466| South Hall
2
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
3
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
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
5
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
6
Revolute Chains with Drives
0.05 0.1 0.15 0.2 0.25 0.3 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
7
High-mass Ratio Chains
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 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
8
Toy-scale Kapla tower
2 4 6 8 10 12 14 16 18 20 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
9
0.5 1 1.5 2 2.5 3
10,000:1 Mass Ratio Chain error 100 iterations
TGS PGS
Error
10
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
11
12
13
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.
14
PxScene* scene = gPhysics->createScene(desc); scene->addActor(*PxCreatePlane(*gPhysics, PxPlane(0,1,0,0), material); PxShape* box = gPhysics->createShape (PxBoxGeometry(PxVec3(1.f), material); PxRigidDyn* dyn; for(int i = 0; i < 1000; ++i) { dyn = gPhysics->createRigidDynamic (PxTransform(PxVec3(0.f, 1.f+2.f*i, 0.f)); dyn->attachShape(*box); updateMassAndInertia(*dyn, 1.f); scene->addActor(*dyn); } for(int frame = 0; frame < 100; ++ frame) { scene->simulate(1.f/60.f); scene->fetchResults(true); } using namespace physx::immediate; const int nbBodies = 10; PxRigidBodyData bodyDescs[nbBodies]; PxSolverBodyData data[nbBodies+1]; PxSolverBody solverBodies[nbBodies+1]; PxConstraintDesc contacts[nbBodies]; PxConstructStaticSolverBody( PxTransformFromPlaneEquation(PxPlane(0,1,0,0)), data[0]); PxConstructSolverBodies(bodyDescs, &data[1], 10); PxReal dt = 1.f/60.f, invDt = 60.f; for(int frame = 0; frame < 100; ++frame) { applyGravity(&data[1],gravity,nbBodies,dt); int cts = 0; for(int i = 0; i < nbBodies; ++i){ if(generateContacts(boxGeom, planeGeom, data[i+1],data[0],contacts[cts])) cts++; for(int i = 0; i < cts; ++i) createConstraints(contacts[i], invDt); solveConstraints(contacts, solverBodies); integrateSolverBodies(solverBodies); }
15
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
www.nvidia.com/GDC
Michelle Lu, Principal Software Engineer | 14 March, 2019 | Booth S466| South Hall
17
Extends immediate mode to support articulations and TGS solver GPU-accelerated articulations (coming soon) Significantly optimized CPU articulations Optimizations and bug fixes
18
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
19
5 10 15 20 25 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
20
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
21
0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 0.2 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
22
23
2 4 6 8 10 12 14 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
Thousands
PxScene 0T PxScene 4T Immediate Mode Immediate Mode 4T
24
10 20 30 40 50 60 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
Thousands
PxScene 4T PxScene 0T Immediate Mode
25
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
26
2 4 6 8 10 12 14 16 18 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
Chart Title
PhysX 4.1 CPU PhysX 4.1 GPU
27
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
28
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.
29
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
www.nvidia.com/GDC
Gordon Yeoman, Developer | 14 March, 2019 | Booth S466| South Hall
31
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.
32
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)
33
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
34
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
35
Rev the engine Engage the clutch Accelerate to top speed in 1st gear Apply the brake at 30 seconds
36
Rev the engine Engage the clutch Throttle forwards Steer maneuver to change lanes (note: placeholder images)
www.nvidia.com/GDC
Gordon Yeoman| gyeoman@nvidia.com
www.nvidia.com/GDC
Gordon Yeoman, Developer | 14 March, 2019 | Booth S466| South Hall
39
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.
40
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)
41
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)
42
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
43
Rev the engine Engage the clutch Accelerate to top speed in 1st gear Apply the brake at 30 seconds
44
Rev the engine Engage the clutch Throttle forwards Lane change maneuver begins at 10s Lane change maneuver ends at 16s
www.nvidia.com/GDC
Gordon Yeoman| gyeoman@nvidia.com