Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Similar presentations


Presentation on theme: "Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc."— Presentation transcript:

1 Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

2 Overview Geometry Shaders in the Pipeline Primitive Types Applications Performance

3 Birds Eye View Create or destroy primitives on the GPU Requires – DirectX 10 – OpenGL 3.2 or GL_ARB_geometry_shader4 Geometry Shader

4 Geometry Shaders in the Pipeline Vertex Shader Fragment Shader Vertices in world coordinates Vertex Shader Fragment Shader Vertices in world coordinates Perspective Divide and Viewport Transformation clip coordinateswindow coordinates

5 Geometry Shaders in the Pipeline Geometry Shader Vertex Shader Fragment Shader Primitive Assembly PD and VT Geometry Shader Vertex Shader Fragment Shader Primitive Assembly Clipping PD and VT Geometry Shader Vertex Shader Fragment Shader PD and VT clip coordinates window coordinates

6 Primitive Types Geometry Shader Output primitives can be disconnected

7 Primitive Types Input Primitives GL_POINTS GL_LINES GL_TRIANGLES Adjacency Output Primitives GL_POINTS GL_LINE_STRIP GL_TRIANGLE_STRIP

8 Primitive Types Input primitive type doesn’t have to equal output primitive type blogs.agi.com/insight3d/index.php/2008/10/23/geometry-shader-for-debugging-normals/

9 Applications – Wireframe How would you implement glPolygonMode?

10 Applications – Wireframe How would you implement glPolygonMode? Triangles Points or Line Strips

11 Applications - Billboards How would you implement GL_ARB_point_sprite?

12 Applications - Billboards How would you implement GL_ARB_point_sprite? Points Triangle Strips

13 Applications - Billboards Code: miniglobe.svn.sourceforge.net/viewvc/miniglobe/Source/Scene/Renderables/BillboardCollection/

14 Applications - Billboards Code: miniglobe.svn.sourceforge.net/viewvc/miniglobe/Source/Scene/Renderables/BillboardCollection/

15 Applications – Wide Lines glLineWidth with width > 1 is deprecated in OpenGL 3.

16 Applications – Wide Lines

17 Two steps Clip to near plane. Why? Expand line to two triangles along screen space normal How would you outline? Code: miniglobe.svn.sourceforge.net/viewvc/miniglobe/Source/Scene/Renderables/Polyline/

18 Applications Displacement mapping Single pass cube map generation Terrain decompression Culling with instancing Extrusions Shadow volumes Fins along silhouettes for fur rendering

19 Applications: Fur in Lost Planet Render surface, write buffers for Fur Color Angle Length GS turns each pixel into a translucent polyline Automatic LOD

20 Images from meshula.net/wordpress/?p=124 coloranglelength Applications: Fur in Lost Planet

21 Performance Duplicates per-vertex operations for vertices shared by primitives Geometry Shader Vertex Shader 5 vertices processed9 vertices processed

22 Performance Geometry Shader Geometry Shader Geometry Shader Geometry Shader Must guarantee order in == order out

23 Performance Order guarantee affects parallelism Geometry Shader Geometry Shader Geometry Shader Reorder Buffer Clipping

24 Performance Buffer size needs to support a number of threads running in parallel

25 Performance Maximum number of vertices a GS will output, e.g.: layout(triangle_strip, max_vertices = 4) out; NVIDIA: Minimize this, it determines the speed of GS execution Minimize vertex size – GS Input: Pack in VS – GS Output: Compute in FS

26 Performance GeForce 8, 9, and GTX2xx – Output size = vertex size * max_vertices Maximum output size: 1,024 scalars Performance is inversely proportional to output size Not a continuous function: 1-20 scalars: Peak Performance 27-40 scalars: 50% Performance On GeForce 8800 GTX

27 Performance 1 The geometry shader must meet criteria in ATI Programming Guide ATI Optimized for 1:1 and 1:4 amplification 1 High amplification can't use on-chip buffers – memory bandwidth problem

28 Performance Benefits Reduces vertex buffer memory usage Compute in GS, e.g. normals Create more geometry No need to duplicate (e.g. compared to equivalent VS implementation) Less memory == less bus traffic Reduces vertex attribute setup cost

29 Summary Geometry shaders are now widely used Modify incoming primitive or make a limited number of copies Not for Large scale amplification Instancing

30 Resources developer.nvidia.com/object/gpu_programming_guide.html Section 4.6

31 Resources developer.amd.com/media/gpu_assets/ATI_Radeon_HD_2000_programming_guide.pdf

32 Resources www.microsoft.com/downloads/details.aspx?FamilyId=96CD28D5-4C15-475E-A2DC-1D37F67FA6CD&displaylang=en Introduction to Direct3D 10 SIGGRAPH 2007 Course Notes

33 Resources www.opengl.org/registry/specs/ARB/geometry_shader4.txt GL_ARB_geometry_shader4

34 Resources www.realtimerendering.com Section 3.5


Download ppt "Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc."

Similar presentations


Ads by Google