My Tessellation Has Cracks! (and solutions to other tessellation related problems) Bryan Dudash Developer Technology, NVIDIA.

Slides:



Advertisements
Similar presentations
Destruction Masking in Frostbite 2 using Volume Distance Fields
Advertisements

Advanced Visual Effects with Direct3D
Exploration of advanced lighting and shading techniques
Tesselation Shaders. Tesselation  dictionary definition of tesselate is the forming of a mosaic.
Dragon Age II DX11 Technology
Tessellation on Any Budget John McDonald Developer Technology NVIDIA Corporation.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
The Art and Technology Behind Bioshock’s Special Effects
3D Graphics Rendering and Terrain Modeling
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
Week 7 - Wednesday.  What did we talk about last time?  Transparency  Gamma correction  Started texturing.
Results / Compared to Relief Mapping It does not scale linearly with screen coverage as does the other techniques. However, for larger displacements, it.
MATHIEU GAUTHIER PIERRE POULIN LIGUM, DEPT. I.R.O. UNIVERSITÉ DE MONTRÉAL GRAPHICS INTERFACE 2009 Preserving Sharp Edges in Geometry Images.
Damon Rocco.  Tessellation: The filling of a plane with polygons such that there is no overlap or gap.  In computer graphics objects are rendered as.
Computer Graphics Hardware Acceleration for Embedded Level Systems Brian Murray
(conventional Cartesian reference system)
Content Subdivision First some basics (control point polygon, mesh)
Status – Week 277 Victor Moya.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Under the Hood: 3D Pipeline. Motherboard & Chipset PCI Express x16.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Computer Graphics Texture Mapping
Light Using Texture Synthesis for Non-Photorealistic Shading from Paint Samples. Christopher D. Kulla, James D. Tucek, Reynold J. Bailey, Cindy M. Grimm.
COLLEGE OF ENGINEERING UNIVERSITY OF PORTO COMPUTER GRAPHICS AND INTERFACES / GRAPHICS SYSTEMS JGB / AAS 1 Shading (Shading) & Smooth Shading Graphics.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
Surface displacement, tessellation, and subdivision Ikrima Elhassan.
Geometry Images Xiang Gu Harvard University Steven J. Gortler Harvard university Hugues Hoppe Microsoft Research Some slides taken from Hugues Hoppe.
3D Graphics for Game Programming Chapter IV Fragment Processing and Output Merging.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Game Programming 06 The Rendering Engine
Maths & Technologies for Games DirectX 11 – New Features Tessellation & Displacement Mapping CO3303 Week 19.
Shader Study 이동현. Vision engine   Games Helldorado The Show Warlord.
CS418 Computer Graphics John C. Hart
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
CS324e - Elements of Graphics and Visualization Fractals and 3D Landscapes.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
04/18/02(c) 2002 University of Wisconsin Last Time Hermite Curves Bezier Curves.
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Advanced D3D10 Shader Authoring Presentation/Presenter Title Slide.
Graphics, Modeling, and Textures Computer Game Design and Development.
Modeling The process of creating 3D Objects
Tessellation Shaders.
Week 7 - Wednesday CS361.
Deferred Lighting.
3D Graphics Rendering PPT By Ricardo Veguilla.
Chapter 6 GPU, Shaders, and Shading Languages
The Graphics Rendering Pipeline
Chapter 14 Shading Models.
Chapters VIII Image Texturing
Graphics, Modeling, and Textures
Introduction to Meshes
Chapter XVIII Surface Tessellation
Computer Graphics Introduction to Shaders
Chapter 14 Shading Models.
03 | Creating, Texturing and Moving Objects
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Patch Textures: Hardware Implementation of Mesh Colors
Introduction to Meshes
Presentation transcript:

My Tessellation Has Cracks! (and solutions to other tessellation related problems) Bryan Dudash Developer Technology, NVIDIA

