// Geometry stage
out int gl_Layer ;
// Fragment stage
in int gl_Layer ;
When used with an array of cube map textures, the gl_Layer output variable takes on a special value. Instead of referring to only the layer, it is used to select a cube map face and a layer. Setting gl_Layer to the value layer*6+face will render to face of the cube defined in layer. The face values are as follows:
|Face Value||Resulting Target|
For example, to render to the positive y cube map face located in the 5th layer of the cube map array, gl_Layer should be set to 5*6+2.
The input variable gl_Layer in the fragment language will have the same value that was written to the output variable gl_Layer in the geometry language. If the geometry stage does not dynamically assign a value to gl_Layer, the value of gl_Layer in the fragment stage will be undefined. If the geometry stage makes no static assignment to gl_Layer, the input gl_Layer in the fragment stage will be zero. Otherwise, the fragment stage will read the same value written by the geometry stage, even if that value is out of range. If a fragment shader contains a static access to gl_Layer, it will count against the implementation defined limit for the maximum number of inputs to the fragment stage.
|OpenGL Shading Language Version|
|gl_Layer (geometry stage)||-||-||-||-||✔||✔||✔||✔||✔||✔||✔||✔|
|gl_Layer (fragment stage)||-||-||-||-||-||-||-||-||-||✔||✔||✔|