Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics

  • Slides: 24
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. X

Birds Eye View Create or destroy primitives on the GPU ¢ Requires Direct. X 10 or GL_ARB_geometry_shader 4 ¢ Geometry Shader

Geometry Shaders in the Pipeline Vertices in world coordinates Vertex Shader Perspective Divide Fragment

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

Geometry Shaders in the Pipeline window coordinates clip coordinates Vertex Shader clip coordinates Primitive

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

Primitive Types Geometry Shader Output primitives can be disconnected

Primitive Types Geometry Shader Output primitives can be disconnected

Primitive Types ¢ Input Primitives l l GL_POINTS GL_LINES GL_TRIANGLES Adjacency ¢ Output Primitives

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

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

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

Applications ¢ Implement gl. Polygon. Mode l ¢ Triangles Points or Line Strips Emulate

Applications ¢ Implement gl. Polygon. Mode l ¢ Triangles Points or Line Strips Emulate GL_ARB_point_sprite l Points Triangle Strips

Applications Displacement Mapping ¢ Single pass generate a cube map ¢ Extrusions ¢ Shadow

Applications Displacement Mapping ¢ Single pass generate a cube map ¢ Extrusions ¢ Shadow volumes l Fins along silhouettes for fur rendering l

Applications: Fur in Lost Planet ¢ Render surface, write buffers for Fur Color l

Applications: Fur in Lost Planet ¢ Render surface, write buffers for Fur Color l Angle l Length l ¢ GS turns each pixel into a translucent polyline l 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

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 Geometry Shader

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

Performance ¢ Order guarantee affects parallelism Geometry Shader Reorder Buffer Clipping

Performance ¢ Order guarantee affects parallelism Geometry Shader Reorder Buffer Clipping

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: GEOMETRY_VERTICES_OUT_ARB Determines the speed

Performance ¢ Maximum number of vertices a GS will output: GEOMETRY_VERTICES_OUT_ARB Determines the speed of GS execution ¢ Make this and vertex sizes as small as possible ¢

Performance ¢ Ge. Force 8, 9, and GTX 2 xx l Output size =

Performance ¢ Ge. Force 8, 9, and GTX 2 xx l Output size = vertex size * GEOMETRY_VERTICES_OUT_ARB Maximum output size: 1, 024 scalars l Performance is inversely proportional to output size l Not a continuous function: l • 1 -20 scalars: Peak Performance • 27 -40 scalars: 50% Performance • On Ge. Force 8800 GTX

Performance ¢ Benefits l Reduces vertex buffer memory usage • Compute in GS, e.

Performance ¢ Benefits l 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 l Reduces vertex attribute setup cost l

Summary Modify incoming primitive or make a limited number of copies ¢ Not for

Summary Modify incoming primitive or make a limited number of copies ¢ Not for ¢ Large scale amplification l Instancing l

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

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

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