Agenda ● Super-Quick Tessellation Review ● How cracks/holes are born ● Specific examples ● PN Triangles cracking ● Displacement map cracking ● Other Tessellation Issues ● Debugging Techniques ● Ptex

Super-Quick Tessellation Review ● Hull Shader ● Processes control points ● Decides tessellation factor ● Tessellator ● Fixed function ● Generates barycentric coords ● Based on tess factors from HS ● Domain Shader ● Calculates final tessellated vertices ● Interpolates data using barycentric coords Domain Shader Hull Shader Tessellator Vertex Shader Setup/Raster Pixel Shader

What is a “crack”? ● Visible seam between edges in the mesh ● Often large color variance on cracked pixels ● Can see the background as backfaces are culled ● Vertices on shared edges that should share a position (along edge) are offset such that they no longer share the same position.

Holes: The other “crack” ● A “hole” is when shared control vertices diverge position ● Can think of this as multiple “cracks” ● Can result in much larger seams ● Same avoidance methods as cracks ● Can cause holes without tessellation! ● Different vertex offsets in VS per SV_PrimitiveID

How cracks are born ● Two primitives share an edge positionally, but the vertices of that edge have divergent data ● Normal, UV, etc ● Domain Shader interpolates divergent data sets ● Can result in large differences in tessellated positions ● Only along control edges/vertices ● Interior edges are guaranteed not to crack ● In practice float LSB differences don’t crack ● Primitive winding means operations are in different order ● Theoretically possible to have micro-cracking

b c a i h d e f g General Solution to Cracking ● Ensure the domain shader is using same input data ● Shared Vertices ● Shared Edges ● What is “same data”?

PN Triangles & PN-AEN ● Vertex normals used to calculate Bezier splines ● offsets tessellated vertices ● Divergent normals = Divergent splines ● Which leads to cracks ● Adjacent Edge Normals (AEN) ● Average Normals along Edges ● Phong Tessellation ● Same issue ● Same solution PN Triangles w/ Averaged Normals

b c a i h d e f g Implementing AEN ● Method 1 : Index Buffer ● Add extra indices per primitive ● Point to adjacent edges ● Average Normals in Shader ● Method 2 : Texture ● Store Averaged Normals ● “Smoothed Normals” ● Two per edge ● Load() in Shader ● SV_VertexID Index Buffer abcdefghi Texture N ad N be N bf N cg N ch N ai

AEN Alternative: Smoothed Normal ● Use average normals from entire mesh ● PN “done right”? ● Used only for PN/Phong interpolation ● Averages all valence vertices ● Less “same data” ● Only one tex sample per vertex ● Could be integrated into VB ● Results in more “puffy” PN splines ● Normals from irrelevant edges PN-AEN Smooth Normals

Displacement Map Cracking(1) ● UV coordinates are discontinuous ● UV unwrap results in seams ● Edge length in texture space also not identical ● Edge direction in texure space divergent ● Historical “issue” for texture mapping ● Divergent locations contain similar values ● Normal mapping sometimes shows issues ● Displacement offsets along shared edges ● Displacements interpolated along the edge and will pick up slightly varying values

Solution: Dominant UVs ● Override UV for sampling displacement ● This is safe as we only override along the shared edge and control vertices ● An edge will never crack from itself ● Interior primitives uses the original UVs

b c a Dominant Data ● Lookup at runtime into preprocessed data ● Overridden IB ● Data to stuff into texture ● Edges separate from Corners ● Only 2 possible shared edges to pick from for any primitive ● N shared “non edge” vertices ● Dominant Vertex may or may not be on Dominant Edge ● Can be arbitrary ● All shared vertices must have the same dominant data ● Both edge vertices must be from the same primitive Control Vertex Dominant Vertex aA bE cH Control Edge Dominant Edge a-bD-E b-cB-C c-aH-I

