Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

24
Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    240
  • download

    0

Transcript of Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

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

Introduction to Geometry Shaders

Patrick Cozzi

Analytical Graphics, Inc.

Page 2: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Overview

Geometry Shaders in the Pipeline Primitive Types Applications Performance

Page 3: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Birds Eye View

Create or destroy primitives on the GPU Requires DirectX 10 or GL_ARB_geometry_shader4

GeometryShader

Page 4: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Geometry Shaders in the Pipeline

VertexShader

FragmentShader

Vertices in world coordinates

VertexShader

FragmentShader

Vertices in world coordinates

Perspective Divide and

Viewport Transformation

clip coordinates window coordinates

Page 5: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Geometry Shaders in the Pipeline

GeometryShader

VertexShader

FragmentShader

PrimitiveAssembly

PDand

VT

GeometryShader

VertexShader

FragmentShader

PrimitiveAssembly

ClippingPDand

VT

GeometryShader

VertexShader

FragmentShader

PDand

VT

clip coordinates clip coordinates

window coordinates

Page 6: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Primitive Types

GeometryShader

Output primitives can be disconnected

Page 7: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Primitive Types

Input Primitives GL_POINTS GL_LINES GL_TRIANGLES Adjacency

Output Primitives GL_POINTS GL_LINE_STRIP GL_TRIANGLE_STRIP

Page 8: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

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/

Page 9: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Applications

Implement glPolygonModeTriangles Points or Line Strips

Emulate GL_ARB_point_spritePoints Triangle Strips

Page 10: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Applications

Displacement Mapping Single pass generate a cube map Extrusions

Shadow volumesFins along silhouettes for fur rendering

Page 11: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Applications: Fur in Lost Planet

Render surface, write buffers forFur ColorAngleLength

GS turns each pixel into a translucent polylineAutomatic LOD

Page 12: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Images from meshula.net/wordpress/?p=124

color angle length

Applications: Fur in Lost Planet

Page 13: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Performance

Duplicates per-vertex operations for vertices shared by primitives

GeometryShader

VertexShader

5 vertices processed 9 vertices processed

Page 14: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Performance

GeometryShader

GeometryShader

GeometryShader

GeometryShader

Must guarantee order in == order out

Page 15: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Performance

Order guarantee affects parallelism

GeometryShader

GeometryShader

GeometryShader

Reorder Buffer

Clipping

Page 16: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Performance

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

Page 17: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

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

Page 18: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Performance

GeForce 8, 9, and GTX2xxOutput size = vertex size *

GEOMETRY_VERTICES_OUT_ARB

Maximum output size: 1,024 scalarsPerformance is inversely proportional

to output sizeNot a continuous function:

• 1-20 scalars: Peak Performance• 27-40 scalars: 50% Performance• On GeForce 8800 GTX

Page 19: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Performance

BenefitsReduces 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 trafficReduces vertex attribute setup cost

Page 20: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Summary

Modify incoming primitive or make a limited number of copies

Not for Large scale amplificationInstancing

Page 21: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Resources

www.microsoft.com/downloads/details.aspx?FamilyId=96CD28D5-4C15-475E-A2DC-1D37F67FA6CD&displaylang=en

Introduction to Direct3D 10SIGGRAPH 2007 Course Notes

Page 22: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Resources

www.opengl.org/registry/specs/ARB/geometry_shader4.txt

GL_ARB_geometry_shader4

Page 23: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Resources

www.realtimerendering.com

Section 3.5

Page 24: Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.

Resources

developer.nvidia.com/object/gpu_programming_guide.html

Section 4.6