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