Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf ·...

Preview:

Citation preview

Higher Order SurfacesHigher Order SurfacesHenry Moreton

Why surfaces?Higher order primitives

Animation

Level of Detail

Bandwidth

Filtering

The “Surfaces” RoadmapPolynomial Surfaces

B-Spline, BézierTensor product, Triangle

Subdivision SurfacesCatmull-Clark, Loop

Displacement Mapping

Massive Levels of Geometric Detail

Geo

met

ricCo

mpl

exity

CPU

CPU

Graphics Processor

Graphics Processor

PreviousGeneration

1 Frame(1/60 sec)

1 Frame(1/60 sec)

AI,Physics,Game Play

Transform& Lighting Rendering

T&L Created A Major Content Shift...

Current Generation

A New Band of Computation

CPU Graphics Processor

AI,Physics,Game Play

Transform& Lighting RenderingGeometry

Processing

...Another Order of Magnitude

❋image courtesy of Pixar Animation Studios

The GeForce3 Graphics Pipelinecurved

surfaces

vertexshaders

setuprasterizer

tex-addrops

textureblending

frame-bufferantialiasing

shadowtextures

per-vertex geometry & shading programs

per-pixel shading

Historical Solution e.g. OpenGL Evaluators

Square - tensor product patches

Grid - just specify rows and columns

Integer - number of segments

Share - use T&L hardware

10

20

Triangular Patches are Necessary

3DStudioMax

Patch outlines

Hardware emulation

SquareGridIntegerShare

Four Independent Tessellation Factors

4

6 5

9

4

9

56

SquareGridIntegerShare

Generalized Tessellation isImportant

SquareGridIntegerShare

Fractional Number of Segments

6.0

6.25

6.5

6.75

7.0

SquareGridIntegerShare

LOD Morphing Suppresses Visual Artifacts

SquareGridIntegerShare

Multiple Tessellation StylesOptimal TessellationMorphing Tessellation

SquareGridIntegerShare

Dedicated Hardware

Doesn’t slow down transform

Performance matched pipeline

Most efficient way to draw triangles

Bandwidth

CPU – light weight animation

Transform & Lighting – great vertex reuse

SquareGridIntegerShare

Setting Tessellation Factorsedge based – (patch soup)

Crack preventionTessellation factors must be specified consistently for shared edges.Data structures or -Tessellation factors must be based on shared information, patch edges.

CriteriaCurvatureScreen space

Transform the control hull edge (Bézier)Silhouettes

Shared surface normals

How to Get Started?

ModelingPolynomial Patches – quadrilateral and triangular

DX8Bézier, B-spline, & Catmull-Rom spline patches

OpenGL Bézier patches – rational

NO Trimmed NURBSUse exporters -

Maya, 3DStudio

DX8 InterfaceSurface representation

Bézier

B-spline

Catmull-Rom

Shape (domains)

Quadrilateral

Triangular

Constraints

Uniform degree

Bézier Catmull-Rom

B-spline

DX8 Entry Points

DrawRectPatch & DrawTriPatch Specify and draw triangular/rectangular patches

DeletePatchFree cached patches

SetRenderState D3DPATCHEDGESTYLE

Discrete - integerContinuous – fractional

CAPSD3DDEVCAPS_RTPATCHES D3DDEVCAPS_QUINTICRTPATCHES

OpenGL Interface

Surface representation

Bézier

Shape (domains)

Quadrilateral

Triangular

OpenGL Entry Points

MapControlPointsNVEVAL_2D_NV or EVAL_TRIANGULAR_2D_NV

Specify the control points for the vertex component

MapParameterivNV & MapParameterfvNVMAP_TESSELLATION_NV

Specify the tessellation factors for the patch

EvalMapsNVTessellate (render) the patch, sending vertices, forming triangles to T&L

Tips & TechniquesDos & Don’ts

Level of detail calculationMemory footprintPerformanceMixing with meshesContinuityTangents, normals & bi-normalsSkinning and blending

Level of Detail Calculationscreen space edge length

By patch – significant foreshorteningTransform to screen spaceCompute control hull lengthDivide by desired edge length

By object – little foreshorteningBeforehand

Compute boundary lengths in model spaceEach frame (or so)

Transform Bbox or proxy to screen spaceCompute sizeScale relative lengths computed off-line

Variable vs. Fixed LOD by Object

24,794 triangles6,326 triangles

Memory Footprint

With tessellation factors A,B,C,Dmin(max(A,C), max(B,D))××××order + 3××××order + slopRoughly 2x for fractional tessellation

Equivalent triangle meshmax(A,C) ×××× max(B,D) + min(A,C) + min(B,D) + 1

Comparison – bi-cubicAssume A=B=C=D4A + 16 vs. A^2 + 2A + 1

0

20

40

60

80

100

1 2 3 4 5 6 7 8 9

patchestriangles

Performance - Hardware

One “clock” per degreeBi-cubic position 3

Two partial derivatives 5

Two linearly varying textures 2

total 10 clocks

Performance – SoftwareChange nothing

time to transfer data

Change tessellation (LOD)order^3 multiplies (matrix mult) + order ×××× (order-1) adds

Change geometry+ order^3 multiplies (matrix mult)

Similar to your costs…

Integer tessellationUse tessellation factor of oneUse patch normal

Fractional tessellationAlways splits once…Use tessellation factor of twoCalculate boundary mid point using subdivisionUse patch normal

Mixing with Meshes

Tangents, Normals & Bi-Normals

Autonormal – Standard T&LDriver does the work for you…Only use with standard T&L

Manual – Vertex ShaderCompute tangents (partial derivatives)Compute normal (cross product) in Shader

Partials are simple!Subtract rows and/or columns of control pointsTriangles too

Partial Derivatives

Skinning & Blending

Modify control points on the CPUSimpleRecalculate patch every change (frame?)

Activate union of matricesFor each patch take union of matricesInterpolate weights using a patch or patches

Continuity

Affected regionControl points neighboring boundary

ComplicationsSome control points are incident to two boundaries

SolutionProject onto a plane at the corner

Demos - Animation

Demos – LOD morphing

Examples!

Examples…

Questions, comments, feedback

• www.nvidia.com/developer

Recommended