1Name 2 3 ARB_texture_rg 4 5Name Strings 6 7 GL_ARB_texture_rg 8 9Contributors 10 11 Daniel Koch, TransGaming, Inc. 12 Jon Leech, Khronos 13 14Contact 15 16 Daniel Koch, TransGaming, Inc. (daniel 'at' transgaming.com) 17 18Notice 19 20 Copyright (c) 2008-2013 The Khronos Group Inc. Copyright terms at 21 http://www.khronos.org/registry/speccopyright.html 22 23Specification Update Policy 24 25 Khronos-approved extension specifications are updated in response to 26 issues and bugs prioritized by the Khronos OpenGL Working Group. For 27 extensions which have been promoted to a core Specification, fixes will 28 first appear in the latest version of that core Specification, and will 29 eventually be backported to the extension document. This policy is 30 described in more detail at 31 https://www.khronos.org/registry/OpenGL/docs/update_policy.php 32 33Status 34 35 Approved by the ARB on July 11, 2008 36 37Version 38 39 Last Modified Date: May 28, 2009 40 Author Revision: 6 41 42Number 43 44 ARB Extension #53 45 46Dependencies 47 48 OpenGL 1.1 is required. 49 50 This extension is written against the OpenGL 2.1 Specification. 51 52 EXT_texture_integer affects the definition of this extension. 53 54 ARB_texture_float affects the definition of this extension. 55 56 EXT_packed_depth_stencil affects the definition of this extension. 57 58 This extension interacts with ARB_framebuffer_object and 59 EXT_framebuffer_object. 60 61 This extension is subsumed by OpenGL 3.0. 62 63Overview 64 65 Historically one- and two- component textures have been specified in OpenGL 66 using the intensity, luminance or luminance-alpha (I/L/LA) formats. 67 With the advent of programmable shaders and render-to-texture capabilites 68 these legacy formats carry some historical artifacts which are no longer 69 useful. 70 71 For example, when sampling from such textures, the luminance values 72 are replicated across the color components, and the intensity values are 73 replicated across both the color and alpha components. This is no 74 longer necessary with programmable shaders. 75 76 It is also desirable to be able to render to one- and two- 77 component format textures using capabilities such as framebuffer 78 objects (FBO), but rendering to I/L/LA formats is under-specified 79 (specifically how to map R/G/B/A values to I/L/A texture channels). 80 81 This extension adds new base internal formats for the one-component RED 82 and two-component RG (red green) texture formats as well as sized 83 internal formats for fixed-point, floating-point and pure integer texture 84 formats. The new texure formats can be used for texturing as well 85 as for rendering into with framebuffer objects. 86 87IP Status 88 89 No known IP claims. 90 91New Tokens 92 93 Accepted by the <internalFormat> parameter of TexImage1D, TexImage2D, 94 TexImage3D, CopyTexImage1D, and CopyTexImage2D: 95 96 R8 0x8229 97 R16 0x822A 98 99 RG8 0x822B 100 RG16 0x822C 101 102 R16F 0x822D 103 R32F 0x822E 104 105 RG16F 0x822F 106 RG32F 0x8230 107 108 R8I 0x8231 109 R8UI 0x8232 110 R16I 0x8233 111 R16UI 0x8234 112 R32I 0x8235 113 R32UI 0x8236 114 115 RG8I 0x8237 116 RG8UI 0x8238 117 RG16I 0x8239 118 RG16UI 0x823A 119 RG32I 0x823B 120 RG32UI 0x823C 121 122 RED 0x1903 123 RG 0x8227 124 125 COMPRESSED_RED 0x8225 126 COMPRESSED_RG 0x8226 127 128 Accepted by the <format> parameter of TexImage1D, TexImage2D, 129 TexImage3D, TexSubImage1D, TexSubImage2D, TexSubImage3D, 130 and ReadPixels: 131 132 RG 0x8227 133 RG_INTEGER 0x8228 134 135 Accepted by the <format> parameter of DrawPixels: 136 137 RG 0x8227 138 139 Accepted by the <param> parameter of the TexParameter{if}* 140 functions when <pname> is DEPTH_TEXTURE_MODE: 141 142 RED 0x1903 143 144 Accepted by the <format> parameter of GetTexImage: 145 146 RG 0x8227 147 RG_INTEGER 0x8228 148 149 150New Procedures and Functions 151 152 None 153 154Additions to Chapter 2 of the OpenGL 2.1 Specification (OpenGL Operation) 155 156 None 157 158Additions to Chapter 3 of the OpenGL 2.1 Specification (Rasterization) 159 160 Modify section 3.6.3 "Pixel Transfer Modes", the "Color Table Specification" 161 subsection and in the third paragraph of the definition of ColorTable modify 162 the last sentence to read: 163 164 "internalformat must be one of the formats in table 3.15 or table 3.16, 165 with the exception of the RED, RG and DEPTH_COMPONENT base and sized 166 internal formats." 167 168 (Add the following to Table 3.6: "DrawPixels and ReadPixels formats", 169 as modified by EXT_texture_integer) 170 171 Format Name Element Meaning and Order Target Buffer 172 ----------- ------------------------- ------------- 173 RG R, G Color 174 RG_INTEGER iR, iG Color 175 176 (Add the following to Table 3.15: "Conversion from RGBA and depth 177 pixel components to internal texture, table, or filter components") 178 179 Base Internal Format RGBA and Depth Values Internal Components 180 -------------------- --------------------- ------------------- 181 RED R R 182 RG R,G R,G 183 184 (Add the following to Table 3.16: "Correspondence of sized internal 185 formats to base internal formats, and desired component resolutions 186 for each sized internal format", as modified by ARB_texture_float and 187 ARB_texture_integer) 188 189 Sized Base R G B A L I D 190 Internal Format Internal Format bits bits bits bits bits bits bits 191 --------------- --------------- ---- ---- ---- ---- ---- ---- ---- 192 R8 RED 8 193 R16 RED 16 194 RG8 RG 8 8 195 RG16 RG 16 16 196 R16F RED f16 197 R32F RED f32 198 RG16F RG f16 f16 199 RG32F RG f32 f32 200 R8I RED i8 201 R8UI RED ui8 202 R16I RED i16 203 R16UI RED ui16 204 R32I RED i32 205 R32UI RED ui32 206 RG8I RG i8 i8 207 RG8UI RG ui8 ui8 208 RG16I RG i16 i16 209 RG16UI RG ui16 ui16 210 RG32I RG i32 i32 211 RG32UI RG ui32 ui32 212 213 (Add the following to Table 3.17: "Generic and specific compressed 214 internal formats") 215 216 Compressed Internal Format Base Internal Format Type 217 -------------------------- -------------------- --------- 218 COMPRESSED_RED RED Generic 219 COMPRESSED_RG RG Generic 220 221 (Modify Table 3.18: "Texure parameters and their values") 222 223 Add RED to the "Legal Values" column for the row containing the 224 definition of DEPTH_TEXTURE_MODE. 225 226 Modify the first sentence of section 3.8.5 "Depth Component Textures" 227 (as modified by EXT_packed_depth_stencil or ARB_framebuffer_object) to read: 228 229 "Depth textures and the depth components of depth/stencil textures can 230 be treated as RED, LUMINANCE, INTENSITY or ALPHA textures during texture 231 filtering and application." 232 233 (Add the following to Table 3.20: "Correspondence of filtered texture 234 components to texture source components.") 235 236 Texture Base Texture source color 237 Internal Format C_s A_s 238 --------------- ------------- ------ 239 RED (R_t, 0, 0) 1 240 RG (R_t, G_t, 0) 1 241 242 (Modify Table 3.21: "Texture functions REPLACE, MODULATE and DECAL.") 243 244 Add RED and RG to the "Texture Base Internal Format" column for the 245 row which defines the behaviour for RGB (or 3). 246 247 (Modify Table 3.22: "Texture functions BLEND and ADD.") 248 249 Add RED and RG to the "Texture Base Internal Format" column for the 250 row which defines the behaviour for RGB (or 3). 251 252 Modify Section 3.8.14 "Texture Comparision Modes", the "Depth Texture 253 Comparision Mode" subsection, and change the second to last paragraph 254 to read: 255 256 "The resulting r is assigned to R_t, L_t, I_t, or A_t if the value of the 257 DEPTH_TEXTURE_MODE is respectively RED, LUMINANCE, INTENSITY, or ALPHA." 258 259Additions to Chapter 4 of the OpenGL 2.1 Specification (Per-Fragment Operations 260and the Framebuffer) 261 262 In section 4.3.2 "Reading Pixels" the subsection "Obtaining Pixels from 263 the framebuffer", modify the first sentence of the 3rd paragraph in the 264 definition of ReadBuffer to read: 265 266 "If the GL is in RGBA mode, and format is one of RED, GREEN, BLUE, ALPHA, 267 RG, RGB, RGBA, BGR, BGRA, LUMINANCE, or LUMINANCE_ALPHA, then red, 268 green, blue, and alpha values are obtained from the selected buffer at 269 each pixel location." 270 271 In subsection "Placement in Pixel Pack Buffer or Client Memory," modify 272 the second to last sentence to read: 273 274 "Likewise if the format is RG, LUMINANCE_ALPHA, RGB, BGR, only the 275 corresponding two or three elements are written." 276 277 In section 4.4.4 "Framebuffer Completeness" as added by 278 EXT_framebuffer_object or ARB_framebuffer_object, modify the first bullet 279 point and add RED and RG to the list of base internal formats which 280 are color-renderable. 281 282Additions to Chapter 5 of the OpenGL 2.1 Specification (Special Functions) 283 284 None 285 286Additions to Chapter 6 of the OpenGL 2.1 Specification (State and State Requests) 287 288 Modify section 6.1.4 "Texture Queries". Change the second sentence of the 289 second paragraph to read: 290 291 "Calling GetTexImage with a color format (one of RED, GREEN, BLUE, ALPHA, 292 RG, RGB, BGR, RGBA, BGRA, LUMINANCE, LUMINANCE_ALPHA, or one of the 293 *_INTEGER variants) when the base internal format of the texture image is 294 not a color format; with a format of DEPTH_COMPONENT when the base internal 295 format is not DEPTH_COMPONENT or DEPTH_STENCIL; with a format of 296 DEPTH_STENCIL when the base internal format is not DEPTH_STENCIL; with an 297 *_INTEGER format when the base internal format is not one of the integral 298 types; or with non-integer format when the base internal is an integral 299 type, causes the error INVALID_OPERATION." 300 301 (Add the following to Table 6.1: "Texture, table, and filter return values") 302 303 Base Internal Format R G B A 304 -------------------- ---- ----- --- --- 305 RED R_i 0 0 1 306 RG R_i G_i 0 1 307 308Dependencies on EXT_packed_depth_stencil 309 310 If EXT_packed_depth_stencil is not supported then delete any reference to 311 depth/stencil textures (unless ARB_framebuffer_objects is supported). 312 313Dependencies on EXT_framebuffer_object 314 315 If EXT_framebuffer_object is not supported then delete any reference to 316 framebuffer objects (unless ARB_framebuffer_objects is supported). 317 318Dependencies on ARB_framebuffer_object 319 320 If ARB_framebuffer_object is not supported: 321 * delete any reference to depth/stencil textures 322 (unless EXT_packed_depth_stencil is supported). 323 * delete any reference to framebuffer objects 324 (unless EXT_framebuffer_object is supported). 325 326Dependencies on EXT_texture_integer 327 328 If EXT_texture_integer is not supported: 329 * delete any reference to the R*I*, R*UI* and *INTEGER* formats. 330 331Dependencies on ARB_texture_float 332 333 If ARB_texture_float is not supported: 334 * delete any reference to the R*F* formats. 335 336Issues 337 338 1) What should this extension be called? ARB_rg_formats, ARB_rg_texture, 339 ARB_texture_rg, etc 340 341 DECIDED. Using ARB_texture_rg. 342 343 2) Why use RED token used instead of just "R"? 344 345 a) there is already some precedent for using RED for single-component 346 images 347 b) the "R" token is already used for texcoord generation, and it is 348 less confusing if we don't reuse it. 349 350 3) Why use RG instead of REDGREEN? 351 352 The list {RED, RG, RGB, RGBA} is more visually appealing than 353 {RED, REDGREEN, RGB, RGBA}. 354 355 4) Why don't the new tokens and entry points in this extension have 356 "ARB" suffixes like other ARB extensions? 357 358 RESOLVED: Unlike most ARB extensions, this is a strict subset of 359 functionality already approved in OpenGL 3.0. This extension 360 exists only to support that functionality on older hardware that 361 cannot implement a full OpenGL 3.0 driver. Since there are no 362 possible behavior changes between the ARB extension and core 363 features, source code compatibility is improved by not using 364 suffixes on the extension. 365 366 5) What are the default values for the unspecified channels if you sampled 367 from an R or RG texture? Is it (r,0,0,1) or (r,1,1,1). 368 369 CLARIFICATION: As per OpenGL defaults as specified in Table 3.20 370 (as modified by this extension) the default values for unspecified 371 components are (r,0,0,1). Note that this does differ from D3D where 372 unspecified values would be filled in as (r,1,1,1). 373 374 6) Are the RG formats accepted by the imaging subset of functions? 375 376 RESOLUTION: NO. This extension does not add RG support to the functions 377 defined in the imaging subset (that is: [Get]Color[Sub]Table, 378 [Get]ConvolutionFilter, [Get]SeparableFilter, GetHistogram, GetMinMax) 379 as it is felt that there is little benefit in doing so. This could be 380 added as a separate extension if desired. 381 382Revision History 383 384 #6 May 28, 2008, jleech 385 - Remove extraneous *_INTEGER formats from table 6.1 386 #5 April 8, 2008, dgkoch 387 - Address issues raised in Bug 4163 388 - clarify that RG_INTEGER is not allowed for DrawPixels 389 - added issue 6) and clarify that support for RED and RG formats 390 is not added to the imaging subset 391 - GetTexImage supports RG (but no conversion) 392 #4 November 14, 2008, dgkoch 393 - marked issue 1) as resolved. 394 - add issue 5) as clarification 395 - Better compatibility with GL 3.0 spec 396 - allow unsized RED and RG formats as internal formats (Bug 4161) 397 - add enums for COMPRESSED_RED/RG and allow as internal formats (Bug 4162) 398 #3 August 7, 2008, jleech 399 - Remove ARB suffixes. 400 #2 June 9, 2008, dgkoch 401 - add COMPRESSED_RED/RG generic formats. 402 - add CopyTexImage1/2D to list of functions accepting the new 403 internalformats. 404 #1 June 8, 2008, dgkoch 405 - initial version extracted from GL3 core. 406