Contains the selected layer of a multi-layer framebuffer attachment.
In the geometry language,gl_Layeris used to select a specific layer (or face and layer of cube map) in a multi-layer framebuffer attachment. The actual layer used will come from one of the vertices in the primitive being shaded. Which vertex the layer comes from is undefined and as such it is recommended to write the same value togl_Layerfor all vertices in the primitive. If a shader statically assigns a value togl_Layer, layered rendering mode is enabled. If a shader statically assigns a value togl_Layer, and there is an execution path through the shader that does not setgl_Layer, then the value ofgl_Layeris undefined for invocations of the shader that take that path.
When used with an array of cube map textures, thegl_Layeroutput 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. Settinggl_Layerto the value [math][/math] will render to [math][/math] of the cube defined in [math][/math] . The face values are as follows:
|Face Value||Resulting Target|
For example, to render to the positive y cube map face located in the 5thlayer of the cube map array,gl_Layershould be set to [math][/math] .
The input variablegl_Layerin the fragment language will have the same value that was written to the output variablegl_Layerin the geometry language. If the geometry stage does not dynamically assign a value togl_Layer, the value ofgl_Layerin the fragment stage will be undefined. If the geometry stage makes no static assignment togl_Layer, the inputgl_Layerin 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 togl_Layer, it will count against the implementation defined limit for the maximum number of inputs to the fragment stage.
|gl_Layer (geometry stage)||1.5+|
|gl_Layer (fragment stage)||4.3+|
Copyright© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.