How it works...

The vertex shader passes the position along to the TCS unchanged.

The TCS defines the number of vertices in the patch using the layout directive:

layout (vertices=4) out; 

In the main function, it passes along the position of the vertex without modification, and sets the inner and outer tessellation levels. All four of the outer tessellation levels are set to the value of Outer, and both of the inner tessellation levels are set to Inner.

In the tessellation evaluation shader, we define the tessellation mode and other tessellation parameters with the input layout directive:

layout ( quads, equal_spacing, ccw ) in; 

The quads parameter indicates that the tessellation-primitive generator should tessellate the parameter space using quad tessellation. The equal_spacing parameter says that the tessellation should be performed such that all subdivisions have equal length. The last parameter, ccw, indicates that the primitives should be generated with counterclockwise winding.

The main function in the TES starts by retrieving the parametric coordinates for this vertex by accessing the gl_TessCoord variable. Then we move on to read the positions of the four vertices in the patch from the gl_in array. We store them in temporary variables to be used in the interpolation calculation.

The built-in gl_Position output variable then gets the value of the interpolated point using the preceding equation. Finally, we convert the position into clip coordinates by multiplying by the model-view projection matrix.

Within the fragment shader, we give all fragments a color that is possibly mixed with a line color in order to highlight the edges.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.162.247