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

37
Higher Order Surfaces Higher Order Surfaces Henry Moreton

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

Page 1: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Higher Order SurfacesHigher Order SurfacesHenry Moreton

Page 2: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Why surfaces?Higher order primitives

Animation

Level of Detail

Bandwidth

Filtering

Page 3: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 4: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 5: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

A New Band of Computation

CPU Graphics Processor

AI,Physics,Game Play

Transform& Lighting RenderingGeometry

Processing

Page 6: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

...Another Order of Magnitude

❋image courtesy of Pixar Animation Studios

Page 7: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

The GeForce3 Graphics Pipelinecurved

surfaces

vertexshaders

setuprasterizer

tex-addrops

textureblending

frame-bufferantialiasing

shadowtextures

per-vertex geometry & shading programs

per-pixel shading

Page 8: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 9: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Triangular Patches are Necessary

3DStudioMax

Patch outlines

Hardware emulation

SquareGridIntegerShare

Page 10: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Four Independent Tessellation Factors

4

6 5

9

4

9

56

SquareGridIntegerShare

Page 11: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Generalized Tessellation isImportant

SquareGridIntegerShare

Page 12: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Fractional Number of Segments

6.0

6.25

6.5

6.75

7.0

SquareGridIntegerShare

Page 13: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

LOD Morphing Suppresses Visual Artifacts

SquareGridIntegerShare

Page 14: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Multiple Tessellation StylesOptimal TessellationMorphing Tessellation

SquareGridIntegerShare

Page 15: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 16: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 17: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 18: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

DX8 InterfaceSurface representation

Bézier

B-spline

Catmull-Rom

Shape (domains)

Quadrilateral

Triangular

Constraints

Uniform degree

Bézier Catmull-Rom

B-spline

Page 19: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

DX8 Entry Points

DrawRectPatch & DrawTriPatch Specify and draw triangular/rectangular patches

DeletePatchFree cached patches

SetRenderState D3DPATCHEDGESTYLE

Discrete - integerContinuous – fractional

CAPSD3DDEVCAPS_RTPATCHES D3DDEVCAPS_QUINTICRTPATCHES

Page 20: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

OpenGL Interface

Surface representation

Bézier

Shape (domains)

Quadrilateral

Triangular

Page 21: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 22: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Tips & TechniquesDos & Don’ts

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

Page 23: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 24: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Variable vs. Fixed LOD by Object

24,794 triangles6,326 triangles

Page 25: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 26: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Performance - Hardware

One “clock” per degreeBi-cubic position 3

Two partial derivatives 5

Two linearly varying textures 2

total 10 clocks

Page 27: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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…

Page 28: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 29: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 30: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Partial Derivatives

Page 31: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

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

Page 32: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Continuity

Affected regionControl points neighboring boundary

ComplicationsSome control points are incident to two boundaries

SolutionProject onto a plane at the corner

Page 33: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Demos - Animation

Page 34: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Demos – LOD morphing

Page 35: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Examples!

Page 36: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Examples…

Page 37: Higher Order Surfaces - Nvidiadeveloper.download.nvidia.com/assets/gamedev/docs/Surfaces.pdf · Higher order primitives Animation Level of Detail Bandwidth Filtering. The “Surfaces”

Questions, comments, feedback

• www.nvidia.com/developer