MGB 005 Agenda Motivation Tessellation Basics DX Tessellation Pipeline Instanced Tessellation Instanced Tessellation in DX0 Displacement Mapping Content Creation Compression Motivation Save memory and bandwidth Memory is the main bottleneck to render highly detailed surfaces = + Level 8 Level 6 Level Level 6 Regular Triangle Mesh 6MB 59MB 6MB 9MB Displaced Subdivision Surface.9MB 7.5MB 0MB 8MB Scalability Continuous Level of Detail Scalability View Dependent Level of Detail 008 NVIDIA Corporation. All rights reserved.
MGB 005 Animation & Simulation Perform Expensive Computations at lower frequency: Realistic animation: blend shapes, morph targets, etc. Goal Enable unprecedented visuals: Highly detailed characters Realistic animation Physics, collision detection, soft body dynamics, etc. Mike Asquith, Valve Corporation 007 Tessellation Concept A new primitive called patch Patch is defined by a set of control points Tessellation Basics A new type of operation called refinement Generate a number of triangles from a patch Kenneth Scott, id Software 008 Transforming control points Animation can be performed at a lower rate Per-patch Operations LOD computation Transform control points to different basis Computes edge tessellation levels Transforming control points 008 NVIDIA Corporation. All rights reserved.
MGB 005 Generating Topology Evaluating Points Generate a set of (u,v)-points in the tessellation domain (0, ) (, ) (x, y, z) (u, v) (0, 0) (, 0) Evaluation Example: Catmull-Clark Subdivision Example: Catmull-Clark Subdivision Most popular scheme Based on B-Spline subdivision Evaluation through recursive refinement Add one new vertex for every face and every edge Example: Catmull-Clark Subdivision Example: Catmull-Clark Subdivision 6 6 n n 6 8 6 8 n n 7 n 008 NVIDIA Corporation. All rights reserved.
MGB 005 Catmull-Clark Subdivision Resulting mesh only approximates the limit subdivision surface Halstead et al show that it s possible to project the vertices to the limit surface Efficient, Fair Interpolation using Catmull-Clark Surfaces http://graphics.cs.uiuc.edu/~jch/cs97jch/halstead.pdf GPU Implementations Previous approaches on the GPU: Adaptive Tessellation of Subdivision Surfaces with Displacement Mapping, Michael Bunnell Recursive Geometry Shader refinement Require multiple passes Direct evaluation is preferred DX Tessellation Pipeline Tessellation Pipeline DirectD extends DirectD0 with support for programmable tessellation Two new shader stages: Hull Shader (HS) Domain Shader (DS) One fixed function stage: Tessellator (TS) Input Assembler Vertex Shader Hull Shader TS Domain Shader Geometry Shader Setup/Raster Input Assembler Vertex Shader New Patch primitive type Arbitrary vertex count (up to ) No implied topology Only supported primitive when tessellation is enabled Input Assembler Vertex Shader Hull Shader TS Domain Shader Transforms patch control points Usually used for: Animation (skinning, blend shapes) Physics simulation Allows more expensive animation at a lower frequency Input Assembler Vertex Shader Hull Shader TS Domain Shader Geometry Shader Geometry Shader Setup/Raster Setup/Raster 008 NVIDIA Corporation. All rights reserved.
MGB 005 Hull Shader (HS) Domain Shader (DS) One invocation per patch Parallelized explicitly. Code split to multiple threads by compiler One thread per output control point One thread per patch constant Vertex Shader HS input: [..] control points Hull Shader One invocation per generated vertex DS input: control points Tess factors Hull Shader TS DS input: U V {W} coordinates HS output: [..] control points Tessellation factors TS Domain Shader Domain Shader DS output: one vertex Surface Evaluation DS shader simply evaluates the bicubic Bezier patch and the corresponding tangent fields Special care has to be taken to obtain watertight results (prevent cracks) Instanced Tessellation in DX0 All computations need to be symmetric along the patch edges Instanced Tessellation GS is not for tessellation We can approximate the tessellation pipeline with DirectX 0 API GS outputs triangles serially Instancing can be used to replicate patches GS Thread Thread Thread Thread Thread n 008 NVIDIA Corporation. All rights reserved.
MGB 005 GS is not for tessellation Limited output size (maximum 0 scalars) is not always enough If each vertex is float s, you can only tessellate up to 6x6 Use instancing instead Render pre-tessellated patch with instancing Set the entire mesh as instance data V U Use instancing instead Render pre-tessellated patch with instance count equal to patch count in the mesh Use instancing instead Pre-tessellated patch represents results of tessellating every input patch Patch data Patch 0 Patch Patch Patch... Patch n Instancing x = Use instancing instead Input attributes limitation Compute refined vertex position in the vertex shader using chosen evaluation algorithm Maximum VS input size is not enough to fit all data required for point evaluation Instead all data can be stored in buffers bound as shader resources Use Load() instruction to fetch this data Instanced tessellation 008 NVIDIA Corporation. All rights reserved.
MGB 005 Using Load() Store mesh data in vertex buffers Bind these buffers as shader resources Load() and InstanceID Use SV_InstanceID as an index to the patch buffer Patch Control points Patch 0 Patch Patch Patch... Patch n SV_InstanceID Load( InstanceID ) 0 Tangents Patch 0 Patch Patch Patch... Patch n Bitangents Patch 0 Patch Patch Patch... Patch n Texture coordinates Compute vertex position... n Patch 0 Patch Patch Patch... Patch n Computing U and V coords Application integration Use SV_VertexID to compute U and V coordinates for the current vertex SV_VertexID Without tessellation With tessellation U = VertexID mod LoD V = VertexID div LoD Compute vertex position SV_VertexID and SV_InstanceID is the only VS input Bind_mesh_vertex_buffer(); Bind_VS(); Bind_PS(); Draw ( primitives_count ); Bind_mesh_vertex_buffer_SRV(); Bind_tessellation_VS(); Bind_PS(); Draw_instanced ( primitives_count, refined_vertex_count ); Results of refinement Results of refinement Before After Before After 008 NVIDIA Corporation. All rights reserved.
MGB 005 Tips Pack all data in float-buffers to use Load() more efficiently Displacement Mapping Use n x n tessellation and bitwise operations to compute U and V from Vertex_ID Integer division is slow! Kenneth Scott, id Software 008 Displacement Maps Consistent Normal Evaluation Crack-free displacement maps Control tangents along edges are not symmetric: Consistent normal evaluation Watertight texture sampling Watertight Texture Sampling Watertight Texture Sampling Texture seams cause holes in the mesh! Due to bilinear discontinuities Varying floating point precision on different regions of the texture map Seamless parameterizations remove bilinear artifacts, but do not solve floating point precision issues 008 NVIDIA Corporation. All rights reserved.
MGB 005 Watertight Texture Sampling Texture coordinate interpolation yields different result depending on location of the seam edges: Content Creation Production Pipeline Modeling Tools Base surface Sculpting Tools Detailed mesh Baker Tools Normal, displacement, occlusion, and other maps Modeling Performance depends on number of topology combinations Optimization guidelines: Eliminate triangles (Quad only meshes) Close holes (Avoid open meshes) Reduce number of extraordinary vertices Decrease number of patches to the minimum Try to create uniform, regular meshes Topology Optimization Topology Optimization 05 topology combinations topology combinations Mike Asquith, Valve Corporation 007 Mike Asquith, Valve Corporation 007 008 NVIDIA Corporation. All rights reserved.
MGB 005 Topology Optimization NVIDIA Mesh Processing Tool Topology visualization tool (nvanalyze) Maya plugin that highlights faces that damage mesh quality the most Successor of NVMeshMender and NVTriStrip but for subdivision surfaces: Reorder faces for consistent adjacencies Minimize topology combinations Pre-compute stencils for different approximation schemes Compute texture coordinates for watertight texture sampling Optimize vertex and face order for best performance And more! Sculpting Baker Tools Many tools available: Autodesk Mudbox Pixologic ZBrush modo, Silo, Blender, etc. Many options: xnormal Mudbox, ZMapper Melody, etc. PolyBump, etc. Two approaches Ray casting Dual parameterization Vector Displacements NVIDIA Baker Tool Native representation of most sculpting tools Uses dual parameterization to extract: Normal and displacement maps Only tool that generates vector displacements Occlusion maps, and more! No other tool supports custom base surfaces: Bezier ACC Gregory ACC Triangle meshes Mike Asquith, Valve Corporation 007 D Displacements Mike Asquith, Valve Corporation 007 D Displacements 008 NVIDIA Corporation. All rights reserved.
MGB 005 NVIDIA Baker Tool Thanks Uses optimized Montecarlo Raytracer Can be easily extended to support: Bent normals Spherical harmonic PRTs etc. Bay Raitt, Mike Asquith, Valve Corporation Kenneth Scott, id Software Full source code will be openly available Questions? calin@nvidia.com 008 NVIDIA Corporation. All rights reserved.