Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics

  • Slides: 34
Download presentation
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Overview Geometry Shaders in the Pipeline Primitive Types Applications Performance

Overview Geometry Shaders in the Pipeline Primitive Types Applications Performance

Birds Eye View Create or destroy primitives on the GPU Requires – – Direct.

Birds Eye View Create or destroy primitives on the GPU Requires – – Direct. X 10 Open. GL 3. 2 or GL_ARB_geometry_shader 4 Geometry Shader

Geometry Shaders in the Pipeline

Geometry Shaders in the Pipeline

Geometry Shaders in the Pipeline

Geometry Shaders in the Pipeline

Primitive Types Geometry Shader Output primitives can be disconnected

Primitive Types Geometry Shader Output primitives can be disconnected

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

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

Primitive Types Input primitive type doesn’t have to equal output primitive type

Primitive Types Input primitive type doesn’t have to equal output primitive type

Applications – Wireframe How would you implement gl. Polygon. Mode?

Applications – Wireframe How would you implement gl. Polygon. Mode?

Applications – Wireframe How would you implement gl. Polygon. Mode? Triangles Points or Line

Applications – Wireframe How would you implement gl. Polygon. Mode? Triangles Points or Line Strips

Applications - Billboards How would you implement GL_ARB_point_sprite?

Applications - Billboards How would you implement GL_ARB_point_sprite?

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

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

Applications - Billboards Code: miniglobe. svn. sourceforge. net/viewvc/miniglobe/Source/Scene/Renderables/Billboard. Collection/

Applications - Billboards Code: miniglobe. svn. sourceforge. net/viewvc/miniglobe/Source/Scene/Renderables/Billboard. Collection/

Applications - Billboards Code: miniglobe. svn. sourceforge. net/viewvc/miniglobe/Source/Scene/Renderables/Billboard. Collection/

Applications - Billboards Code: miniglobe. svn. sourceforge. net/viewvc/miniglobe/Source/Scene/Renderables/Billboard. Collection/

Applications – Wide Lines gl. Line. Width width > 1 is deprecated in Open.

Applications – Wide Lines gl. Line. Width width > 1 is deprecated in Open. GL 3.

Applications – Wide Lines

Applications – Wide Lines

Applications – Wide Lines Two steps Clip to near plane. Why? Expand line to

Applications – Wide Lines 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/

Applications Displacement mapping Single pass cube map generation Terrain decompression Culling with instancing Extrusions

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

Applications: Fur in Lost Planet Render surface, write buffers for Fur Color Angle Length

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

Applications: Fur in Lost Planet color angle length Images from meshula. net/wordpress/? p=124

Applications: Fur in Lost Planet color angle length Images from meshula. net/wordpress/? p=124

Performance Duplicates per-vertex operations for vertices shared by primitives 5 vertices processed 9 vertices

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

Performance Must guarantee order in == order out

Performance Must guarantee order in == order out

Performance Order guarantee affects parallelism

Performance Order guarantee affects parallelism

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

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

Performance Maximum number of vertices a GS will output, e. g. : layout(triangle_strip, max_vertices

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

Performance Ge. Force 8, 9, and GTX 2 xx – Output size = vertex

Performance Ge. Force 8, 9, and GTX 2 xx – 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 Ge. Force 8800 GTX

Performance ATI for 1: 1 and 1: 4 amplification 1 High amplification can't use

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

Performance Benefits Reduces vertex buffer memory usage • Compute in GS, e. g. normals

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

Summary Geometry shaders are now widely used Modify incoming primitive or make a limited

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

Resources Section 4. 6 developer. nvidia. com/object/gpu_programming_guide. html

Resources Section 4. 6 developer. nvidia. com/object/gpu_programming_guide. html

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

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

Resources Introduction to Direct 3 D 10 SIGGRAPH 2007 Course Notes www. microsoft. com/downloads/details.

Resources Introduction to Direct 3 D 10 SIGGRAPH 2007 Course Notes www. microsoft. com/downloads/details. aspx? Family. Id=96 CD 28 D 5 -4 C 15 -475 E-A 2 DC-1 D 37 F 67 FA 6 CD&displaylang=en

Resources GL_ARB_geometry_shader 4 www. opengl. org/registry/specs/ARB/geometry_shader 4. txt

Resources GL_ARB_geometry_shader 4 www. opengl. org/registry/specs/ARB/geometry_shader 4. txt

Resources Section 3. 5 www. realtimerendering. com

Resources Section 3. 5 www. realtimerendering. com