390 likes | 649 Views
Higher Order Surfaces. Henry Moreton. Why surfaces? Higher order primitives. Animation Level of Detail Bandwidth Filtering. The “Surfaces” Roadmap. Polynomial Surfaces B-Spline, Bézier Tensor product, Triangle Subdivision Surfaces Catmull-Clark, Loop Displacement Mapping
E N D
Higher Order Surfaces Henry Moreton
Why surfaces?Higher order primitives • Animation • Level of Detail • Bandwidth • Filtering
The “Surfaces” Roadmap • Polynomial Surfaces • B-Spline, Bézier • Tensor product, Triangle • Subdivision Surfaces • Catmull-Clark, Loop • Displacement Mapping Massive Levels of Geometric Detail
T&L Created A Major Content Shift... CPU Graphics Processor Previous Generation 1 Frame (1/60 sec) AI, Physics, Game Play Transform & Lighting Rendering Current Generation 1 Frame (1/60 sec) Graphics Processor CPU
AI, Physics, Game Play Geometry Processing Transform & Lighting Rendering Graphics Processor CPU A New Band of Computation
...Another Order of Magnitude k image courtesy of Pixar Animation Studios
The GeForce3 Graphics Pipeline curved surfaces vertex shaders per-vertex geometry & shading programs setup rasterizer tex-addr ops shadow textures texture blending per-pixel shading frame-buffer antialiasing
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
Square Grid Integer Share Triangular Patches are Necessary Hardware emulation 3DStudio Max Patch outlines
Square Grid Integer Share Four Independent Tessellation Factors
Square Grid Integer Share Generalized Tessellation is Important
Square Grid Integer Share Fractional Number of Segments 6.0 6.25 6.5 6.75 7.0
Square Grid Integer Share LOD Morphing Suppresses Visual Artifacts
Square Grid Integer Share Multiple Tessellation Styles Morphing Tessellation Optimal Tessellation
Square Grid Integer Share 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
Setting Tessellation Factorsedge based – (patch soup) • Crack prevention • Tessellation factors must be specified consistently for shared edges. • Data structures or - • Tessellation factors must be based on shared information, patch edges. • Criteria • Curvature • Screen space • Transform the control hull edge (Bézier) • Silhouettes • Shared surface normals
How to Get Started? • Modeling • Polynomial Patches – quadrilateral and triangular • DX8 • Bézier, B-spline, & Catmull-Rom spline patches • OpenGL • Bézier patches – rational • NO Trimmed NURBS • Use exporters - • Maya, 3DStudio
DX8 Interface • Surface 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 • DeletePatch • Free cached patches • SetRenderState • D3DPATCHEDGESTYLE • Discrete - integer • Continuous – fractional • CAPS • D3DDEVCAPS_RTPATCHES • D3DDEVCAPS_QUINTICRTPATCHES
OpenGL Interface • Surface representation • Bézier • Shape (domains) • Quadrilateral • Triangular
OpenGL Entry Points • MapControlPointsNV • EVAL_2D_NV or EVAL_TRIANGULAR_2D_NV • Specify the control points for the vertex component • MapParameterivNV & MapParameterfvNV • MAP_TESSELLATION_NV • Specify the tessellation factors for the patch • EvalMapsNV • Tessellate (render) the patch, sending vertices, forming triangles to T&L
Tips & TechniquesDos & Don’ts • Level of detail calculation • Memory footprint • Performance • Mixing with meshes • Continuity • Tangents, normals & bi-normals • Skinning and blending
Level of Detail Calculation screen space edge length • By patch – significant foreshortening • Transform to screen space • Compute control hull length • Divide by desired edge length • By object – little foreshortening • Beforehand • Compute boundary lengths in model space • Each frame (or so) • Transform Bbox or proxy to screen space • Compute size • Scale relative lengths computed off-line
Variable vs. Fixed LOD by Object 6,326 triangles 24,794 triangles
Memory Footprint • With tessellation factors A,B,C,D • min(max(A,C), max(B,D))order + 3order + slop • Roughly 2x for fractional tessellation • Equivalent triangle mesh • max(A,C) max(B,D) + min(A,C) + min(B,D) + 1 • Comparison – bi-cubic • Assume A=B=C=D • 4A + 16 vs. A^2 + 2A + 1
Performance - Hardware • One “clock” per degree • Bi-cubic position 3 • Two partial derivatives 5 • Two linearly varying textures 2 total 10 clocks
Performance – Software • Change 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…
Mixing with Meshes • Integer tessellation • Use tessellation factor of one • Use patch normal • Fractional tessellation • Always splits once… • Use tessellation factor of two • Calculate boundary mid point using subdivision • Use patch normal
Tangents, Normals & Bi-Normals • Autonormal – Standard T&L • Driver does the work for you… • Only use with standard T&L • Manual – Vertex Shader • Compute tangents (partial derivatives) • Compute normal (cross product) in Shader • Partials are simple! • Subtract rows and/or columns of control points • Triangles too
Skinning & Blending • Modify control points on the CPU • Simple • Recalculate patch every change (frame?) • Activate union of matrices • For each patch take union of matrices • Interpolate weights using a patch or patches
Continuity • Affected region • Control points neighboring boundary • Complications • Some control points are incident to two boundaries • Solution • Project onto a plane at the corner
Questions, comments, feedback • www.nvidia.com/developer