Introduction To Geometry Shaders

10,521 views

Published on

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
10,521
On SlideShare
0
From Embeds
0
Number of Embeds
657
Actions
Shares
0
Downloads
198
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide
  • Since late 2006 Direct3D can destroy primitives. OpenGL might require at least 1 primitive to be output.
  • Color clamping and flat shading actually happen right before clipping
  • Must output at least 1 primitive Input primitive is discarded
  • Introduction To Geometry Shaders

    1. 1. Introduction to Geometry Shaders Patrick Cozzi Analytical Graphics, Inc.
    2. 2. Overview <ul><li>Geometry Shaders in the Pipeline </li></ul><ul><li>Primitive Types </li></ul><ul><li>Applications </li></ul><ul><li>Performance </li></ul>
    3. 3. Birds Eye View <ul><li>Create or destroy primitives on the GPU </li></ul><ul><li>Requires DirectX 10 or GL_ARB_geometry_shader4 </li></ul>Geometry Shader
    4. 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 coordinates window coordinates
    5. 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 clip coordinates window coordinates
    6. 6. Primitive Types Geometry Shader Output primitives can be disconnected
    7. 7. Primitive Types <ul><li>Input Primitives </li></ul><ul><ul><li>GL_POINTS </li></ul></ul><ul><ul><li>GL_LINES </li></ul></ul><ul><ul><li>GL_TRIANGLES </li></ul></ul><ul><ul><li>Adjacency </li></ul></ul><ul><li>Output Primitives </li></ul><ul><ul><li>GL_POINTS </li></ul></ul><ul><ul><li>GL_LINE_STRIP </li></ul></ul><ul><ul><li>GL_TRIANGLE_STRIP </li></ul></ul>
    8. 8. Primitive Types <ul><li>Input primitive type doesn’t have to equal output primitive type </li></ul>blogs.agi.com/insight3d/index.php/2008/10/23/geometry-shader-for-debugging-normals/
    9. 9. Applications <ul><li>Implement glPolygonMode </li></ul><ul><ul><li>Triangles Points or Line Strips </li></ul></ul><ul><li>Emulate GL_ARB_point_sprite </li></ul><ul><ul><li>Points Triangle Strips </li></ul></ul>
    10. 10. Applications <ul><li>Displacement Mapping </li></ul><ul><li>Single pass cube map generation </li></ul><ul><li>Extrusions </li></ul><ul><ul><li>Shadow volumes </li></ul></ul><ul><ul><li>Fins along silhouettes for fur rendering </li></ul></ul>
    11. 11. Applications: Fur in Lost Planet <ul><li>Render surface, write buffers for </li></ul><ul><ul><li>Fur Color </li></ul></ul><ul><ul><li>Angle </li></ul></ul><ul><ul><li>Length </li></ul></ul><ul><li>GS turns each pixel into a translucent polyline </li></ul><ul><ul><li>Automatic LOD </li></ul></ul>
    12. 12. Applications: Fur in Lost Planet Images from meshula.net/wordpress/?p=124 color angle length
    13. 13. Performance <ul><li>Duplicates per-vertex operations for vertices shared by primitives </li></ul>Geometry Shader Vertex Shader 5 vertices processed 9 vertices processed
    14. 14. Performance <ul><li>Must guarantee order in == order out </li></ul>Geometry Shader Geometry Shader Geometry Shader Geometry Shader
    15. 15. Performance <ul><li>Order guarantee affects parallelism </li></ul>Geometry Shader Geometry Shader Geometry Shader Reorder Buffer Clipping
    16. 16. Performance <ul><li>Buffer size needs to support a number of threads running in parallel </li></ul>
    17. 17. Performance <ul><li>Maximum number of vertices a GS will output: </li></ul><ul><ul><ul><li>GEOMETRY_VERTICES_OUT_ARB </li></ul></ul></ul><ul><li>Determines the speed of GS execution </li></ul><ul><li>Make this and vertex sizes as small as possible </li></ul>
    18. 18. Performance <ul><li>GeForce 8, 9, and GTX2xx </li></ul><ul><ul><li>Output size = vertex size * GEOMETRY_VERTICES_OUT_ARB </li></ul></ul><ul><ul><li>Maximum output size: 1,024 scalars </li></ul></ul><ul><ul><li>Performance is inversely proportional to output size </li></ul></ul><ul><ul><li>Not a continuous function: </li></ul></ul><ul><ul><ul><li>1-20 scalars: Peak Performance </li></ul></ul></ul><ul><ul><ul><li>27-40 scalars: 50% Performance </li></ul></ul></ul><ul><ul><ul><li>On GeForce 8800 GTX </li></ul></ul></ul>
    19. 19. Performance <ul><li>Benefits </li></ul><ul><ul><li>Reduces vertex buffer memory usage </li></ul></ul><ul><ul><ul><li>Compute in GS, e.g. normals </li></ul></ul></ul><ul><ul><ul><li>Create more geometry </li></ul></ul></ul><ul><ul><ul><li>No need to duplicate (e.g. compared to equivalent VS implementation) </li></ul></ul></ul><ul><ul><li>Less memory == less bus traffic </li></ul></ul><ul><ul><li>Reduces vertex attribute setup cost </li></ul></ul>
    20. 20. Summary <ul><li>Modify incoming primitive or make a limited number of copies </li></ul><ul><li>Not for </li></ul><ul><ul><li>Large scale amplification </li></ul></ul><ul><ul><li>Instancing </li></ul></ul>
    21. 21. Resources <ul><li>www.microsoft.com/downloads/details.aspx?FamilyId=96CD28D5-4C15-475E-A2DC-1D37F67FA6CD&displaylang=en </li></ul>Introduction to Direct3D 10 SIGGRAPH 2007 Course Notes
    22. 22. Resources <ul><li>www.opengl.org/registry/specs/ARB/geometry_shader4.txt </li></ul>GL_ARB_geometry_shader4
    23. 23. Resources <ul><li>www.realtimerendering.com </li></ul>Section 3.5
    24. 24. Resources <ul><li>developer.nvidia.com/object/gpu_programming_guide.html </li></ul>Section 4.6

    ×