GL_OES_tessellation_shader

Supported Hardware

Series6XT

Valid APIs

OpenGL ES 3.1

Description

This extension adds new tessellation stages to the OpenGL ES pipeline, and two new shader types - tessellation control and tessellation evaluation. When tessellation is active, a number of pipeline stages are affected. Tessellation operates after primitive assembly and before geometry shading (if supported).

Patch Primitives

Tessellation operates on a new primitive type - patches, which are a collection of vertices that are combined to form a patch. The actual number of vertices is application defined, allowing it to be fairly general-purpose.

Tessellation Control

The first step of tessellation is the control shader. This shader exists to allow further transformation of vertices and set the level of detail required by the fixed function tessellation stage. It may also add or subtract vertices from a patch before passing it on - though it cannot change the number of patches.

Fixed Function Tessellation

The fixed function stage turns patches into a number of primitives, which are then available to the tessellation evaluation shader. The algorithm is fairly flexible and has a number of determining factors depending on the control shader's outputs. Full details of this are available in the specification.

Note: This stage is also affected by the type of primitive specified in the tessellation evaluation shader.

Tessellation Evaluation

After the fixed function tessellation stage, this shader consumes those generated primitives, doing final evaluation of the vertices before passing them on to Geometry Shading. The values output by the fixed function tessellation are usually abstract and not suitable for rasterization directly, so are modified by this shader stage into a more final output, typically involving interpolation.

Registry Link

https://www.khronos.org/registry/gles/extensions/OES/OES_tessellation_shader.txt

Example

// Create a Tessellation Control Shader 
GLuint geometryShader = glCreateShader(GL_TESS_CONTROL_SHADER_OES); 
// Create a Tessellation Control Shader 
GLuint geometryShader = glCreateShader(GL_TESS_EVALUATION_SHADER_OES);

Example

// Tessellation control shader 
#extension GL_OES_tessellation_shader : require 
#extension GL_OES_shader_io_blocks : require 
layout(vertices = 3) out; 
void main(void) 
{ 
	gl_TessLevelOuter[0] = 2.0; 
	gl_TessLevelOuter[1] = 4.0; 
	gl_TessLevelOuter[2] = 6.0; 
	gl_TessLevelOuter[3] = 8.0; 
	gl_TessLevelInner[0] = 8.0; 
	gl_TessLevelInner[1] = 8.0; 
	gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position; 
} 
// Tessellation evaluation shader 
#extension GL_OES_tessellation_shader : require 
#extension GL_OES_shader_io_blocks : require 
layout(triangles, equal_spacing, ccw) in; 
vec3 interpolate(vec3 v0, vec3 v1, vec3 v2) 
{ 
    return (gl_TessCoord.x * v0) + (gl_TessCoord.y * v1) + (gl_TessCoord.z * v2); 
} 
void main(void) 
{ 
	gl_Position = interpolate(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_in[2].gl_Position); 
}