forked from BSVino/docs.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl_Layer.xhtml
250 lines (249 loc) · 14 KB
/
gl_Layer.xhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<div class="refentry" id="gl_Layer">
<div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>gl_Layer — contains the selected layer of a multi-layer framebuffer attachment</p>
</div>
<div class="refsynopsisdiv">
<h2>Declaration</h2>
<p>
</p>
<pre class="programlisting">// Geometry stage</pre>
<p>
<code class="fieldsynopsis"><span class="modifier">out </span><span class="type">int </span><span class="varname">gl_Layer </span>;</code>
</p>
<p>
</p>
<pre class="programlisting">// Fragment stage</pre>
<p>
<code class="fieldsynopsis"><span class="modifier">in </span><span class="type">int </span><span class="varname">gl_Layer </span>;</code>
</p>
</div>
<div class="refsect1" id="description">
<h2>Description</h2>
<p>
In the geometry language, <code class="varname">gl_Layer</code> is 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
to <code class="varname">gl_Layer</code> for all vertices in the primitive. If a shader statically
assigns a value to <code class="varname">gl_Layer</code>, layered rendering mode is enabled.
If a shader statically assigns a value to <code class="varname">gl_Layer</code>, and there is an execution path through
the shader that does not set <code class="varname">gl_Layer</code>, then the value of <code class="varname">gl_Layer</code>
is undefined for invocations of the shader that take that path.
</p>
<p>
When used with an array of cube map textures, the <code class="varname">gl_Layer</code> 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 <code class="varname">gl_Layer</code> to the value
<math overflow="scroll"><mi>layer</mi><mo>*</mo><mn>6</mn><mo>+</mo><mi>face</mi></math>
will render to <math overflow="scroll"><mi>face</mi></math>
of the cube defined in <math overflow="scroll"><mi>layer</mi></math>.
The face values are as follows:
</p>
<div class="informaltable">
<table style="border-collapse: collapse; border-top: 2px solid ; border-bottom: 2px solid ; border-left: 2px solid ; border-right: 2px solid ; ">
<colgroup>
<col style="text-align: left; "/>
<col style="text-align: center; "/>
</colgroup>
<thead>
<tr>
<th style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong> Face Value </strong></span>
</th>
<th style="text-align: center; border-bottom: 2px solid ; ">
<span class="bold"><strong> Resulting Target </strong></span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
0
</td>
<td style="text-align: center; border-bottom: 2px solid ; ">
<code class="constant">GL_TEXTURE_CUBEMAP_POSITIVE_X</code>
</td>
</tr>
<tr>
<td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
1
</td>
<td style="text-align: center; border-bottom: 2px solid ; ">
<code class="constant">GL_TEXTURE_CUBEMAP_NEGATIVE_X</code>
</td>
</tr>
<tr>
<td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
2
</td>
<td style="text-align: center; border-bottom: 2px solid ; ">
<code class="constant">GL_TEXTURE_CUBEMAP_POSITIVE_Y</code>
</td>
</tr>
<tr>
<td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
3
</td>
<td style="text-align: center; border-bottom: 2px solid ; ">
<code class="constant">GL_TEXTURE_CUBEMAP_NEGATIVE_Y</code>
</td>
</tr>
<tr>
<td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
4
</td>
<td style="text-align: center; border-bottom: 2px solid ; ">
<code class="constant">GL_TEXTURE_CUBEMAP_POSITIVE_Z</code>
</td>
</tr>
<tr>
<td style="text-align: left; border-right: 2px solid ; ">
5
</td>
<td style="text-align: center; ">
<code class="constant">GL_TEXTURE_CUBEMAP_NEGATIVE_Z</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
<p>
For example, to render to the positive y cube map face located in the 5<sup>th</sup> layer of the
cube map array, <code class="varname">gl_Layer</code> should be set to
<math overflow="scroll"><mn>5</mn><mo>*</mo><mn>6</mn><mo>+</mo><mn>2</mn></math>.
</p>
<p>
The input variable <code class="varname">gl_Layer</code> in the fragment language will have the same value that was written to the
output variable <code class="varname">gl_Layer</code> in the geometry language. If the geometry stage does not dynamically assign a
value to <code class="varname">gl_Layer</code>, the value of <code class="varname">gl_Layer</code> in the fragment stage will be undefined. If the geometry stage
makes no static assignment to <code class="varname">gl_Layer</code>, the input <code class="varname">gl_Layer</code> 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 <code class="varname">gl_Layer</code>, it will count against the implementation
defined limit for the maximum number of inputs to the fragment stage.
</p>
</div>
{$pipelinestall}{$examples}
<div class="refsect1" id="versions">
<h2>Version Support</h2>
<div class="informaltable">
<table style="border-collapse: collapse; border-top: 2px solid ; border-bottom: 2px solid ; border-left: 2px solid ; border-right: 2px solid ; ">
<colgroup>
<col style="text-align: left; "/>
<col style="text-align: center; " class="firstvers"/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; "/>
<col style="text-align: center; " class="lastvers"/>
</colgroup>
<thead>
<tr>
<th style="text-align: left; border-right: 2px solid ; ">
</th>
<th style="text-align: center; border-bottom: 2px solid ; " colspan="12">
<span class="bold"><strong>OpenGL Shading Language Version</strong></span>
</th>
</tr>
<tr>
<th style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>Function Name</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>1.10</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>1.20</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>1.30</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>1.40</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>1.50</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>3.30</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>4.00</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>4.10</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>4.20</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>4.30</strong></span>
</th>
<th style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">
<span class="bold"><strong>4.40</strong></span>
</th>
<th style="text-align: center; border-bottom: 2px solid ; ">
<span class="bold"><strong>4.50</strong></span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left; border-right: 2px solid ; border-bottom: 2px solid ; ">gl_Layer (geometry stage)</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; border-bottom: 2px solid ; ">✔</td>
<td style="text-align: center; border-bottom: 2px solid ; ">✔</td>
</tr>
<tr>
<td style="text-align: left; border-right: 2px solid ; ">gl_Layer (fragment stage)</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">-</td>
<td style="text-align: center; border-right: 2px solid ; ">✔</td>
<td style="text-align: center; border-right: 2px solid ; ">✔</td>
<td style="text-align: center; ">✔</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="refsect1" id="seealso">
<h2>See Also</h2>
<p>
<a class="citerefentry" href="gl_ViewportIndex"><span class="citerefentry"><span class="refentrytitle">gl_ViewportIndex</span></span></a>
</p>
</div>
<div class="refsect1" id="Copyright">
<h2>Copyright</h2>
<p>
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.
<a class="link" href="https://opencontent.org/openpub/" target="_top">https://opencontent.org/openpub/</a>.
</p>
</div>
</div>