Before the tessellation engine receives a patch, the tessellation control shader processes the incoming control points and sets tessellation factors that are used to break down the patch. The tessellation engine is a fixed-function part of the OpenGL pipeline that takes high-order surfaces represented as patches and breaks them down into simpler primitives such as points, lines, or triangles. Everybody copies their input to their output Listing 3.7: Our first tessellation control shader #version 450 core This variable contains the zero-based index of the control point within the patch being processed by the current invocation of the tessellation control shader. The built-in input variable gl_InvocationID is used as an index into the gl_in and gl_out arrays. Setting the tessellation factor to 0 will cause the whole patch to be thrown away. Higher numbers would produce a more densely tessellated output, and lower numbers would yield a more coarsely tessellated output. It sets the number of output control points to three (the same as the default number of input control points) using the layout (vertices = 3) out layout qualifier, copies its input to its output (using the built-in variables gl_in and gl_out), and sets the inner and outer tessellation level to 5. Listing 3.7 shows a simple tessellation control shader. The output tessellation factors are written to the gl_TessLevelInner and gl_TessLevelOuter built-in output variables, whereas any other data that is passed down the pipeline is written to user-defined output variables (those declared using the out keyword, or the special built-in gl_out array) as normal. The control shader is responsible for calculating the values of the output control points and for setting the tessellation factors for the resulting patch that will be sent to the fixed-function tessellation engine. Here, N is the number of control points per patch. Such a layout qualifier looks like this: layout (vertices = N) out The number of control points produced by the control shader is set using an output layout qualifier in the control shader’s source code. The number of control points per patch can be changed such that the number of control points that is output by the tessellation control shader can differ from the number of control points that it consumes. That is, vertices are used as control points and the result of the vertex shader is passed in batches to the tessellation control shader as its input. When tessellation is active, the vertex shader runs once per control point, while the tessellation control shader runs in batches on groups of control points where the size of each batch is the same as the number of vertices per patch. The maximum number of control points that can be used to form a single patch is implementation defined, but is guaranteed to be at least 32. Thus, if this is what you want (as in our example application), you don’t need to call it at all. The prototype of glPatchParameteri() is void glPatchParameteri(GLenum pname,īy default, the number of control points per patch is three. The number of control points per patch is configurable and set by calling glPatchParameteri() with pname set to GL_PATCH_VERTICES and value set to the number of control points that will be used to construct each patch. Each patch is formed from a number of control points. Tessellation in OpenGL works by breaking down high-order surfaces known as patches into points, lines, or triangles. This shader takes its input from the vertex shader and is primarily responsible for two things: the determination of the level of tessellation that will be sent to the tessellation engine, and the generation of data that will be sent to the tessellation evaluation shader that is run after tessellation has occurred. The first of the three tessellation phases is the tessellation control shader (TCS sometimes known as simply the control shader). Logically, the tessellation phase sits directly after the vertex shading stage in the OpenGL pipeline and is made up of three parts: the tessellation control shader, the fixed-function tessellation engine, and the tessellation evaluation shader. OpenGL includes a fixed-function, configurable tessellation engine that is able to break up quadrilaterals, triangles, and lines into a potentially large number of smaller points, lines, or triangles that can be directly consumed by the normal rasterization hardware further down the pipeline. Tessellation is the process of breaking a high-order primitive (which is known as a patch in OpenGL) into many smaller, simpler primitives such as triangles for rendering. OpenGL Superbible: Comprehensive Tutorial and Reference, 7th Edition
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |