1 / 18

Guard Band Clipping

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.

tulia
Download Presentation

Guard Band Clipping

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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

  3. 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].

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

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

  6. 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

  7. 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

  8. 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

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

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

More Related