Download presentation
Presentation is loading. Please wait.
Published byAbraham Kennedy Modified over 8 years ago
1
By Joey Green
2
What is a geometry shader? Demo Go over code More geometry shader info Transform Feedback Render To Cube Map Final Project
3
One primitive at a time Manipulate, Remove, or Create Primitives Discards original primitive Result is new set of transformed vertices Clip coordinates Does not replace vertex shader Input and output primitive types don’t have to match August 3, 2009: OpenGL 3.2 as core functionality
5
Glchar GeometryShaderSource; //load shader source Glint objectGS; objectGS = glCreateShader(GL_GEOMETRY_SHADER); glShaderSource(objectGS, 1, &GeometryShaderSource, NULL); glCompileShader(objectGS); myShaderProgam = glCreateProgram() glAttachShader(myShaderProgram, objectGS); glAttachShader(myShaderProgram, objectVS); glAttachShader(myShaderProgram, objectFS); glUseProgram(myShaderProgram);
6
Demo
7
Vertex Shader
10
Geometry Shader
20
Fragment Shader
21
Primitive type must match primitive mode Input Types: points lines lines_adjacency triangles triangles_adjacency Draw Modes: points lines lines_strip line_loop lines_adjacency lines_strip_adjacency triangles triangle_strip triangle_fan triangles_adjacency Triangle_strip_adjacency
22
One to six input vertices per input primitive [2]
23
gl_PrimitiveIDIn number of primitives processed so far set in primitive assembly stage gl_in[] gl_Position – position from vertex shader, transformed? gl_PointSize – size in pixels gl_ClipDistance[] – user defined clip distance
24
Right after Geometry or Vertex Shader Move vertex attributes to transform feedback buffer Decide to reprocess or send on for rendering Calculations per vertex per frame can stay on GPU
26
Cube Map Texture Reflections Texture with six sections for each face Without Geometry Shader for (face = 0; face < 6; face++) { //change section to render to //change the look at direction drawSpheres(); } With Geometry Shader gl_Layer Render primitives to the different layers gl_Layer specifies layer to render to One pass
27
Without GS( Spines )With GS Extend a quad along an edge that is shared by a front and back facing triangle. Draw front faces Draw back faces in line mode Spines along the end of an edge
28
Required Shaders Cube Map Geometry Shader Real-Time Glow Shader Desired Scene Rendered from height map [5] [6]
29
[1] K. Akeley and M. Segal, “The OpenGL Graphics System: A Specification( Version 4.0 ( Core Profile ) – March 11, 2010), “ The Khronos Group Inc., Mar. 2010 pp. 114 - 122 [2] P. Rideout, “Silhouette Extraction,” The Little Grasshopper, http://prideout.net/blog/?p=54 ( current 24 Oct. 2010 ) http://prideout.net/blog/?p=54 [3] M. Costa, “Chapter 11 – Advanced Shader Usage – Geometry Shaders,” Rendering Wonders, http://renderingwonders.wordpress.com/tag/geometry-shader/ ( current 7 Feb. 2011 )http://renderingwonders.wordpress.com/tag/geometry-shader/ [4] B. Dole, “Tutorial 28 – Particle System using Transform Feedback,” OpenGL Step By Step, http://ogldev.atspace.co.uk/www/tutorial28/tutorial28.html( current 8 August 2011 ) http://ogldev.atspace.co.uk/www/tutorial28/tutorial28.html [5] J. Tsiombika, “Cube Map Test,” Nuclear’s Junkyard http://nuclear.dnsalias.com/shots/henge/http://nuclear.dnsalias.com/shots/henge/ ( current 20 March 2009 ) [6] J. O’Rorke, “Chapter 21. Real-Time Glow,” Nvidia Developer Zone, http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html ( current September 2007 ) http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html [7] P. Rideout, “Noise Based Particles, Part II,” The Little Grasshopper, http://prideout.net/blog/?tag=transform-feedback ( current 29 Jan. 2011 ) http://prideout.net/blog/?tag=transform-feedback
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.