J E A C B HI E D Index Buffer Texture UdVdUeUdVdUe Implementing Dominant UVs ● Method 1: Index Buffer ● Add indices for dominant edge ● Can use AEN edge data as well ● Add indices for dominant vertex ● Method 2: Texture ● Encode UV ● 2 Samples per control point abcDEBCHAEJI VeUAVAVeUAVA

Dominant Data Generation ● CPU side pre-process ● Typically done as part of a build/cook process ● Can be done on mesh load as well ● Generate Packed Listing of shared position & edges ● List of indices at each shared position ● List of index tuple at each shared edge start ● Arbitrarily pick dominant data ● First entry in the list ● It really is that simple

Intra-material cracking ● Meshes in games often have multiple materials ● Submeshes render as separate draws ● With separate textures and UV spaces ● No access to neighbor info across seams ● Solutions ● If submeshes share a VB, then AEN style techniques can work ● Smooth normal/Dominant UV texture can encode data from group of submeshes ● Pin displacement to 0 at edge ● May not look “right” ● Alternative is mesh rework.

Virtual Dicing ● Tessellation factor limit of 64 ● 1 edge => 64 edges ● This limit can be hit for coarse meshes with high zoom ● One solution is to pre-dice mesh in DCC tool ● This requires artist time ● Potentially not matched to displacement map resolution ● Alternative is to programmatically subdivide ● Per primitive density control ● Match mesh density to displacement map resolution ● Add extra redundant indices into IB ● Reposition duplicates on interior of original

No Dicing – Dynamic Factor=64 12 Factor Diced – Dynamic Factor=32

Virtual Dicing Implementation ● Add duplicate primitives ● “inflated” index buffer ● # of addition varies per prim ● Barycentric coords texture ● Remap of new control verts ● Interpolation of originals ● Hull Shader repositions vertices ● SV_PrimitiveID determines Load() Domain Shader Hull Shader Tessellator Custom Barycentrics Texture Inflated Index Buffer Vertex Shader Original Vertex Buffer LOAD SV_PRIMITIVE_ID Repositioned Diced Control Points Dynamic Tess Factors Dynamic Barycentrics

Ptex – Per-face TEXture ● Developed at Walt Disney Animation Studios ● By Brent Burley in 2008 ● As a method to remove UV unwrap serialization in art pipeline ● Texturing with implicit UVs ● One “texture” per primitive ● Power of two textures ● Quads only!

Ptex and Displacement Maps ● Ptex can be used with displacement maps ● No Holes ● Corners pinned at texgen ● No Cracks ● Edges all share common data ● Full Resolution Control ● Per-face control

Realtime Ptex ● DCC support already in place ● Realtime Ptex with DirectX11! ● Texture2DArray (also in D3D10) ● Quad primitives ● For more info: ● “ Practical Ptex for Games” ● Game Developer Magazine: January 2012 Content Production Bucket and Sort Generate Mipmaps Fill Texture Interiors Reorder Index Buffer Fill Texture Borders Pack Patch Constants

Questions?

Appendix A: Dicing C 100 C 010 C 001 C’ ½0½ P’ 1 P’ 2 I0I0 I2I2 I1I1 PrimI0I1I2 P’1V c100 V c010 V C½0½ P’2V C½0½ V c010 V c001

Appendix B: Debugging Techniques Verify your conventions Output Barycentric coordinates as diffuse color Reduce shader to flat tessellation add pieces back Remove clipping & “clever” optimizations Barycentric Coordinates as colors

Debugging Techniques cont’d ● Edge LOD specification ● for triangles is surprising ● Real-time graphics debugging tools ● Introspect graphics state ● Visualize mesh, texture and render target data ● Debug your tessellation shader (Hull/Domain) ● natively on the hardware

Appendix C :Texture Stretching UV space stretched when displacing Edge length in texture space is constant Physical edge length (world space) changes based on displacement Solution/Workaround 2-pass approach Reduce displacement of texels causing stretching on the second pass Texture stretching Reduced offsets