![]() GLSL gives us a built-in variable called gl_in that internally (probably) looks something like this: To generate meaningful results we need some way to retrieve the output from the previous shader stage. Each extra point results in a new line between the new point and the previous point as you can see in the following image with 5 point vertices: In case you're wondering what a line strip is: a line strip binds together a set of points to form one continuous line between them with a minimum of 2 points. In this particular case we're going to output a line_strip with a maximum number of 2 vertices. The geometry shader also expects us to set a maximum number of vertices it outputs (if you exceed this number, OpenGL won't draw the extra vertices) which we can also do within the layout qualifier of the out keyword. To generate a single triangle for example we'd specify triangle_strip as the output and output 3 vertices. With just these 3 output specifiers we can create almost any shape we want from the input primitives. Like the input layout qualifier, the output layout qualifier can take several primitive values: We also need to specify a primitive type that the geometry shader will output and we do this via a layout specifier in front of the out keyword. The number within the parenthesis represents the minimal number of vertices a single primitive contains. If we'd chosen to draw vertices as GL_TRIANGLES we should set the input qualifier to triangles. These are almost all the rendering primitives we're able to give to rendering calls like glDrawArrays.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |