GLSL Core tutorial–primitive Assembly

Source: Internet
Author: User

Original: http://www.lighthouse3d.com/tutorials/glsl-core-tutorial/primitive-assembly/

The element assembly phase takes the data of the vertex shader as input, and how the vertices are combined is indicated by the application calling the OpenGL function gldraw* (the orange part of the figure).

The connection of vertices illustrates how vertices are combined into entities. The elements can be dots, lines, triangles, or patches. In addition, the adjoining information can be provided. For example, the application also provides vertex data that generates adjacency elements. This data is only used in the geometry shader, how to not activate the geometry shader, then this information will be ignored.

The entity assembly outputs some primitives or patches. For example, if you enter a sequence of six vertices, and the connection information indicates that the vertices are joined to a triangle, 2 triangles are generated. For a triangle, it connects 6 vertices, generating 4 triangles that are joined together.

In opengl4+, patches is the input primitive type of the subdivision control shader. Patch is not the same as in the above, its vertex count is indeterminate, and the number of vertices of a patch can be from 1 to an implementation-dependent constant: Gl_max_patch_ VERTICES.

In graphics, it is generally assumed that the generated primitive type instance is a triangle, which can be described in the following steps:

The following table shows the possible set of vertex composition information and the resulting results, and the corresponding shader for using them:

Here are some examples of generating points, lines, and triangles. For an example of an entity with adjacency information, a solid line represents the primary entity (the generated entity), and the dashed lines connect to the adjacent vertices. It is important to note that in the graphical (connected) order, the entity is a counterclockwise order (CCW) connection.

The geometry interpolation of patches is not linear, so it is not shown here. For more information about patches, see the section shader segment.

GLSL Core tutorial–primitive Assembly

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.