OUTPUT VARIABLES (VERTEX SHADER)

Vertex position

highp vec4 gl_Position;

The built-in variable gl_Position is used by the vertex shader to hand over the transformed vertex position to the OpenGL ES 2.0 pipeline. The variable is declared as shown above and can be used in the vertex shader for an assignment without prior declaration.

The values of the position vector are interpreted in clip coordinate space. The vertex shader is responsible to execute all vertex manipulations, e.g. the transformation from object coordinates to clip coordinates.

The assignment of values to this variable is mandatory for the vertex shader.

Point size

mediump float gl_PointSize;

The built-in variable gl_PointSize is used by the vertex shader to hand over the point size of a vertex to the OpenGL ES 2.0 pipeline. The variable is declared as shown above and can be used in the vertex shader for an assignment without prior declaration.

The value of the the point size is interpreted as the radius in pixels of the point sprite. The actual drawing geometry is a quad (a rectangular primitive) that is derived from the position and the radius of the point sprite.

Side note: The value assigned to this variable is only taken into account by the OpenGL ES 2.0 pipeline if the rendered primitives are points.

INPUT VARIABLES (FRAGMENT SHADER)

Fragment coordinates

mediump vec4 gl_FragCoord;

The built-in variable gl_FragCoord is used by the OpenGL ES 2.0 pipeline to hand over the coordinates of the fragment to the fragment shader. The variable is read-only and the value is assigned by the OpenGL ES 2.0 pipeline.

The values of the fragment coordinate vector are given in the window coordinate system.

Fragment orientation

bool gl_FrontFacing;

The built-in variable gl_FrontFacing is used by the OpenGL ES 2.0 pipeline to hand over the information to the fragment shader if the fragment is part of a front-facing primitive (triangle). The variable is read-only and the value is assigned by the OpenGL ES 2.0 pipeline.

The front-facing variable has a boolean value.

Point coordinates

mediump vec2 gl_PointCoord;

The built-in variable gl_PointCoord  is used by the OpenGL ES 2.0 pipeline to hand over the coordinates of a point sprite to the fragment shader. The variable is read-only and the value is calculated and assigned by the OpenGL ES 2.0 pipeline based on the position and radius of the point sprite..

Side note: A value for this variable is provided by the OpenGL ES 2.0 pipeline only if the rendered primitives are points.

OUTPUT VARIABLES (FRAGMENT SHADER)

Fragment color

mediump vec4 gl_FragColor;

The built-in variable gl_FragColor is used by the fragment shader to hand over the color of the fragment to the OpenGL ES 2.0 pipeline. The variable is pre-declared as shown above that way the variable can be used in the fragment shader for an assignment without prior declaration.

The values of the color vector are interpreted in the RGBA color space.

The assignment of values to this variable is mandatory for the fragment shader.