You are on page 1of 41

Direct3D 11 Tessellation

Speaker: Kevin Gee


Research: Charles Loop / Scott Schafer Slides: Shanon Drone, Matt Lee, Michael Oneppo

Design Background
Programmable pipeline can target any surface approach. One primary scenario facilitates subdivision surfaces as a primitive type. Charles Loop and Scott Schaefer provided a reference approximation to Catmull-Clark. Converts Sub-D surface into Bezier patches. Other approaches are possible too.

Why Tessellate?
Many reasons including Reduced asset memory size More morph targets Cheap / free LODs
Reduced asset creation time

Improved pixel shader utilization Reduced GPU skinning costs Run faster simulations Move Sub-D costs to GPU

Asset Size: Comparison

Pre-Tesselated Mesh: ~5500 kb Sub-D Mesh: ~130 kb

Morph Targets
Huge potential memory / size wins Morph targets in Sub-D take up less space than fully-tessellated \ sparse morph targets Enable richer animations for the same memory cost

Level of Detail
Continuous LOD becomes possible. Reduces content creation time
Cheaper than building & testing explicit LODs

Improves pixel shader quad utilization

Faster Simulation
Skin at the control mesh level
Saves skinning costs

Cloth in Sub-D
Reduces the resolution of the simulation Keeps a smooth surface for rendering The more complex the simulation, the bigger the savings

Compute surface constraints at a lower frequency


Limit high-frequency positions to avoid penetrations

DIRECT3D 11 PIPELINE OVERVIEW

Input Assembler

V ertex Buffer Index Buffer

V ertex Shader

T exture

G Hull eometry Shader

T exture Stream O utput

Rasterizer/ T essellator Interpolator

Domain Pixel Shader

T exture

O utput Merger

Depth/ Stencil Render T arget

New Primitives

Hull Shader
Operates per input primitive
E.g. patch

Computes control point transforms


E.g. Basis Change

Computes tessellation factors per edge of generated patches

Hull Shader Syntax


[patchsize(12)] [patchconstantfunc(MyPatchConstantFunc)] MyOutPoint main(uint Id : SV_ControlPointID, InputPatch<MyInPoint, 12> InPts) { MyOutPoint result;

result = TransformControlPoint( InPts[Id] ); return result; }

Tessellator
Inputs
Takes in Tessellation Factors provided by the Hull shader Tess factors per-side in the range of [2.0..64.0]

Outputs
UV or UVW domain points Connectivity of those points (tris, lines) No adjacency information

Many possible partitioning schemes

demo
Tessellation Scheme

Domain Shader
Operates on each point generated by the tessellator Gets ALL control points as input
Control points and patch constant data are passed directly to the domain shader

Evaluate primitive surface to compute position of points


Convert from U,V space into positions, tangents

Domain Shader Syntax


void main( out MyDSOutput result, float2 myInputUV : SV_DomainPoint, MyDSInput DSInputs, OutputPatch<MyOutPoint, 12> ControlPts, MyTessFactors tessFactors ) { result.Position = EvaluateSurfaceUV( ControlPoints, myInputUV ); }

APPLYING SUBDIVISION SURFACES TO THE PIPE

What Are Subdivision Surfaces?


Surfaces defined by iterative refinement Many different techniques
Catmull-Clark (1978) Doo-Sabin (1978) Loop (1987)

Techniques differ primarily in edge cases and fixing trouble spots in previous techniques

Catmull-Clark Subdivision
Start with a quad mesh Faces and edges are split in the center Vertices are averaged with their surrounding neighbors Infinite iteration results in the limit surface

Why Catmull-Clark?
Broad support from industry and modeling packages Parametric evaluation introduced in 1998 (Stam) at Alias|wavefront Further refinements added edges and creases Pixar adopted Catmull-Clark early
Facilitates rich character animation

Sub-Ds In Current Systems


Build the model in Sub-Ds
Modeling, texturing, rigging

Configure & preview displacement maps At export time


Tessellate into a poly mesh Apply displacement maps Write to disk

Game engine
Apply skinning transform Rasterize

Proposed Future System


Build the model in Sub-Ds Configure & preview displacement maps Export Sub-D mesh Game engine
Convert Sub-D mesh into parametric surface Tessellate to desired LOD level Apply displacement maps and skinning Rasterize

Catmull-Clark Terminology
Vertex, edge, quad Valence is number of incident edges to a vertex Regular vertex has a valence of 4, otherwise it is an extraordinary vertex

Regular Vertex Extraordinary Vertex

Loop/Schaefer Research
Represent each quads limit surface as a bicubic patch (16 knots, 4x4) Add two biquadratic patches that create a U and V tangent field
12 knots, 3x4 each Cross-product is the normal vector

Adjust the U and V patch edges to account for surface discontinuities around extraordinary vertices

Implementation Overview
Initialization time
Load Sub-D mesh (quad mesh) Build adjacency-based patches
Use 1-ring of vertices around each quad

Compute texture tangent space for each vertex

Run time
Skin the quad mesh in the vertex shader (VS) Convert Sub-D mesh into patches in the Hull shader (HS) Evaluate patches using the domain shader (DS)

Quad Mesh

Input Quads
Each patch consists of 4 inner quad vertices and a 1-ring neighborhood

Sub-D Patch

1-Ring Neighborhood

D3D11 Sub-D Pipeline Overview


Sub-D Patch Buffer Skin

Draw
o Single pass o No additional memory o Avoids 16 fetches per vertex o Variable tessellation within a draw o Subsets of HS can operate in parallel

VS Hull Shader
Tessellator Domain Shader GS PS

Regular and Extraordinary


Regular patches
All vertices have 4 edge-adjacent neighbors
Valence 4

Predictable amount of data and work

Extraordinary patches
Any irregular patch Not quite as predictable Require a little more work Draw call per valence supported

demo
Direct3D 10 SDK Sample Subdivision Surfaces

Handling Creases
Add redundant geometry
Redundant Defined geometry crease

More Loop/Schaefer Research


Latest version: Modified Approximate Catmull-Clark Patches (ACC2) Outputs a Bezier patch consisting of 16 control vertices for regular patches Outputs a Gregory patch consisting of 20 control vertices for extraordinary patches

New Research (ACC2)


Collapse position and tangent into a single bicubic patch
Fewer control points, less memory
b03 b13 b23 b33

Modification of a Gregory patch


Bicubic patch with 2 sets of interior knots (20 knots total)

b12v b02 b12u

b22v b22u

b32

b11v b01 b11u

b21v b21u

b31

b00

b10

b20

b30

ACC2 Patch

ACC2 Patch - Position

Average the inner point pairs and evaluate the resulting 4x4 bicubic patch for position

ACC2 Patch - Tangents

ACC2 Math
pi+1
b20,i+1

v
b00

b10,i+1

b11u,i b11v,i

qi

b10,i

b20,i

pi

pi-1 qi-1

This is a lot
Theres a lot of complexity here, but its worth it D3D11 can target almost any surface algorithm you want
Bezier NURBs Dynamic and static tessellation Displacement Subdivision (using Loop transforms) and more

Call to Action!
Experiment with the D3D10 Subdivision Surface Sample from the DirectX SDK NOW! Build support for Sub-D meshes into your pipelines, tools, and engines. Look for a future Community Tech Preview (CTP) of Direct3D 11.

www.xnagamefest.com

2008 Microsoft Corporation. All rights reserved.


This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

You might also like