Morphing and Animation GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from ShaderX 3, 4 and 5 And GPU Gems 1.

Slides:



Advertisements
Similar presentations
Animation in Video Games presented by Jason Gregory
Advertisements

Part IV: Memory Management
COMPUTER GRAPHICS SOFTWARE.
GlTF and rest3d Patrick Cozzi University of Pennsylvania CIS Fall 2013.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
The Programmable Graphics Hardware Pipeline Doug James Asst. Professor CS & Robotics.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 19 of 41 William H. Hsu Department of Computing.
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
Character Animation CSE 191A: Seminar on Video Game Programming Lecture 5: Character Animation UCSD, Spring, 2003 Instructor: Steve Rotenberg.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE408, University of Illinois, Urbana-Champaign 1 Programming Massively Parallel Processors Chapter.
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
Skin Rendering GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from David Gosselin’s Power Point and article, Real-time skin rendering,
IN4151 Introduction 3D graphics 1 Introduction to 3D computer graphics part 2 Viewing pipeline Multi-processor implementation GPU architecture GPU algorithms.
The programmable pipeline Lecture 10 Slide Courtesy to Dr. Suresh Venkatasubramanian.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Chapter 5.2 Character Animation. CS Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Computer Graphics Graphics Hardware
Geometric Objects and Transformations. Coordinate systems rial.html.
GPU Shading and Rendering Shading Technology 8:30 Introduction (:30–Olano) 9:00 Direct3D 10 (:45–Blythe) Languages, Systems and Demos 10:30 RapidMind.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
Interactive Time-Dependent Tone Mapping Using Programmable Graphics Hardware Nolan GoodnightGreg HumphreysCliff WoolleyRui Wang University of Virginia.
Cg Programming Mapping Computational Concepts to GPUs.
09/11/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Graphics Pipeline Texturing Overview Cubic Environment Mapping.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
Character Animation for Realtime Applications Michael Putz Klaus Hufnagl Institute of Computer Graphics Graz University of Technology Austria.
Computer Graphics Soft Body Animation - Skinning CO2409 Computer Graphics Week 22.
The programmable pipeline Lecture 3.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Tone Mapping on GPUs Cliff Woolley University of Virginia Slides courtesy Nolan Goodnight.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Review of OpenGL Basics
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
Skeletal Animation and Skinning A (hardware friendly) software approach By: Brandon Furtwangler.
09/25/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Shadows Stage 2 outline.
Image Processing A Study in Pixel Averaging Building a Resolution Pyramid With Parallel Computing Denise Runnels and Farnaz Zand.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Mesh Skinning Sébastien Dominé. Agenda Introduction to Mesh Skinning 2 matrix skinning 4 matrix skinning with lighting Complex skinning for character.
OpenGL Shading Language
Programming with OpenGL Part 3: Shaders Ed Angel Professor of Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive.
GLSL I.  Fixed vs. Programmable  HW fixed function pipeline ▪ Faster ▪ Limited  New programmable hardware ▪ Many effects become possible. ▪ Global.
An Introduction to the Cg Shading Language Marco Leon Brandeis University Computer Science Department.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/XX13 – GLSL Lecture 13: OpenGL Shading Language (GLSL) COMP 175: Computer Graphics April 12, 2016.
Build your own 2D Game Engine and Create Great Web Games using HTML5, JavaScript, and WebGL. Sung, Pavleas, Arnez, and Pace, Chapter 5 Examples 1.
Our Graphics Environment Landscape Rendering. Hardware  CPU  Modern CPUs are multicore processors  User programs can run at the same time as other.
Computer Graphics Graphics Hardware
GPU Architecture and Its Application
Software Engineering and Game Development
Graphics Processing Unit
Deferred Lighting.
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Introduction to geometry instancing
Computer Graphics Graphics Hardware
Programming with OpenGL Part 3: Shaders
Computer Graphics Introduction to Shaders
03 | Creating, Texturing and Moving Objects
CS 480/680 Fall 2011 Dr. Frederick C Harris, Jr. Computer Graphics
Presentation transcript:

Morphing and Animation GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from ShaderX 3, 4 and 5 And GPU Gems 1

Morphing  Vertex Tweening – two key meshes are blended varying by time.  Morph Targets – vertex tweening applied only to local displacements. Represent morph targets by relative vectors from the base mesh to the target meshes

Morph Target Animation  Morph Target Animation – one base mesh can morph into multiple targets at the same time. Facial animation Muscle Deformation

Morph Target Animation Linear Interpolation: Relative: Position Output = Position Source + (Position Destination * Factor) Absolute: Position Output = Position Source + (Position Destination – Position Source )*Factor

Relative vs. Absolute 4 3 RelativeAbsolute

Constraints 1. Number of vertices must be the same 2. Faces and attributes must be the same 3. Material must be equal 4. Textures must be the same 5. Shaders, etc must be the same Useful only where skinning fails!

