320491: Advanced Graphics - Chapter 2 163
Visualization and Computer Graphics LabJacobs University
2.9 Mesh-free Physics
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.
320491: Advanced Graphics - Chapter 2 165
Visualization and Computer Graphics LabJacobs University
Mesh-free physics
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.
320491: Advanced Graphics - Chapter 2 167
Visualization and Computer Graphics LabJacobs University
Gradient approximation
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
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.
320491: Advanced Graphics - Chapter 2 170
Visualization and Computer Graphics LabJacobs University
Results
• Elastic solid melts to fluid:
320491: Advanced Graphics - Chapter 2 171
Visualization and Computer Graphics LabJacobs University
Results
• Highly plastic deformation, where fracture isincorporated when strain gets too high:
320491: Advanced Graphics - Chapter 2 172
Visualization and Computer Graphics LabJacobs University
2.10 Summary
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, …
320491: Advanced Graphics - Chapter X 1
Visualization and Computer Graphics LabJacobs University
X. GPU Programming
320491: Advanced Graphics - Chapter X 2
Visualization and Computer Graphics LabJacobs University
X.1 GPU Architecture
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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();
…
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
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
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
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
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
320491: Advanced Graphics - Chapter X 27
Visualization and Computer Graphics LabJacobs University
Summary of GPU part
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
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
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