Maths & Technologies for Games DirectX 11 – New Features Tessellation & Displacement Mapping CO3303 Week 19.

Slides:



Advertisements
Similar presentations
Tesselation Shaders. Tesselation  dictionary definition of tesselate is the forming of a mosaic.
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Exploration of bump, parallax, relief and displacement mapping
Results / Compared to Relief Mapping It does not scale linearly with screen coverage as does the other techniques. However, for larger displacements, it.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
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.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 4: 3D Objects and Meshes Ravi Ramamoorthi
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Introduction to Modeling. What is CG Modeling? Combination of Sculpting, Architecture, Drafting, and Painting. The core component of computer animation.
My Tessellation Has Cracks! (and solutions to other tessellation related problems) Bryan Dudash Developer Technology, NVIDIA.
Computer Graphics Introducing DirectX
Modeling and representation 1 – comparative review and polygon mesh models 2.1 Introduction 2.2 Polygonal representation of three-dimensional objects 2.3.
Maths and Technologies for Games Water Rendering CO3303 Week 22.
Bresenham’s Algorithm. Line Drawing Reference: Edward Angel’s book: –6 th Ed. Sections 6.8 and 6.9 Assuming: –Clipped (to fall within the window) –2D.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Games Development Practices 3D Model Import/Export CO2301 Games Development 1 Week 17.
4.7. I NSTANCING Introduction to geometry instancing.
Computer Graphics Texture Mapping
Week 2 - Wednesday CS361.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
Geometric Modeling using Polygonal Meshes Lecture 1: Introduction Hamid Laga Office: South.
TERRAIN SET09115 Intro to Graphics Programming. Breakdown  Basics  What do we mean by terrain?  How terrain rendering works  Generating terrain 
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
Image Synthesis Rabie A. Ramadan, PhD 1. 2 About my self Rabie A. Ramadan My website and publications
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Subdivision Schemes Basic idea: Start with something coarse, and refine it into smaller pieces for rendering –We have seen how subdivision may be used.
GRAPHICS PIPELINE & SHADERS SET09115 Intro to Graphics Programming.
Game Programming 06 The Rendering Engine
Games Development 1 Camera Projection / Picking CO3301 Week 8.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
BUMP-MAPPING SET09115 Intro to Graphics Programming.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
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.
CS 450: Computer Graphics PARAMETRIC SPLINES AND SURFACES
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Computer Graphics Matrices
Emerging Technologies for Games Capability Testing and DirectX10 Features CO3301 Week 6.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Applications and Rendering pipeline
Three-Dimensional Art Composition
Games Development Practices 3D Modelling
Computer Graphics Index Buffers
Graphics Processing Unit
Deferred Lighting.
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Chapter 14 Shading Models.
Graphics Processing Unit
Introduction to geometry instancing
Lecture 13 Clipping & Scan Conversion
Games Development Practices 3D Model Import/Export
Chapter XVIII Surface Tessellation
Computer Graphics Introduction to Shaders
Computer Graphics Material Colours and Lighting
Chapter 14 Shading Models.
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
03 | Creating, Texturing and Moving Objects
Computer Graphics Introducing DirectX
Presentation transcript:

Maths & Technologies for Games DirectX 11 – New Features Tessellation & Displacement Mapping CO3303 Week 19

Today’s Lecture Direct3D 11 – New features Direct3D 11 – Changes from Direct3D 10 New DX11 Pipeline Tessellation Overview Patches Details: Hull Shader / Tessellation Stage / Domain Shader Displacement Mapping Technical Considerations and Issues

DirectX 11 – New Features DirectX 11 was introduced with Windows 7 But is also supported on Windows Vista Major new features introduced in DX11: Multithreaded rendering A single device can have several contexts Different threads that can render using the same resources Tessellation Introduced in this lecture Compute Shaders General purpose (non-graphics) programming on the GPU More recently, support has been added for DX10 hardware Shader Model 5.0 – extra shader language features High quality texture compression formats

Converting from DX10 to DX11 DirectX 11 is a strict superset of DX10.1 Nearly everything in DX10 works with minimal change Not like the huge changes from DX9 to DX10 Key points when converting: The device pointer (g_pD3DDevice) has been split in two A device pointer for overall control & a context pointer for each thread Use the immediate context pointer for single threaded work Context pointer used for most rendering: Draw, SetXXShader etc. The Effects framework (.fx) is not in the provided libraries Compile it ourselves (add an extra Effects11 project to our solution) DX maths libraries not in 11, now provided as an extra download No font support in the D3DX libraries (now an extra download) Or use Direct2D, DirectWrite, or a 3rd party library Minor changes to a few DX structures require code tweaks

New DX11 Pipeline Stages In order to support tessellation, DX11 adds three new stages to the rendering pipeline Two programmable stages: Hull Shader Domain Shader One fixed stage in between Tessellation stage No shader All three must be used together Only used when tessellating Disabled otherwise

Tessellation - Overview Input geometry is made of patches and control points Not strictly vertices and polygons Each patch has several control points, from 1 to 32 The vertex shader processes each control point Likely to convert into world space But probably not into viewport space since they are not ready for rendering The hull shader also processes each control point But can access all points for a patch Used for patch-specific transforms

Tessellation - Overview Hull shader has an associated patch constant function Called once per patch Determines the amount of tessellation required for that patch The tessellation stage tessellates the patch as required Tessellation occurs in generic 0->1 space, not world space The domain shader takes the generic tessellation and control points and creates final vertices Which are sent to the geometry / pixel shaders as normal Tessellation Stage: Generic tessellations with different tessellation factors Domain Shader: Control points shape the generic tessellation to create final mesh

Patches / Control Points Model geometry for tessellation uses patches and control points A patch is a line, triangle or quad, which is bent or shaped by some number of control points For example, a Bezier spline DirectX does not specify the available patch types We can choose any and implement it in hull and domain shaders This is potentially a huge change for game asset creation Patches suit artwork creation much better than polygonal modelling A quad patch and control points Head made from quad patches

Hull Shader The hull shader gets access to all the control points for a single patch and can process them in any way It outputs the final control points used to shape the patch It can output greater or fewer control points if necessary For many tessellation purposes, we don’t need to change the control points given Often the vertex shader converts to world space & they’re ready So many hull shaders just copy input to output However, they can be used for advanced purposes: Approximating complex input splines using simpler output splines Providing per-control-point information to help the patch constant function (see next slide)

Patch Constant Function The patch constant function is called once per patch It must decide how much to tessellate each patch It can also output other custom per-patch data It can access the input control points and the hull shader ouput control points (as arrays) to do its job Patch tessellation is specified as one Interior Tessellation Factor and three or four Edge Tessellation Factors That is for a triangle or quad patch. A line only has one factor These factors specify how much to divide the edges and split up the interior of each patch (see next slides) A simple patch constant function can just set fixed values More commonly the factors are increased as models get nearer, or for more complex areas of the geometry

Tessellation Stage The tessellation stage uses the factors specified in the patch constant function Divides up a unit square, triangle or line based on the factors It works in a generic 0->1 space Usually referred to with UV axes Outputs this generic geometry as vertices for the domain shader next Several fixed algorithms are available for the tessellation Specify in the hull shader code Edge Factors 3,1,1,1 Interior Factors: 1,1 (Horizontal / Vertical) Edge Factors 1,1,1,1 Interior Factors: 4,4 Edge Factors 4,4,4,4 Interior Factors: 4,4

Five Control points shaping a tessellated quad Domain Shader The domain shader: Takes control points output from the hull shader And the generic vertices output from the tessellation stage Combine to create final tessellation for the scene Exactly what this involves depends on the patch type At least involves transforming generic vertices to world space Then some manipulation based on the control points Five Control points shaping a tessellated quad Number of control points and formula used for shaping decided by programmer, e.g. NURBs Catmull-Clark surfaces, etc.

Distance / Density Variation It is common to vary the amount of tessellation used based on the geometry distance or complexity (density) Distance variation is simpler: The patch control function can look at the distance of the control points to the camera Make tessellation factor decisions based on that Density variation needs pre-processing: The patch control function can get an integer ID for each patch So analyse the complexity of each patch offline Store complexity in an array (1D texture) indexed by patch ID Patch control function reads this array to choose tessellation factors

“Water-tight” Patch Seams As soon as we vary tessellation per-patch, there are problems with patch seams Cracks in the geometry appearing at the edges between patches of different tessellation That is why we can control the edge tessellation separately Ensure all edges have the same tessellation factor in the patch on each side (watertight seams) Additional processing for the patch constant function / hull shader Adjacent patches, different tessellation – causes crack at seam Match edge tessellation to create “watertight” seams

Tessellation + Height Map Displacement Mapping Displacement mapping is adjusting the height of vertices based on heights stored in a texture (a height map) Effectively, this is parallax mapping done properly Result has correct silhouettes and no visual problems Requires finely detailed geometry, so it works well with tessellation A very effective method to provide fine geometry detail with less expense – and to make most effective use of the tessellation Can be used on most kinds of patch Parallax Mapping Tessellation + Height Map Displacement Mapping

Triangle Tessellation Used on polygonal mesh Displacement Mapping Control points and patches seem far from a game’s polygonal models But, can use displacement mapping and tessellation on polygons too: Call each triangle a patch Call the three vertices control points Use tessellation to create interior vertices and triangles Hull shader just copies control points Domain shader transforms generic tessellated triangle to position of original triangle – tangent-space work for this Displacement mapping on result vertices Need height map for displacement and a normal map for lighting Same requirements as parallax mapping Triangle Tessellation Used on polygonal mesh

Technical Issues Tessellation has performance implications: A very efficient method to draw large number of polygons However, minimise it: don’t tessellate off-screen, use lower tessellation in the distance, fall back to normal mapping etc. Displacement mapping brings more seam issues: Any discontinuity in texture, e.g. where two different textures meet, will cause a discontinuity in displacement (i.e. cracks) Even with the most careful mapping, this cannot be avoided Solve by specifying a dominant texture at patch seams Extra coding in the hull shader / patch constant function Sharp edges cause cracks (use normal map or averaging at edges) Models must be designed with displacement in mind Very low polygon models won’t work well. Start with the basic shape of the height map designed into the geometry (see lab)

Future for Tessellation in Games Will see tessellation / displacement mapping on standard polygonal models in the lab However, these technologies allow us to start using patch / control point based geometry instead Artists have long used patch-based modelling for commercial animation Catmull-Clark subdivision surfaces are quite well suited to GPU tessellation A low polygon surface that mathematically defines a curved patch There have been a few experiments with these in games already, expect to see variants of these used more frequently The polygon is dead (soon…)