GPU Gems 3 Chapter 2 Animated Crowd Rendering

  • Slides: 22
Download presentation
GPU Gems 3 Chapter 2. Animated Crowd Rendering http: //www. kindnap. pe. kr http:

GPU Gems 3 Chapter 2. Animated Crowd Rendering http: //www. kindnap. pe. kr http: //cafe. naver. com/shader

introduction �Shader 4. 0 버전을 이용한 Skinned Hardware Instancing을 구현해본다. A Crowd of Characters

introduction �Shader 4. 0 버전을 이용한 Skinned Hardware Instancing을 구현해본다. A Crowd of Characters Animated Using Skinned Instancing

Hardware Instancing? �하나의 버퍼에 몰아, Draw Call을 최적화 �이점 Reduce : : Draw Call

Hardware Instancing? �하나의 버퍼에 몰아, Draw Call을 최적화 �이점 Reduce : : Draw Call Reduce : : Cache Miss Reduce : : Set. Render. State Reduce : : Set. Texture 더 자세한 내용은 http: //www. storyq. net/boxes/1841

Hardware Instancing Dx 9 � 사용법 In HLSL #define MAX_UNIT_INSTANCING 75 //상수 레지스터의 제한으로

Hardware Instancing Dx 9 � 사용법 In HLSL #define MAX_UNIT_INSTANCING 75 //상수 레지스터의 제한으로 인한 한번을 DP call시 그릴 수 있는 수의 한계를 둠 Float 4 x 3 g_m. World. Matrix. Array. Instancing[MAX_UNIT_INSTANCING] : WORLDMATRIXARRAY; //각 인스턴스의 월드행렬 정보의 저장 struct VS_INPUT { float 4 v. Pos float 2 v. Tex. Coord 0 : POSITION; : TEXCOORD 0; float f. World. Matrix. Index : TEXCOORD 1; //버퍼중 인스턴스의 아이디를 직접 알 수 있는 버퍼의 존재 } Vertex;

Hardware Instancing Dx 9 In VS int i. Matrix. Index = i. f. World.

Hardware Instancing Dx 9 In VS int i. Matrix. Index = i. f. World. Matrix. Index; //버택스 Input에서 현제 아이드를 참조함 v. World. Pos = mul( i. v. Pos, g_m. World. Matrix. Array. Instancing[i. Matrix. Index] ); //포지션 개산시 해당 월드행렬의 참조 o. v. Pos = mul( float 4( v. World. Pos, 1. 0 f ), g_m. Shadow. View. Proj ); // 이후 일반 연산과 동일한 과정

Hardware Instancing Dx 9 �In C Code D 3 DDevice()-> Set. Stream. Source. Freq(

Hardware Instancing Dx 9 �In C Code D 3 DDevice()-> Set. Stream. Source. Freq( ui. Stream. Number, ui. Frequency. Param ); 의 호출

Technique Gpu VS Load Instance data Load bone matrix(in tex) ani 연산 PS 여타와

Technique Gpu VS Load Instance data Load bone matrix(in tex) ani 연산 PS 여타와 같은 행위

Technique Constants – Based HLSL struce struct Per. Instance. Data { float 4 world

Technique Constants – Based HLSL struce struct Per. Instance. Data { float 4 world 1; float 4 world 2; float 4 world 3; float 4 color; uint 4 animation. Data; }; cbuffer c. Instance. Data { Per. Instance. Data g_Instances[MAX_INSTANCE_CONSTANTS]; }

Technique Constants – Based C Struct struct Instance. Data. Element { D 3 DXVECTOR

Technique Constants – Based C Struct struct Instance. Data. Element { D 3 DXVECTOR 4 world 1; D 3 DXVECTOR 4 world 2; D 3 DXVECTOR 4 world 3; D 3 DXCOLOR color; // Offset in vectors (texels) into the whole data stream // for the start of the animation playing UINT animation. Index; // Offset in vectors (texels) into the animation stream // for the start of the frame playing UINT frame. Offset; UINT unused 1; // pad UINT unused 2; // pad };

Palette Skinning Using an Animation Texture

Palette Skinning Using an Animation Texture

Conditional branching float 4 x 4 final. Matrix; // Load the first and most

Conditional branching float 4 x 4 final. Matrix; // Load the first and most influential bone weight final. Matrix = input. v. Weights. x *load. Bone. Matrix(animation. Data, input. v. Bones. x); // Conditionally apply subsequent bone matrices if the weight is > 0 if(input. v. Weights. y > 0) { final. Matrix += input. v. Weights. y * load. Bone. Matrix(animation. Data, input. v. Bones. y); if(input. v. Weights. z > 0) { final. Matrix += input. v. Weights. z * load. Bone. Matrix(animation. Data, input. v. Bones. z); if(input. v. Weights. w > 0) final. Matrix += input. v. Weights. w * load. Bone. Matrix(animation. Data, input. v. Bones. w); } }

Geometry Variations

Geometry Variations

Performance � 8600 회사똥컴 24 frame / 9547 characters if no instancing 16 frame

Performance � 8600 회사똥컴 24 frame / 9547 characters if no instancing 16 frame / 9547 characters � 8800 Gtx 34 frame / 9547 characters

Conclusion �Instancing 사용합시다. 끝!

Conclusion �Instancing 사용합시다. 끝!