include more low-level bindings
[clinton/guile-figl.git] / upstream-man-pages / manglsl / gl_Layer.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id="gl_Layer">
5 <refmeta>
6 <refmetainfo>
7 <copyright>
8 <year>2012</year>
9 <holder>Khronos Group</holder>
10 </copyright>
11 </refmetainfo>
12 <refentrytitle>gl_Layer</refentrytitle>
13 <manvolnum>3G</manvolnum>
14 </refmeta>
15 <refnamediv>
16 <refname>gl_Layer</refname>
17 <refpurpose>contains the selected layer of a multi-layer framebuffer attachment</refpurpose>
18 </refnamediv>
19 <refsynopsisdiv><title>Declaration</title>
20 <funcsynopsis>
21 <function>out int gl_Layer; // Geometry stage</function>
22 </funcsynopsis>
23 <funcsynopsis>
24 <function>in int gl_Layer; // Fragment stage</function>
25 </funcsynopsis>
26 </refsynopsisdiv>
27 <refsect1 id="description"><title>Description</title>
28 <para>
29 In the geometry language, <function>gl_Layer</function> is used to select a specific
30 layer (or face and layer of cube map) in a multi-layer framebuffer attachment. The actual
31 layer used will come from one of the vertices in the primitive being shaded. Which vertex
32 the layer comes from is undefined and as such it is recommended to write the same value
33 to <function>gl_Layer</function> for all vertices in the primitive. If a shader statically
34 assigns a value to <function>gl_Layer</function>, layered rendering mode is enabled.
35 If a shader statically assigns a value to <function>gl_Layer</function>, and there is an execution path through
36 the shader that does not set <function>gl_Layer</function>, then the value of <function>gl_Layer</function>
37 is undefined for invocations of the shader that take that path.
38 </para>
39 <para>
40 When used with an array of cube map textures, the <function>gl_Layer</function> output variable
41 takes on a special value. Instead of referring to only the layer, it is used to select a cube map
42 face and a layer. Setting <function>gl_Layer</function> to the value
43 <inlineequation><mml:math><mml:mi>layer</mml:mi><mml:mo>*</mml:mo><mml:mn>6</mml:mn><mml:mo>+</mml:mo><mml:mi>face</mml:mi></mml:math></inlineequation>
44 will render to <inlineequation><mml:math><mml:mi>face</mml:mi></mml:math></inlineequation>
45 of the cube defined in <inlineequation><mml:math><mml:mi>layer</mml:mi></mml:math></inlineequation>.
46 The face values are as follows:
47 <informaltable frame="topbot">
48 <tgroup cols="2" align="left">
49 <colspec colwidth="1.1*" />
50 <colspec colwidth="1*" align="center" />
51 <thead>
52 <row>
53 <entry rowsep="1" align="left"><emphasis role="bold">
54 Face Value
55 </emphasis></entry>
56 <entry rowsep="1" align="left"><emphasis role="bold">
57 Resulting Target
58 </emphasis></entry>
59 </row>
60 <row>
61 <entry>
62 0
63 </entry>
64 <entry>
65 <constant>GL_TEXTURE_CUBEMAP_POSITIVE_X</constant>
66 </entry>
67 </row>
68 <row>
69 <entry>
70 1
71 </entry>
72 <entry>
73 <constant>GL_TEXTURE_CUBEMAP_NEGATIVE_X</constant>
74 </entry>
75 </row>
76 <row>
77 <entry>
78 2
79 </entry>
80 <entry>
81 <constant>GL_TEXTURE_CUBEMAP_POSITIVE_Y</constant>
82 </entry>
83 </row>
84 <row>
85 <entry>
86 3
87 </entry>
88 <entry>
89 <constant>GL_TEXTURE_CUBEMAP_NEGATIVE_Y</constant>
90 </entry>
91 </row>
92 <row>
93 <entry>
94 4
95 </entry>
96 <entry>
97 <constant>GL_TEXTURE_CUBEMAP_POSITIVE_Z</constant>
98 </entry>
99 </row>
100 <row>
101 <entry>
102 5
103 </entry>
104 <entry>
105 <constant>GL_TEXTURE_CUBEMAP_NEGATIVE_Z</constant>
106 </entry>
107 </row>
108 </thead>
109 </tgroup>
110 </informaltable>
111 </para>
112 <para>
113 For example, to render to the positive y cube map face located in the 5<superscript>th</superscript> layer of the
114 cube map array, <function>gl_Layer</function> should be set to
115 <inlineequation><mml:math><mml:mn>5</mml:mn><mml:mo>*</mml:mo><mml:mn>6</mml:mn><mml:mo>+</mml:mo><mml:mn>2</mml:mn></mml:math></inlineequation>.
116 </para>
117 <para>
118 The input variable <function>gl_Layer</function> in the fragment language will have the same value that was written to the
119 output variable <function>gl_Layer</function> in the geometry language. If the geometry stage does not dynamically assign a
120 value to <function>gl_Layer</function>, the value of <function>gl_Layer</function> in the fragment stage will be undefined. If the geometry stage
121 makes no static assignment to <function>gl_Layer</function>, the input <function>gl_Layer</function> in the fragment stage will be zero. Otherwise,
122 the fragment stage will read the same value written by the geometry stage, even if that value is out of
123 range. If a fragment shader contains a static access to <function>gl_Layer</function>, it will count against the implementation
124 defined limit for the maximum number of inputs to the fragment stage.
125 </para>
126 </refsect1>
127 <refsect1 id="versions"><title>Version Support</title>
128 <informaltable frame="topbot">
129 #VARTABLECOLS#
130 <thead>
131 #FUNCTABLEHEADER#
132 <row>
133 <entry>gl_Layer (geometry stage)</entry>#newin15#
134 </row>
135 <row>
136 <entry>gl_Layer (fragment stage)</entry>#newin43#
137 </row>
138 </thead>
139 </tgroup>
140 </informaltable>
141 </refsect1>
142 <refsect1 id="seealso"><title>See Also</title>
143 <para>
144 <citerefentry><refentrytitle>gl_ViewportIndex</refentrytitle></citerefentry>
145 </para>
146 </refsect1>
147 <refsect1 id="Copyright"><title>Copyright</title>
148 <para>
149 Copyright <trademark class="copyright"></trademark> 2011-2012 Khronos Group.
150 This material may be distributed subject to the terms and conditions set forth in
151 the Open Publication License, v 1.0, 8 June 1999.
152 <ulink url="http://opencontent.org/openpub/">http://opencontent.org/openpub/</ulink>.
153 </para>
154 </refsect1>
155 </refentry>