Data Structures for Morphing  DirectX allows for flexible vertex formats  Unsure if OpenGL supports flexible formats  Position 1 holds the relative position for the morph target D3DVERTEXELEMENT9 pStandardMeshDeclaration[] = { { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, { 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 1 }, { 0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, { 0, 32, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, D3DDECL_END() }

Skeletal Animation  Hierarchical animation 1. Mesh vertex is attached to exactly one bone 2. Transform vertex with the inverse of the bone’s world matrix  Issues Buckling occurs at regions where two bones are connected

Skeletal Subspace Deformation Vertices are attached to multiple bones by weighting 1. Move each vertex into every associated bone space by multiplying the inverse of the initial transformation 2. Apply current world transformation 3. Resulting vertices are blended using morphing

Shader Model 2.0 Approach  Go into Dawn demo here

GPU Animation  Can skip the processing of unused bones or morph targets Need hardware support for:  Dynamic branching  Can separate the modification and the rendering process Need hardware support for:  Four component floating-point texture formats  Multiple render targets Normal Map Position Map Tangent Map

Method 1  Hold the vertex data in texture arrays  Manipulate the data in the pixel shader  Re-output to texture arrays  Pass the output as input to vertex shader

Storage Procedures If: vertex array is one-dimensional frame buffer is two-dimensional index2D.x = index % textureWidth; index2D.y = index / textureWidth; index = index2D.y * textureWidth + index2D.x;

Redefining the View Draw a rectangle of coordinates (0,0), (0,1), (0,1), (1,1) Remap them using the following vertex program float4 VS(float4 index2D: POSITION0, out float4 outIndex2D : TEXCOORD0) : POSITION { outIndex2D = index2D; return float4(2 * index2D.x – 1, -2 * index2D.y + 1, 0, 1); } (-1, 1), (1,1), (-1,-1), (1,-1)

GPU Animation Pixel Shader float2 halfTexel = float2(.5/texWidth,.5/texHeight); float4 PS(float4 index2D : TEXCOORD0, out float4 position : COLOR0, out float4 normal : COLOR1,...) { index2D.xy += halfTexel; float4 vertAttr0 = tex2Dlod(Sampler0, index2D); float4 vertAttr1 = tex2Dlod(Sampler1, index2D);... // perform modifications and assign the final // vertex attributes to the output registers }

Analysis Advantage  Keeps vertex and geometry processing units workload at a minimum Why is this good?  Good for copy operations and vertex tweeningDisadvantage  Per-vertex data has to be accessed through texture lookups  Number of constant registers is less in pixel shader (224) than vertex shader (256)  Can not divide modification process into several pieces because only a single quad is drawn  Therefore, Constant registers must hold all bone matrices and morph target weights for entire object

Method 2  Apply modifications in the vertex shader, do nothing in the pixel shader  Destination pixel is specified explicitly as a vertex shader input  Still writing all vertices to a textureAdvantage Can easily segment the modification groupsDisadvantage Speed issues make this method impractical

Accessing Modified Data  Do NOT want to send the data back to the CPU, except in one case  Solution: Direct-Render-To-VertexBuffer The problem: Direct-Render-To-VertexBuffer doesn’t exist yet (but we can always dream)  Solution 2: Transfer result from render target to vertex buffer object on graphics card Use OpenGL’s ARB_pixel_buffer_object  Solution 3: Use RenderTexture capability and then access the texture in the vertex shader Store the texture lookup in the vertices texture coordinates Problem: Vertex textures are SLOW Can not execute vertex texture lookups and other instructions in parallel

Performance Issues  Preferable to perform modification and rendering in single pass  Accessing vertex attributes using vertex texturing is always slower than performing a fast copy within video memory  Accessing morph in a vertex texture makes the application too slow, must use constants

Usage  To get real speed advantage use a hybrid CPU GPU approach 1. Let the CPU compute the final vertex attributes used during rendering frames n and n+k 2. Let the GPU perform vertex tweening at frames greater than n and smaller than n+k 3. Phase shift the animations between characters so that the processors do not have peak loads  Advantage Vertex tweening is supported on almost all hardware No restrictions on modification algorithms because it is performed on CPU

Massive Character Animation  Can perform simple AI effects  Each pixel of output texture holds one character’s state  Pixel shader computes next state  State is used to determine which animation to use

Simulating Character Behavior  Implement Finite State Machine in Pixel Shader Walk Turn If no Obstacle Run If Chased If Obstacle If Chased If Obstacle

Implementing an FSM on GPU Use dependent texture lookups  Agent-space maps: Contain information about the state of characters (position, state, frame)  World-space image maps: Contain information about the environment to influence the behavior of the character  FSM Maps: Contain information about the behavior for each state and about transitions between states. Rows group transitions within the same state Columns contain conditions to trigger transitions