• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Name
2
3    ARB_shadow
4
5Name Strings
6
7    GL_ARB_shadow
8
9Contact
10
11    Brian Paul (brian_e_paul 'at' yahoo.com)
12
13Notice
14
15    Copyright (c) 2002-2013 The Khronos Group Inc. Copyright terms at
16        http://www.khronos.org/registry/speccopyright.html
17
18Status
19
20    Complete. Approved by ARB on February 14, 2002.
21
22Version
23
24    Last Modified Date: 21 January 2002
25
26Number
27
28    ARB Extension #23
29
30Dependencies
31
32    OpenGL 1.1 is required.
33    ARB_depth_texture is required.
34    This extension is written against the OpenGL 1.3 Specification.
35
36Overview
37
38    This extension clarifies the GL_SGIX_shadow extension.
39
40    This extension supports comparing the texture R coordinate to a depth
41    texture value in order to produce a boolean texture value.  This can
42    be used to implement shadow maps.
43
44    The extension is written in generic terms such that other texture
45    comparison modes can be accommodated in the future.
46
47IP Status
48
49    XXX None?
50
51Issues
52
53    (1) How is this extension different from GL_SGIX_shadow?
54
55      - It defines GL behaviour when the currently bound texture is not
56        a depth texture.
57      - It specifies that R is clamped to [0,1].
58      - We use the standard GL_LEQUAL and GL_GEQUAL tokens instead of
59        defining new ones.
60      - The result may be ALPHA, LUMINANCE or INTENSITY.
61      - A bit more is said about how depth textures are sampled.
62      - The extension is generalized for comparison modes.
63
64    (2) Should we use GL_LEQUAL and GL_EQUAL instead of
65      GL_TEXTURE_LEQUAL_R_SGIX and GL_TEXTURE_GEQUAL_R_SGIX?
66
67      RESOLUTION: Yes.  The old tokens are misleading.  For example,
68      the GL_TEXTURE_LEQUAL_R_SGIX token should really have been named
69      GL_R_LEQUAL_TEXTURE_SGIX since we're comparing R <= TEXTURE.
70      This extension uses the standard GL_LEQUAL and GL_GEQUAL tokens.
71      Also, the original shadow spec seems to be inconsistant with
72      what was really implemented in hardware.
73
74    (3) Use TEXTURE_COMPARE_OPERATOR_ARB or TEXTURE_COMPARE_FUNC_ARB?
75
76      RESOLVED: Use TEXTURE_COMPARE_FUNC_ARB to be more consistant with
77      the conventions of glDepthFunc(), glStencilFunc(), etc which use
78      the GL_LEQUAL, GL_GEQUAL, etc tokens.
79
80    (4) Should the result of the texture comparison be a LUMINANCE,
81      INTENSITY or ALPHA texel?
82
83      RESOLVED: Allow any of them. This is controlled by
84      DEPTH_TEXTURE_MODE_ARB defined in ARB_depth_texture extension.
85
86    (5) What if TEXTURE_COMPARE_MODE_ARB is set to COMPARE_R_TO_TEXTURE
87      but the the currently bound texture is not a depth texture?
88
89      RESOLVED: If the currently bound texture is a color (or paletted
90      or color index) texture then the texture unit treats it in the
91      usual manner and all texture comparison logic is bypassed.
92
93    (6) Should the R value be clamped to [0,1] before the comparison?
94
95      RESOLUTION: Yes, that makes sense since the depth texels are in
96      the range [0,1].  Note that clamping R to [0,1] really only matters
97      at the values 0 and 1.
98
99    (7) How is bilinear or trilinear filtering implemented?
100
101      RESOLUTION: We suggest an implementation behaviour but leave the
102      details up to the implementation.  Differences here amount to the
103      quality and softness of shadow edges.  Specific filtering
104      algorithms could be expressed via layered extensions.  We're
105      intentionally vague here to avoid IP and patent issues.
106
107    (8) Is GL_ARB_shadow the right name for this extension?
108
109      RESOLVED: Probably.  While this extension is expressed in rather
110      generic terms which may be used by future extensions, it implements
111      a rather specific operation at this time.
112
113    (9) What about GL_SGIX_shadow_ambient?
114
115      RESOLUTION: Omit that functionality.  It can be accomplished with
116      advanced texture extensions such as GL_NV_register_combiners.
117      GL_SGIX_shadow_ambient usually can't be implemented with existing
118      hardware so it'll be offered as GL_ARB_shadow_ambient, rather than
119      burdon this extension with it.
120
121New Procedures and Functions
122
123    None
124
125New Tokens
126
127    Accepted by the <pname> parameter of TexParameterf, TexParameteri,
128    TexParameterfv, TexParameteriv, GetTexParameterfv, and GetTexParameteriv:
129
130    TEXTURE_COMPARE_MODE_ARB    0x884C
131    TEXTURE_COMPARE_FUNC_ARB    0x884D
132
133    Accepted by the <param> parameter of TexParameterf, TexParameteri,
134    TexParameterfv, and TexParameteriv when the <pname> parameter is
135    TEXTURE_COMPARE_MODE_ARB:
136
137    COMPARE_R_TO_TEXTURE_ARB    0x884E
138
139Additions to Chapter 2 of the 1.3 Specification (OpenGL Operation)
140
141    None
142
143Additions to Chapter 3 of the 1.3 Specification (Rasterization)
144
145    Section 3.8.4, Texture Parameters, p. 133, append table 3.19 with the
146    following:
147
148        Name                        Type  Legal Values
149        --------------------------  ----  -------------------------------
150        TEXTURE_COMPARE_MODE_ARB    enum  NONE, COMPARE_R_TO_TEXTURE
151        TEXTURE_COMPARE_FUNC_ARB    enum  LEQUAL, GEQUAL
152
153    After section 3.8.12, Texture Environments and Texture Functions,
154    p. 149, insert the following new sections (and renumber subsequent
155    sections):
156
157        "3.8.13 Texture Comparison Modes
158
159        TEXTURE_COMPARE_MODE_ARB can be used to compute the texture value
160        according to a comparison function.  TEXTURE_COMPARE_MODE_ARB
161        specifies the comparison operands, and TEXTURE_COMPARE_FUNC_ARB
162        specifies the comparison function.  The format of the resulting
163        texture sample is specified by the DEPTH_TEXTURE_MODE_ARB.
164
165        3.8.13.1 Depth Texture Comparison Mode
166
167        If the currently bound texture's format is DEPTH_COMPONENT then
168        TEXTURE_COMPARE_MODE_ARB, TEXTURE_COMPARE_FUNC_ARB and
169        DEPTH_TEXTURE_MODE_ARB control the output of the texture unit
170        as described below.  However, if the currently bound texture is
171        not DEPTH_COMPONENT then the texture unit operates in the normal
172        manner and texture comparison is bypassed.
173
174        Let Dt (D subscript t) be the depth texture value, in the range
175        [0, 1].  Let R be the interpolated texture coordinate clamped to
176        the range [0, 1].  Then the effective texture value Lt, It, or At
177        is computed by
178
179        if TEXTURE_COMPARE_MODE_ARB = NONE
180
181            r = Dt
182
183        else if TEXTURE_COMPARE_MODE_ARB = COMPARE_R_TO_TEXTURE_ARB
184
185            if TEXTURE_COMPARE_FUNC_ARB = LEQUAL
186
187                 { 1.0,  if R <= Dt
188             r = {
189                 { 0.0,  if R > Dt
190
191            else if TEXTURE_COMPARE_FUNC_ARB = GEQUAL
192
193                 { 1.0,  if R >= Dt
194             r = {
195                 { 0.0,  if R < Dt
196
197            endif
198
199            if DEPTH_TEXTURE_MODE_ARB = LUMINANCE
200
201                Lt = r
202
203            else if DEPTH_TEXTURE_MODE_ARB = INTENSITY
204
205                It = r
206
207            else if DEPTH_TEXTURE_MODE_ARB = ALPHA
208
209                At = r
210
211            endif
212
213        endif
214
215        If TEXTURE_MAG_FILTER is not NEAREST or TEXTURE_MIN_FILTER is
216        not NEAREST or NEAREST_MIPMAP_NEAREST then r may be computed by
217        comparing more than one depth texture value to the texture R
218        coordinate.  The details of this are implementation-dependent
219        but r should be a value in the range [0, 1] which is proportional
220        to the number of comparison passes or failures.
221
222Additions to Chapter 4 of the 1.3 Specification (Per-Fragment Operations
223and the Frame Buffer)
224
225    None
226
227Additions to Chapter 5 of the 1.3 Specification (Special Functions)
228
229    None
230
231Additions to Chapter 6 of the 1.3 Specification (State and State Requests)
232
233    In section 6.1.3, p. 200, insert the following after the fourth
234    paragraph:
235
236    "The texture compare mode and texture compare function may be queried
237    by calling GetTexParameteriv or GetTexParameterfv with <pname> set to
238    TEXTURE_COMPARE_MODE_ARB, or TEXTURE_COMPARE_FUNC_ARB, respectively."
239
240Additions to the GLX Specification
241
242    None
243
244Errors
245
246    INVALID_ENUM is generated if TexParameter[if] parameter <pname>
247    is TEXTURE_COMPARE_MODE_ARB and parameter <param> is not NONE or
248    COMPARE_R_TO_TEXTURE.
249
250    INVALID_ENUM is generated if TexParameter[if] parameter <pname>
251    is TEXTURE_COMPARE_FUNC_ARB and parameter <param> is not LEQUAL or
252    GEQUAL.
253
254New State
255
256    In table 6.16, Texture Objects, p. 224, add the following:
257
258    Get Value                   Type  Get Command           Initial Value  Description     Sec.   Attribute
259    --------------------------  ----  --------------------  -------------  --------------  -----  ---------
260    TEXTURE_COMPARE_MODE_ARB    Z_2   GetTexParameter[if]v  NONE           compare mode    3.8.13 texture
261    TEXTURE_COMPARE_FUNC_ARB    Z_2   GetTexParameter[if]v  LEQUAL         compare func    3.8.13 texture
262
263New Implementation Dependent State
264
265    None
266
267Revision History
268
269    19 March 2001
270        - initial revision
271    20 March 2001
272        - use GL_LEQUAL, GL_GEQUAL tokens
273        - removed TEXTURE_COMPARE_FAIL_VALUE_ARB
274    16 April 2001
275        - renamed TEXTURE_COMPARE_OPERATOR_ARB to TEXTURE_COMPARE_FUNC_ARB
276        - replace TEXTURE_COMPARE_ARB with TEXTURE_COMPARE_MODE_ARB
277    22 April 2001
278        - added TEXTURE_COMPARE_RESULT
279    23 April 2001
280        - minor tweaks
281    22 June 2001
282        - fixed grammatical errors
283    16 November 2001
284        - Change default value of TEXTURE_COMPARE_MODE_ARB to LUMINANCE.
285    17 November 2001
286        - Resolved issue 5
287        - cleaned up new section 3.8.7.1 yet again
288    12 December 2001
289        - rewritten against the OpenGL 1.3 spec
290    3 January 2002
291        - fixed a typo found by Bimal
292    18 January 2002
293        - Since depth textures can now allow ALPHA, INTENSITY, LUMINANCE mode,
294          there was no need for TEXTURE_COMPARE_RESULT_ARB.
295    21 January 2002
296        - Fixed error to be INVALID_ENUM instead of INVALID_OPERATION.
297