GLSL 高级教程 – Primitive Assembly

The primitive assembly stage receives as input the processed vertices from the vertex shader, and the vertex connectivity information from the application as specified by in the <code>glDraw*</code> family of OpenGL commands.

The vertex connectivity states how the vertices are connected to create a primitive. Primitives can be points, lines, triangles, or patches. Furthermore, adjacency information can also be made available, i.e. the application may also provide the vertices that make up the adjacent primitives. This information is of use only  for the geometry shader, and, if not such shader is active, the adjacency information will be ignored.

As output the primitive assembly produces primitives or patches. For instance, if the input is a sequence of six vertices, and the connectivity information specifies that we are using triangles, the output will be two triangles. For triangle strips, and considering also six vertices, the output will be four triangles.

Patches are the primitive types accepted by the tessellation control shader, available in OpenGL 4+. The number of vertices of  patch is not fixed as in the primitives case, and it can vary between 1 and an implementation dependent constant,GL_MAX_PATCH_VERTICES, vertices per patch.

Graphically, assuming for instance that the primitive type is GL_TRIANGLES, this can be depicted as follows:

The following table shows the possible input connectivity information settings, and the outputs produced, as well as the shaders that use them.

glDraw commandoutput primtiveused in shaders
GL_POINTSpointsgeometry; fragment
GL_LINESlinesgeometry; fragment
GL_LINE_STRIPlinesgeometry; fragment
GL_LINE_LOOPlinesgeometry; fragment
GL_LINES_ADJACENCYlines_adjacencygeometry
GL_LINE_STRIP_ADJACENCYlines_adjacencygeometry
GL_TRIANGLEStrianglesgeometry; fragment
GL_TRIANGLE_STRIPtrianglesgeometry; fragment
GL_TRIANGLE_FANtrianglesgeometry; fragment
GL_TRIANGLES_ADJACENCYtriangles_adjacencygeometry
GL_TRIANGLE_STRIP_ADJACENCYtriangles_adjacencygeometry
GL_PATCHESpatchestessellation control

 

Bellow are examples of what can be obtained with points, lines, and triangles. Regarding primitives with adjacency information, the full lines indicate the main primitive, and the dashed lines connect the adjacent vertices. Note the ordering in the graphics, all primitives are ordered counter clock wise.


The geometrical interpretation of a patch is not as linear, so it is not represented in here. See the section on tessellation for more info on patches.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值