Advanced D3D Programming Sim Dietrich

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Advanced Light and Shadow Culling Methods Eric Lengyel.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
1 Clipping. 2 Transformation Sequence X Y Z X Y Z X Y Z X Y Z Object Coords. Eye Coords. Clip Coords. Normalized Device Coords. Screen Coords. Implementation:
Clipping Lines Lecture 7 Wed, Sep 10, The Graphics Pipeline From time to time we will discuss the graphics pipeline. The graphics pipeline is the.
Computer Graphics Viewing.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Status – Week 231 Victor Moya. Summary Primitive Assembly Primitive Assembly Clipping triangle rejection. Clipping triangle rejection. Rasterization.
1 Lecture 8 Clipping Viewing transformations Projections.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Now Playing: California Stars Billy Bragg & Wilco from Mermaid Avenue
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Lecture 5: 3D Rendering Pipeline (II) Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Sky Rendering The actual physics is very complicated and costly to calculate. Several cheap approaches for very distant skies: –Constant backdrop –Skybox.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Buffers Textures and more Rendering Paul Taylor & Barry La Trobe University 2009.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Computer Graphics Lecture 32 Fasih ur Rehman. 3D Transforms The idea of 3D transforms is the same as that of 2D – A 3D point is represented by (x, y,
Windows, Viewports, and Clipping
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Implementation of a Renderer Consider Programs are processd by the system line & polygon, outside the view volume Efficiently Understanding of the implementation.
Chapter III Rasterization
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
CS552: Computer Graphics Lecture 12: 3D Clipping.
Chapter 71 Computer Graphics - Chapter 7 From Vertices to Fragments Objectives are: How your program are processed by the system that you are using, Learning.
CENG 538 Advanced Graphics and UIs
Computer Graphics Clipping.
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Computer Graphics Shading in OpenGL
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
3D rezanje 3D Clipping view frustrum clipping planes clipped.
Concepts, algorithms for clipping
3D Clipping.
Models and Architectures
Implementation I Ed Angel
Graphics Pipeline Clipping
Models and Architectures
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Lecture 13 Clipping & Scan Conversion
Chapter VII Rasterizer
Joshua Barczak CMSC 435 UMBC
© University of Wisconsin, CS559 Fall 2004
(c) 2002 University of Wisconsin, CS559
3D rezanje 3D Clipping view frustrum clipping planes clipped.
Clipping Clipping Sutherland-Hodgman Clipping
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
COMPUTER GRAPHICS Clipping
Presentation transcript:

Advanced D3D Programming Sim Dietrich SDietrich@nvidia.com Guard Band Clipping Advanced D3D Programming Sim Dietrich SDietrich@nvidia.com

Guard Band Clipping What is Guard Band Clipping? Why would you want to use it? Using Guard Band Clipping 2D Clip Testing and Guard Band 3D Culling and Guard Band How to Detect it

What is Guard Band Clipping? The ability for hardware to accept screen coordinates outside of the current viewport range. The basic idea of guard band clipping is that the hardware can accept triangles that are partially or totally off-screen. Some graphics processors support 2D coordinates within the range [-2048,-2048 to 2047,2047].

Guard Band and Viewport ( 1024x768 ) Guard Band ( 4096x4096 )

Guard Band and Viewport This triangle can be trivially accepted or rejected These triangles can be trivially accepted This triangle must be clipped

3D Frustum Clipping is Slow Requires dot products with 6 frustum planes for each vertex Produces extra vertices Each value at vertex ( u,v, fog, alpha, diffuse color, specular color ) requires interpolation More bandwidth required for each new vertex Breaks vertex cache coherency Clipping can break up strips and fans

Clip Testing is Faster 2D or 3D Clip testing combined with Guard band addresses these issues Most triangles that normally require clipping could be passed through to HW instead Keeps more strips and fans intact Maintain vertex cache coherency Apps must still clip to near and far clip planes

Guard Band Clipping Only in the rare case of a primitive crossing both the viewport and a Guard Band boundary is 3D frustum clipping necessary Either clip to the guard band boundary or the viewport boundary D3D clips triangles to the guard band Clipping to the viewport is preferred It’s smaller than the guard band, so less pixels Clipper will reject triangles outside viewport

Using Guard Band Clipping Direct3D takes advantage of Guard Band clipping automatically if present and Direct3D performs clipping If the app performs own transforms Detect the Guard Band extents If found, use 3D cull testing or 2D clip testing after culling and perspective transform If apps pass 2D coordinates to D3D, they should perform their own clipping, to keep Direct3D from de-projecting during its clipping

2D Clip Testing A version of Cohen-Sutherland clip-testing (FOLEY90) Generate outcodes for the viewport and the guard band’s borders for each vertex Outcode is a Bitfield : 0 means in, 1 means out Bitwise AND (&) and Bitwise OR ( | ) the outcodes in parallel to test various cases If primitive is within viewport accept If primitive is outside of viewport on at least 1 side, reject If primitive is in GB, accept If primitive crosses a GB boundary, clip to viewport

3D Culling and Guard Band An alternative to 2D clip testing is to use a second, larger frustum extending through the guard band borders for your 3D culling test. This eliminates the need to project the vertices to 2D before clip testing It is easily added to the end of your existing 3D culling

Top View of Guard Band and View Frustums Far Clip Plane Guard Band Frustum Left Guard Band Frustum Plane Right View Frustum Plane Near Clip Plane View Frustum Screen

3D Culling and Guard Bands Create a 3D view frustum that passes through the guard band borders Cull boxes or spheres of objects to this frustum and the normal viewing frustum If the object is within the guard band frustum and crosses an edge of the view frustum, you can trivially accept it instead of clipping it to the view frustum

3D Culling and Guard Bands For each object, calculate signed distance from the center of bounding sphere to each view frustum plane and compare to radius of sphere If it’s completely outside view frustum, reject If it’s completely inside view frustum, accept If it’s partially in, test against guard band frustum If completely in, accept it - This is where you save performance in avoiding clipping If it crosses a guard band frustum plane, clip it to view frustum as normal

Top View of Guard Band and View Frustums, and Bounding Spheres Far Clip Plane Guard Band Frustum B Clipped A Accepted C Rejected Near Clip Plane Screen View Frustum

Trivially Accepting Polygons If you trivially accept a set of polygons, render them with D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS If you omit this, Direct3D will clip test to guard band for you If you must clip a set of polygons that straddle both the view and guard band frustums, clip them to the view frustum

Detecting a Guard Band Call the DIRECT3DDEVICE3 interface GetCaps method to get the guard band extents hr = device->GetCaps( &aD3DHWDevDesc, &aD3DSWDevDesc ); aD3DHWDevDesc.dvGuardBandLeft; aD3DHWDevDesc.dvGuardBandRight; aD3DHWDevDesc.dvGuardBandTop; aD3DHWDevDesc.dvGuardBandBottom; These extents will all be set to 0 to indicate no guard band support

? ? ? ? ? ? ? Questions Sim Dietrich SDietrich@nvidia.com www.nvidia.com