• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    MESAX_texture_stack
4
5Name Strings
6
7    GL_MESAX_texture_stack
8
9Contact
10
11    Ian Romanick, IBM (idr 'at' us.ibm.com)
12
13IP Status
14
15    No known IP issues.
16
17Status
18
19    TBD
20
21Version
22
23    $Date: 2005/12/12$ $Revision: 0.3$
24
25Number
26
27    318
28
29Dependencies
30
31    OpenGL 1.2 or GL_EXT_texture3D is required.
32
33    Support for ARB_fragment_program is assumed, but not required.
34
35    Support for ARB_fragment_program_shadow is assumed, but not required.
36
37    Support for EXT_framebuffer_object is assumed, but not required.
38
39    Written based on the wording of the OpenGL 2.0 specification and
40    ARB_fragment_program_shadow but not dependent on them.
41
42Overview
43
44    There are a number of circumstances where an application may wish to
45    blend two textures out of a larger set of textures.  Moreover, in some
46    cases the selected textures may vary on a per-fragment basis within
47    a polygon.  Several examples include:
48
49       1. High dynamic range textures.  The application stores several
50       different "exposures" of an image as different textures.  On a
51       per-fragment basis, the application selects which exposures are
52       used.
53
54       2. A terrain engine where the altitude of a point determines the
55       texture applied to it.  If the transition is from beach sand to
56       grass to rocks to snow, the application will store each texture
57       in a different texture map, and dynamically select which two
58       textures to blend at run-time.
59
60       3. Storing short video clips in textures.  Each depth slice is a
61       single frame of video.
62
63    Several solutions to this problem have been proposed, but they either
64    involve using a separate texture unit for each texture map or using 3D
65    textures without mipmaps.  Both of these options have major drawbacks.
66
67    This extension provides a third alternative that eliminates the major
68    drawbacks of both previous methods.  A new texture target,
69    TEXTURE_2D_STACK, is added that functions identically to TEXTURE_3D in
70    all aspects except the sizes of the non-base level images.  In
71    traditional 3D texturing, the size of the N+1 LOD is half the size
72    of the N LOD in all three dimensions.  For the TEXTURE_2D_STACK target,
73    the height and width of the N+1 LOD is halved, but the depth is the
74    same for all levels of detail. The texture then becomes a "stack" of
75    2D textures.  The per-fragment texel is selected by the R texture
76    coordinate.
77
78    References:
79
80        http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=011557
81        http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=000516
82        http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=011903
83        http://www.delphi3d.net/articles/viewarticle.php?article=terraintex.htm
84
85Issues
86
87    (1) Is "texture stack" a good name for this functionality?
88
89        NO.  However, I can't think of anything else that is better.
90
91    (2) Should the R texture coordinate be treated as normalized or
92    un-normalized?  If it were un-normalized, floor(R) could be thought
93    of as a direct index into the texture stack.  This may be more
94    convenient for applications.
95
96        RESOLVED.  All texture coordinates are normalized.  The issue of
97        un-normalized texture coordinates has been discussed in the ARB
98        before and should be left for a layered extension.
99
100    (3) How does LOD selection work for stacked textures?
101
102        RESOLVED.  For 2D texture stacks the R coordinate is ignored, and
103        the LOD selection equations for 2D textures are used.  For 1D
104        texture stacks the T coordinate is ignored, and the LOD selection
105        equations for 1D textures are used.  The expected usage is in a
106        fragment program with an explicit LOD selection.
107
108    (4) What is the maximum size of a 2D texture stack?  Is it the same
109    as for a 3D texture, or should a new query be added?  How about for 1D
110    texture stacks?
111
112        UNRESOLVED.
113
114    (5) How are texture stacks exposed in GLSL?
115
116        RESOLVED.  For now, they're not exposed at all.  Mesa doesn't
117	currently support GLSL, so it's somewhat moot.
118
119	When this extension is converted to MESA, EXT, or ARB, it is
120	expected that an additional samplers (e.g., sampler1DStack and
121	sampler2DStack) and texture lookup functions (e.g., texture1DStack and
122	texture2Dstack) will be added.
123
124    (6) Should a 1D texture stack also be exposed?
125
126        RESOLVED.  For orthogonality, yes.
127
128    (7) How are stacked textures attached to framebuffer objects?
129
130        SEMI-RESOLVED.  Slices of TEXTURE_2D_STACK textures are attached in
131        the same manner as slices of traditional 3D textures.
132
133        TEXTURE_1D_STACK textures are a bit more tricky.  This could be
134        handled one of two ways.  The entire texture could be attached using
135        FramebufferTexture2DEXT, or a new function could be created that
136        would allow the attachment of a single 1D slice of the texture.  The
137        spec currently uses the former, but the later may be more logical.
138
139New Procedures and Functions
140
141    None
142
143New Tokens
144
145    Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, by
146    the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, and
147    GetDoublev, and by the <target> parameter of TexImage3D, GetTexImage,
148    GetTexLevelParameteriv, GetTexLevelParameterfv, GetTexParameteriv, and
149    GetTexParameterfv:
150
151        TEXTURE_1D_STACK_MESAX            0x8759
152        TEXTURE_2D_STACK_MESAX            0x875A
153
154    Accepted by the <target> parameter of TexImage3D,
155    GetTexLevelParameteriv, and GetTexLevelParameterfv:
156
157        PROXY_TEXTURE_1D_STACK_MESAX      0x875B
158        PROXY_TEXTURE_2D_STACK_MESAX      0x875C
159
160    Accepted by the <pname> parameter of GetBooleanv, GetIntegerv,
161    GetFloatv, and GetDoublev
162
163        TEXTURE_1D_STACK_BINDING_MESAX    0x875D
164        TEXTURE_2D_STACK_BINDING_MESAX    0x875E
165
166    Accepted by the <textarget> parameter of FramebufferTexture2DEXT:
167
168        TEXTURE_1D_STACK_MESAX
169
170    Accepted by the <textarget> parameter of FramebufferTexture3DEXT:
171
172        TEXTURE_2D_STACK_MESAX
173
174Additions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation)
175
176    None
177
178Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization)
179
180    -- Section 3.8.8 "Texture Minification" in the section "Scale Factor and Level of Detail"
181
182       Change the first paragraph (page 172) to say:
183
184       "Let s(x,y) be the function that associates an s texture coordinate
185       with each set of window coordinates (x,y) that lie within a primitive;
186       define t(x,y) and r(x,y) analogously.  Let u(x,y) = w_t * s(x,y),
187       v(x,y) = h_t * t(x,y), and w(x,y) = d_t * r(x,y), where w_t, h_t,
188       and d_t are as defined by equations 3.15, 3.16, and 3.17 with
189       w_s, h_s, and d_s equal to the width, height, and depth of the
190       image array whose level is level_base.  For a one-dimensional
191       texture, define v(x,y) = 0 and w(x,y) = 0; for a two-dimensional
192       texture or a 2D texture stack, define w(x,y) = 0..."
193
194    -- Section 3.8.8 "Texture Minification" in the section "Mipmapping"
195
196       After the first paragraph (page 175) add:
197
198       "For TEXTURE_2D_STACK_MESAX textures, d_b is always treated as
199       zero, regardless of the actual value, when performing mipmap
200       calculations."
201
202    -- Section 3.8.15 "Texture Application"
203
204       Change the first paragraph (page 189) to say:
205
206       "Texturing is enabled or disabled using the generic Enable and Disable
207       commands, respectively, with the symbolic constants TEXTURE_1D,
208       TEXTURE_2D, TEXTURE_3D, TEXTURE_CUBE_MAP, TEXTURE_1D_STACK_MESAX, or
209       TEXTURE_2D_STACK_MESAX to enable one-, two-, three-dimensional, cube
210       map, or 2D texture stack texture, respectively.  If both two- and
211       one-dimensional textures are enabled, the two-dimensional texture is
212       used.  If the three-dimensional and either of the two- or one-
213       dimensional textures is enabled, the three-dimensional texture is
214       used.  If the cube map texture and any of the three-, two-, or one-
215       dimensional textures is enabled, then cube map texturing is used.  If
216       1D texture stack is enabled and any of cube map, three-, two-, or
217       one-dimensional textures is enabled, 2D texture stack texturing is
218       used.  If 2D texture stack is enabled and any of cube map, three-,
219       two-, one-dimensional textures or 1D texture stack is enabled, 2D
220       texture stack texturing is used..."
221
222    -- Section 3.11.2 of ARB_fragment_program (Fragment Program Grammar and Restrictions):
223
224       (mostly add to existing grammar rules)
225
226       <optionName>           ::= "MESAX_texture_stack"
227
228       <texTarget>            ::= "1D"
229                               | "2D"
230                               | "3D"
231                               | "CUBE"
232                               | "RECT"
233                               | "1D_STACK"
234                               | "2D_STACK"
235
236    -- Add Section 3.11.4.5.4 Texture Stack Option
237
238       "If a fragment program specifies the "MESAX_texture_stack" program
239       option, the <texTarget> rule is modified to add the texture targets
240       1D_STACK and 2D_STACK (See Section 3.11.2)."
241
242    -- Modify Section 3.11.6  Fragment Program Texture Instruction Set
243
244       (replace 1st and 2nd paragraphs with the following paragraphs)
245
246      "The first three texture instructions described below specify the
247      mapping of 4-tuple input vectors to 4-tuple output vectors.
248      The sampling of the texture works as described in section 3.8,
249      except that texture environments and texture functions are not
250      applicable, and the texture enables hierarchy is replaced by explicit
251      references to the desired texture target (i.e., 1D, 2D, 3D, cube map,
252      rectangle, 1D_STACK, 2D_STACK).  These texture instructions specify
253      how the 4-tuple is mapped into the coordinates used for sampling.  The
254      following function is used to describe the texture sampling in the
255      descriptions below:
256
257         vec4 TextureSample(float s, float t, float r, float lodBias,
258                            int texImageUnit, enum texTarget);
259
260      Note that not all three texture coordinates, s, t, and r, are
261      used by all texture targets.  In particular, 1D texture targets only
262      use the s component.  2D, RECT (non-power-of-two), and 1D_STACK texture
263      targets only use the s and t components.  SHADOW1D texture
264      targets only use the s and r components.  The descriptions of the
265      texture instructions below supply all three components, as would
266      be the case with CUBE, 3D, 2D_STACK, SHADOW2D, and SHADOWRECT targets."
267
268Additions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment Operations)
269
270    -- 4.4.2.3 Attaching Texture Images to a Framebuffer
271
272       Change the sixth paragraph to say:
273
274       "If <textarget> is TEXTURE_RECTANGLE_ARB, then <level> must be zero.
275       If <textarget> is TEXTURE_3D or TEXTURE_2D_STACK , then <level> must
276       be greater than or equal to zero and less than or equal to log base 2
277       of MAX_3D_TEXTURE_SIZE..."
278
279       Change the ninth paragraph to say:
280
281       "For FramebufferTexture2DEXT, if <texture> is not zero, then
282       <textarget> must be one of: TEXTURE_2D, TEXTURE_1D_STACK,
283       TEXTURE_RECTANGLE_ARB, TEXTURE_CUBE_MAP_POSITIVE_X,
284       TEXTURE_CUBE_MAP_POSITIVE_Y, TEXTURE_CUBE_MAP_POSITIVE_Z,
285       TEXTURE_CUBE_MAP_NEGATIVE_X, TEXTURE_CUBE_MAP_NEGATIVE_Y, or
286       TEXTURE_CUBE_MAP_NEGATIVE_Z."
287
288       Change the tenth paragraph to say:
289
290       "For FramebufferTexture3DEXT, if <texture> is not zero, then
291       <textarget> must be TEXTURE_3D or TEXTURE_2D_STACK."
292
293Additions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions)
294
295    None
296
297Additions to Chapter 6 of the OpenGL 2.0 Specification (State and State Requests)
298
299    None
300
301Additions to Appendix A of the OpenGL 2.0 Specification (Invariance)
302
303    None
304
305Additions to the AGL/GLX/WGL Specifications
306
307    None
308
309GLX Protocol
310
311    None
312
313Dependencies on ARB_fragment_program
314
315    If ARB_fragment_program is not supported, the changes to section 3.11
316    should be ignored.
317
318Dependencies on EXT_framebuffer_object
319
320    If EXT_framebuffer_object is not supported, the changes to section
321    4.4.2.3 should be ignored.
322
323Errors
324
325    None
326
327New State
328
329    None
330
331New Implementation Dependent State
332
333    None
334
335Revision History
336
337    ||2005/11/15||0.1||idr||Initial draft version.||
338    ||2005/12/07||0.2||idr||Added framebuffer object interactions.||
339    ||2005/12/12||0.3||idr||Updated fragment program interactions.||
340