Animated Crowd Rendering · 2011. 8. 30. · From GPU Gems 3 by Bryan Dudash Johan Wallermark Jonas...

14
Animated Crowd Rendering From GPU Gems 3 by Bryan Dudash Johan Wallermark Jonas E. Mattsson

Transcript of Animated Crowd Rendering · 2011. 8. 30. · From GPU Gems 3 by Bryan Dudash Johan Wallermark Jonas...

  • Animated Crowd Rendering

    From GPU Gems 3by Bryan Dudash

    Johan WallermarkJonas E. Mattsson

  • 10 000 is a crowd

  • DX9 vs DX10

    DX9Hard to achieve instancingUnable to index into constant memory based on current instanceCache-inefficient work-around exists

    DX10Instancing is at the core of the APINew functions to support drawing multiple meshesVarious system variables => generated by the GPU

  • Instancing

    Render a mesh multiple times with different locationcolor, etc

    Usually static meshese.g. grass, leaves, other things that one needs a lot ofcan't be in different animations

    Uses constant memory to store dataUsed to transfer workload from CPU to GPU Skinned Instancing

    Same as above but uses texture memory to store data

  • Skinned instancing

  • How does this work?

    SV_InstanceIDTexture stores all animations

    texture used instead of constant memory because of the amount of dataoffset used to access the right animationtexture fetches are fasttexture animation is a multiple of 4

    easy to get the next matrix by just offsetting the u component

  • Ze math

    4096 float4 maximum under DX10The papers example uses 5 float4 for their data=> 4096/5 ~= 819 instances per draw callTo draw 10 000 characters=> 10 000 / 819 ~= 13 draw calls

    13 draw calls is much better than 10 000 (if only one mesh)

  • Rendering flowCPU

    Perform game logic (animation time, AI, etc.). Determine an LOD group for each instance and populate LOD lists.For each LOD:

    For each submesh:Populate instance data buffers for each instanced draw call.

    For each buffer: Call DrawInstanced() on the submesh.

  • Rendering flow cont.

    GPUVertex Shader1. Load per-instance data from constants using SV_InstanceID.2. Load bone matrix of appropriate animation and frame.3. Perform palette skinning.

    Pixel Shader1. Apply per-instance coloration as passed down from vertex shader.2. (Optional) Read a custom texture per instance from a texture

    array.

  • Geometry variations

    Having all characters look the same with the same animation looks really weird and humans will by a first glance see that something is off.hence breaking characters into several different pieces and instancing those separately

  • Performance increasers

    Level of detail - LODsets LOD groups on the CPU

    View frustum culling (CPU)

  • Performance

    Intel Core 2 Duo 2.93 GHz, 2GB RAM, NVIDIA 8800 GTX @1280x1024 9547 characters34 frames/secpixel/fill limited LOD 20, 60 & 100 unit radiuses160 instanced draw callsvs 59 726

  • Own comments

    Shadows for 10 000 characters, hmm...Polygons per character Various effectsPerformance

    59 726What method?

  • Thank you for your time

    Questions?