2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo •...

41
320491: Advanced Graphics - Chapter 2 163 Visualization and Computer Graphics Lab Jacobs University 2.9 Mesh-free Physics

Transcript of 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo •...

Page 1: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 163

Visualization and Computer Graphics LabJacobs University

2.9 Mesh-free Physics

Page 2: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 164

Visualization and Computer Graphics LabJacobs University

Mesh-free physics

• The continuum mechanics that were introduced in thecontext of finite elements methods can also beapplied to particle positions.

Page 3: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 165

Visualization and Computer Graphics LabJacobs University

Mesh-free physics

Page 4: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 166

Visualization and Computer Graphics LabJacobs University

Mesh-free physics

• The only challenge is to accurately determine thederivative of the displacement vector.

• As no connectivity is given between particles, derivative computation is not straight forward, evenif the displacement vectors of all nearby particles areknown.

Page 5: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 167

Visualization and Computer Graphics LabJacobs University

Gradient approximation

Page 6: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 168

Visualization and Computer Graphics LabJacobs University

Moving Least Squares

In order to have the resulting function be an interpolation, choose weights

,..2,1,)( 2 == − kttw k

Page 7: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 169

Visualization and Computer Graphics LabJacobs University

Rendering

• To render the results of an animation, isosurfaces areshown.

• The isosurfaces are rendered using, again, a movingleast squares approximation.

Page 8: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 170

Visualization and Computer Graphics LabJacobs University

Results

• Elastic solid melts to fluid:

Page 9: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 171

Visualization and Computer Graphics LabJacobs University

Results

• Highly plastic deformation, where fracture isincorporated when strain gets too high:

Page 10: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 172

Visualization and Computer Graphics LabJacobs University

2.10 Summary

Page 11: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter 2 173

Visualization and Computer Graphics LabJacobs University

Animation• Morphing

– Mesh morphing– Volume morphing

• Physically-based animation– Spring models Hair, Cloth– Continuum mechanics Deformable objects

• Finite elements• Mesh-less

– Particle systems Smoke, fire, …– Euler methods Fluids

• Motion capturing Humans, animals, …

Page 12: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 1

Visualization and Computer Graphics LabJacobs University

X. GPU Programming

Page 13: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 2

Visualization and Computer Graphics LabJacobs University

X.1 GPU Architecture

Page 14: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 3

Visualization and Computer Graphics LabJacobs University

GPU

• Graphics Processing Unit• Parallelized SIMD Architecture

– 112 processing cores on nVidia GeForce 9800GT (2 years ago)– 512 processing cores on nVidia GeForce GTX 580 (newest)

Page 15: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 4

Visualization and Computer Graphics LabJacobs University

Restrictions

• Not a generalized vector processor• Cannot read and write to same areas of memory• Limited output capability

– Currently, expensive to output to arbitrary locations in memory

• Restricted memory size– 1GB on nVidia GeForce 9800GT– 1.5GB on nVidia GeForce GTX 580

Page 16: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 5

Visualization and Computer Graphics LabJacobs University

Notation

• Vertex– A data structure for a point in a mesh, containing position,

normal, texture coordinates, etc.• Fragment

– A pixel, possibly sub-pixel, of a rasterized image• Shaders

– Small programs run in the GPU at specific stages of the GPU pipeline

Page 17: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 6

Visualization and Computer Graphics LabJacobs University

Memory constructs

• Buffered Objects• Uniform Registers/State Table• Interpolated Registers• Temporary Registers• Textures

Page 18: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 7

Visualization and Computer Graphics LabJacobs University

Memory constructs

• Buffered Objects– CPU Generated Streams of Data– Limited Modifiability– Example

• Vertex Data of a Mesh

Page 19: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 8

Visualization and Computer Graphics LabJacobs University

Memory constructs

• Uniform Registers/State Table– Constant Data through the Pipeline

• Only Necessarily Constant for 1 Polygon– 32 general purpose registers– State Table Specific Registers

• Projection/Model View Matrices• Lights• … and more

Page 20: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 9

Visualization and Computer Graphics LabJacobs University

Memory constructs

• Interpolated Registers– Per Vertex Data of a Polygon– Stores Information Interpolated Across Polygon– 10 General Purpose Interpolated Registers

Page 21: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 10

Visualization and Computer Graphics LabJacobs University

Memory constructs

• Temporary Registers– Standard Notion of Registers– Temporary Registers for In Shader Calculations

Page 22: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 11

Visualization and Computer Graphics LabJacobs University

Memory constructs

• Textures– Closest to Random Access Memory– Expensive to Access

• Multiple Dependent AccessesExtremely Expensive

Page 23: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 12

Visualization and Computer Graphics LabJacobs University

GPU pipelineProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations

Framebuffer

DriverCPU

GPUBus

Page 24: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 13

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Program– Your Program

• API– Either OpenGL or DirectX Interface

Program/API

Page 25: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 14

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Driver– Black-box

• Implementations are Company Secrets– Largest Bottleneck in many GPU programs

Driver

Page 26: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 15

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• GPU Front End– Receives commands & data from driver– PCI Express helps at this stage

GPU Front End

Page 27: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 16

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Vertex Processing– Normally performs transformations– Programmable

VertexProcessing

VertexProcessor

vertex

data for interpolation

data for rasterizationPOSITION

PSIZE

FOG

TEXCOORD[0-7]COLOR[0-1]

shader

POSITION, NORMAL, BINORMAL*, TANGENT*, TEXCOORD[0-7], COLOR[0-1], PSIZE

textures

Page 28: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 17

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Primitive Assembly– Compiles Vertices into Points, Lines and/or Polygons– Link elements and set rasterizer

PrimitiveAssembly

Page 29: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 18

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Rasterization– For each fragment determine respective area of triangle

(Barycentric Coordinates) or other primitive• Interpolation

Rasterization &Interpolation

data for interpolation

data for rasterizationPOSITION

PSIZE

FOG

TEXCOORD[0-7]COLOR[0-1]

Rasterizer

Interpolator interpolated data

TEXCOORD[0-7]COLOR[0-1]

rasterized data

DEPTHBarycentricCoordinates

PrimitiveAssemblerPrimitive Type

Page 30: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 19

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Fragment Processing– Programmable

FragmentProcessing

FragmentProcessor

shader

textures

interpolated data

TEXCOORD[0-7]COLOR[0-1]

rasterized data

DEPTHCOLOR[0-3]

DEPTH

data for raster ops

Page 31: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 20

Visualization and Computer Graphics LabJacobs University

GPU pipeline

• Depth Checking– Check framebuffer to see if lesser depth already exists (Z-

Buffer)– Limited Programmability

• Blending– Use alpha channel to combine colors already in the

framebuffer– Limited Programmability

RasterOperations

Page 32: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 21

Visualization and Computer Graphics LabJacobs University

ExampleProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations Framebuffer(s)

Driver

Bus

Code Snippet

….glBegin(GL_TRIANGLES);glTexCoord2f(1,0); glVertex3f(0,1,0);glTexCoord2f(0,1); glVertex3f(-1,-1,0);glTexCoord2f(0,0); glVertex3f(1,-1,0);

glEnd();

Page 33: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 22

Visualization and Computer Graphics LabJacobs University

ExampleProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations Framebuffer(s)

Driver

Bus

01001001100….

GP

U

Page 34: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 23

Visualization and Computer Graphics LabJacobs University

ExampleProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations Framebuffer(s)

Driver

Bus

viewing frustum

Page 35: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 24

Visualization and Computer Graphics LabJacobs University

ExampleProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations Framebuffer(s)

Driver

Bus

screen space

Page 36: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 25

Visualization and Computer Graphics LabJacobs University

ExampleProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations Framebuffer(s)

Driver

Bus

framebuffer

Page 37: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 26

Visualization and Computer Graphics LabJacobs University

ExampleProgram/

API

GPU Front End

VertexProcessing

PrimitiveAssembly

Rasterization &Interpolation

FragmentProcessing

RasterOperations Framebuffer(s)

Driver

Bus

framebuffer

Page 38: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 27

Visualization and Computer Graphics LabJacobs University

Summary of GPU part

Page 39: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 28

Visualization and Computer Graphics LabJacobs University

Quick architecture notes

• Limits in Shader Size• MIMD

– Branches are supported with a large overhead• Unified Shading Architecture

– Xbox 360 – ATI– Pool of processors with load balancing

Page 40: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 29

Visualization and Computer Graphics LabJacobs University

Higher-level shading languages

• Vectorized languages for designing shader programs• Easy way out of tedious assembly coding• Not Perfect

– Results Are Sometimes Clearly Not Optimized• Examples

– Cg– GLSL– HLSL

Page 41: 2.9 Mesh-free Physics · Animation •Morphing gn–Mih mphrsoe gnih mmpeur–Volo • Physically-based animation s mlgedno–Sirp Hair, Cloth – Continuum mechanics Deformable objects

320491: Advanced Graphics - Chapter X 30

Visualization and Computer Graphics LabJacobs University

GPGPU

• General Purpose GPU Processing• Key Notes

– Goal to exploit fragment processor– Each pixel represents a compacted 4-component element of

data– Most optimal in gathering algorithms

• Vertex shader needed to re-order output• Possibly Optimal in Unified Shading Architecture