OpenGL ES Shading Language
OpenGL ES Shading Language | |
---|---|
Publishing year: | 2009 |
Developer: | Khronos Group |
Current version : | 3.20 (August 6, 2015) |
Influenced by: | OpenGL Shading Language and C |
www.khronos.org/opengles/ |
The OpenGL ES Shading Language (short: GLSL ES ) is a programming language with which the programmable units of a graphics processor , so-called shaders , are created. These shaders are compiled, linked to one another to form a finished program and executed on embedded systems using OpenGL ES .
Language features
GLSL ES is based on the OpenGL Shading Language (GLSL) and as such is also a C -like programming language. In contrast to GLSL, the current version of GLSL ES has fewer texture data types (samplers) and offers significantly fewer built-in variables and functions. In addition, the precision qualifier can be used to determine the minimum range and accuracy of a floating point or integer data type.
example
An example of a simple GLSL-ES program consisting of a vertex and a fragment shader; the program draws objects in a previously defined color:
Vertex shader
This vertex shader positions the vertex ( a_vertex
) modelViewProjectionMatrix
relative to the camera in space with the help of the matrix , and transfers the color (a_color) passed by the OpenGL ES API to the fragment shader.
uniform mat4 modelViewProjectionMatrix;
attribute vec4 a_vertex;
attribute vec4 a_color;
varying vec4 v_color;
void main()
{
v_color = a_color;
gl_Position = modelViewProjectionMatrix * a_vertex;
}
The same example in version 3.00:
#version 300 es
uniform mat4 modelViewProjectionMatrix;
layout (location = 0) in vec4 a_vertex;
layout (location = 1) in vec4 a_color;
out vec4 v_color;
void main()
{
v_color = a_color;
gl_Position = modelViewProjectionMatrix * a_vertex;
}
Fragment shader
This fragment shader sets the drawing color of the fragment to the color passed by the vertex shader.
precision mediump float;
varying vec4 v_color;
void main()
{
gl_FragColor = v_color;
}
Same example in version 3.00
#version 300 es
precision mediump float;
in vec4 v_color;
out vec4 my_fragcolor;
void main()
{
my_fragcolor = v_color;
}
history
Legend: | Old version | Current version |
---|
version | publication | Description / changes |
---|---|---|
1.00 | May 12, 2009 |
|
3.00 | July 11, 2012 |
|
3.10 | 17th March 2014 |
|
3.20 | August 6, 2015 |
|
Web links
- GLSL-ES Specification Version 1.00 (May 12, 2009). (PDF; 619 kB)
- GLSL-ES Specification Version 3.00 (March 6, 2013). (PDF; 750 kB)
- GLSL-ES Specification Version 3.10 (March 17, 2014). (PDF; 891 kB)
- GLSL-ES Specification Version 3.20 (August 6, 2015). (PDF; 1.16 MB)