+ All Categories
Home > Documents > Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA [email protected] .

Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA [email protected] .

Date post: 26-Mar-2015
Category:
Upload: sebastian-whitehead
View: 225 times
Download: 7 times
Share this document with a friend
Popular Tags:
29
Physical Simulation on Physical Simulation on GPUs GPUs Jim Van Verth OpenGL Software Engineer NVIDIA [email protected] www.nvidia.com www.essentialmath.com
Transcript
Page 1: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Physical Simulation on GPUsPhysical Simulation on GPUs

Jim Van Verth

OpenGL Software EngineerNVIDIA

[email protected]

www.essentialmath.com

Page 2: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Physics on GPU

Topics of discussion Ways of parallelizing physics Examples of GPU physics CUDA and you

Page 3: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Parallelizing Physics

CPU

What we’ve talked about so far

Display

Game Logic,AI, Physics

GPU

Graphics

Awfully busy… improve performance?

Page 4: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Parallelizing Physics

Solution 1: Multicore CPU

CPUDispla

y

Game Logic,AI

GPU

GraphicsPhysics

Page 5: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Parallelizing Physics

CPU

Solution 2a: Cell processor

Display

Game Logic,AI GPU

Graphics

Physics

SPU SPU SPU

SPU SPU SPU

Page 6: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Parallelizing Physics

CPU

Solution 2b: AGEIA processor

Display

Game Logic,AI GPU

Graphics

Physics

PPU

Page 7: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Parallelizing Physics

CPU

Solution 3: Programmable GPU

Display

Game Logic,AI

GPU

Graphics,Physics

Page 8: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Parallelizing Physics

CPU

Solution 3b: SLI

Display

Game Logic,AI

GPU

Graphics

GPU

Physics

Page 9: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

GPU Computing

Modern GPU has many independent processors: GeForce 8800 GTX: 128 SPs GeForce 8800 GT: 112 SPs

Mostly processing power, not cache: GeForce 8800 GTX: 300-400 Gflops GeForce 8800 GT: 500 Gflops

A lot of parallel power for physics!

Page 10: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

GPU Physics Example

From GPU Gems 3 Takahiro Harada, “Real-time Rigid

Body Simulation on GPUs” Simple physics engine, all running

on GPU

Page 11: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

GPU Physics Example

Idea: GPU is good at: Many similar computations Simple data

So: Particles for collision representation Grid for collision detection Simple collision response

Page 12: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Global object data in texture pairs

Alternate frame to frame

Object Representation

Position Orientation LinearMomentum

AngularMomentum

Page 13: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Object Representation

Collision rep: Solid (or shell) of particles

Store as Fixed radius Displacement from center of mass

Page 14: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Object Representation

Smaller particles == better fit But more processing

Page 15: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Object Representation

Particle data stored in texture and three rendertargets

Update position, velocity each frame from global object data

Update force from collisions

Displacement Position Velocity Force

Page 16: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Pipeline

Update Particles

Calculate Grid

ComputeCollisions

Integrate

Page 17: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Update Particles

For each object do: Iterate through all particles Update particle position,

velocity

Update Particles

Calculate Grid

Compute Collisions

Integrate

Position Orientation

LinearMomentum

AngularMomentum

Displacement

ParticlePosition

ParticleVelocity

Page 18: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Grid Representation

Stored as slabs within 2D rendertarget

Voxel stored as texel Four particle indices per texel

Update Particles

Calculate Grid

Compute Collisions

Integrate

Page 19: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Grid Creation

For each particle do Compute grid index Write particle index to

appropriate component at that location

Update Particles

Calculate Grid

Compute Collisions

Integrate

Page 20: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Collision Resolution

For each voxel do For each particle in voxel do

Compute force based on particles in this and 27 neighboring voxels

Regardless of collision! Spring force Damping from relative vel. Tangential force

Update Particles

Calculate Grid

Compute Collisions

Integrate

Page 21: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Integration

Compute new linear and angular momenta based on collision (and other) forces Force/torque on rigid body is

weighted sum of forces from each particle

Compute new position and orientation from momenta

Update Particles

Calculate Grid

Compute Collisions

Integrate

Page 22: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Demo

Page 23: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Other approaches

Simon Green’s particles N-body Parallelize one piece:

Ex. Broad Phase (GPU Gems 3) Do smaller problem

Ex. Fluid dynamics (Hellfire: London)

Page 24: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

GPU Computing

How to program? Pre-G80, had to use Cg, GLSL, HLSL Problems:

Requires specialized shader knowledge Data is often texture or rendertarget Can’t “scatter” data easily

Page 25: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

CUDA

Solution is CUDA Stands for Compute Unified Device

Architecture Extensions on C/C++ Interoperable with D3D and OpenGL www.nvidia.com/cuda Use it!

Page 26: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

CUDA

Updating our example: Instead of Cg, use standard C++ w/CUDA

extensions Instead of textures or rendertargets, just use

CUDA arrays Instead of vertex shader, use scatter operation

Page 27: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

NVIDIA Presentations@ GDC 2008

NVIDIA SessionsRoom 3003 – West Hall

Advanced Skin Rendering in NVIDIA's Human Head Demo4:00-5:00 pm, Wednesday, Feb. 20

Particle-based Fluid Simulation For Games9:00-9:30 am, Thursday, Feb. 21

3D Stereoscopic Game Development - How to Make Your Game Look Like Beowulf 3D9:30-10:00 am, Thursday, Feb. 21

GPU Optimization with the Latest NVIDIA Performance Tools10:30-11:30 am, Thursday, Feb. 21

NVIDIA FX Composer 2: Shader Development Unleashed12:00-1:00 pm, Thursday, Feb. 21

General GDC Sessions

Advanced Visual Effects with Direct 3D10:00-18:00, Monday, Feb 18Room 2007 - West Hall

Beyond Printf: Debugging Graphics Through Tools12:00-1:00 pm, Thursday, Feb. 21 Room 131 - North Hall

Real-Time Ambient Occlusion14:50-15:10, Friday, Feb 22 Room 3004 - West Hall

Physics for Game Programmers10:00-18:00, Tuesday, Feb 19 Room 2018 - West Hall

Page 28: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

San Jose downtown San Jose downtown Aug 25-27 2008Aug 25-27 2008

The first-ever The first-ever visual visual computing computing mega-event..mega-event..

The universe of The universe of visual visual computing in computing in one place at one place at one timeone time

15,000 Visitors: 10,000 amateur and

pro gamers, demoscencers, Game modders, machinima creators, and 3D artists

3,000 technical and marketing professionals from multiple industries

2000 visitors 300 press & analysts

http://www.nvision2008.comhttp://www.nvision2008.comhttp://www.nvision2008.comhttp://www.nvision2008.com

Page 29: Physical Simulation on GPUs Jim Van Verth OpenGL Software Engineer NVIDIA jvanverth@nvidia.com   .

Questions?


Recommended