1Name 2 3 OES_depth_texture 4 5Name Strings 6 7 GL_OES_depth_texture 8 9Contact 10 11 Aaftab Munshi (amunshi@apple.com) 12 13Notice 14 15 Copyright (c) 2006-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 ES 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 Ratified by the Khronos BOP, March 20, 2008. 31 32Version 33 34 Last Modifed Date: January 29, 2012 35 36Number 37 38 OpenGL ES Extension #44 39 40Dependencies 41 42 OpenGL ES 2.0 is required. 43 This extension is written against the OpenGL ES 2.0 specification 44 45Overview 46 47 This extension defines a new texture format that stores depth values in 48 the texture. Depth texture images are widely used for shadow casting but 49 can also be used for other effects such as image based rendering, displacement 50 mapping etc. 51 52Issues 53 541. Should manual generation of mipmaps for a depth texture using GenerateMipmap be supported? 55 56 Possible Resolutions: 57 58 a) Allow manual generation of mipmaps. This will ensure that GenerateMipmap works 59 consistently for any texture. 60 61 b) Disallow. GenerateMipmap will generate INVALID_OPERATION error for a depth texture. 62 The reason for this is that doing a low-pass filter to generate depth values for 63 higher mip-levels of a depth texture does not make sense. 64 65 Resolution: Adopt approach b). Manual generation of mipmaps is done by averaging a 66 2 x 2 region --> 1 texel as we go from one level to the next. This does not make much 67 sense for depth textures. A better approach would be to take a min or max of 2 x 2 texel 68 region instead of doing an average. Since min & max filters are not supported by GenerateMipmap, 69 the WG decided to disallow manual generation of mipmaps for a depth texture. 70 712. Should GL_DEPTH_TEXTURE_MODE be used to determine whether depth textures are treated as 72 LUMINANCE, INTENSITY or ALPHA textures during texture filtering and application. 73 74 Possible Resolutions: 75 76 a) Adopt text from the OpenGL specification. 77 78 b) No longer require DEPTH_TEXTURE_MODE. Treat depth textures always as luminance 79 textures i.e. depth value is returned as (d, d, d, 1.0) by GLSL texture* calls in the 80 fragment and/or vertex shader. 81 82 Resolution: Adopt approach b). We only need to support one way of treating how depth textures 83 are read by the shader instead of three possible ways as supported by OpenGL. Almost all apps on 84 desktop that use depth textures treat depth textures as LUMINANCE. Therefore, this extension treats 85 depth textures always as luminance textures and no longer supports DEPTH_TEXTURE_MODE. 86 873. How should 24-bit depth texture data be represented when specified in TexImage2D and TexSubImage2D? 88 89 Resolution: This is currently not supported. Depth textures can be specified with 16-bit depth 90 values i.e. <type> = UNSIGNED_SHORT or 32-bit depth values i.e. <type> = UNSIGNED_INT. 91 924. Are cube-map depth textures implemented by this extension? 93 94 Resolution: No. This is defined in OES_depth_texture_cube_map. 95 96 A very interesting use case is rendering shadows for a point light. 97 For a point light, you want to be able to render depth values into a cube-map and then 98 use this cube-map depth texture as a shadow map to compute % in shadow at each pixel. 99 100 The original version of this extension supported cube-map 101 depth textures, but this was contradicted by OES_packed_depth_stencil which 102 only supported 2D textures. Some implementations of OES_depth_texture did 103 not support cube-maps while others did so it was decided to make support for 104 cube-map depth textures a separate extension. 105 1065. Are 3D depth textures implemented by this extension? 107 108 Resolution: This is not supported. We could not come up with any use cases for 109 3D depth textures. In addition, we can always define a new extension that adds 110 this specific functionality in the future. 111 112New Procedures and Functions 113 114 None 115 116New Tokens 117 118 Accepted by the <format> parameter of TexImage2D and TexSubImage2D and 119 <internalFormat> parameter of TexImage2D: 120 121 DEPTH_COMPONENT 0x1902 122 123 Accepted by the <type> parameter of TexImage2D, TexSubImage2D: 124 125 UNSIGNED_SHORT 0x1403 126 UNSIGNED_INT 0x1405 127 128Additions to Chapter 2 of the OpenGL ES 2.0 Specification (OpenGL Operation) 129 130 Modifications to table 2.9 (Component conversions) 131 132 Add the following entries: 133 134 GLType Conversion 135 ------- ---------- 136 UNSIGNED_SHORT c / (2^16 - 1) 137 UNSIGNED_INT c / (2^32 - 1) 138 139 NOTE: UNSIGNED_SHORT and UNSIGNED_INT entries already exist in table 2.9 of the 140 OpenGL ES 2.0 specification and have been added here for clarity. 141 142Additions to Chapter 3, section 3.8 of the OpenGL ES 2.0 specification 143 144 Textures with <format> and <internalFormat> values of DEPTH_COMPONENT 145 refer to a texture that contains depth component data. <type> is used 146 to determine the number of bits used to specify depth texel values. 147 148 A <type> value of UNSIGNED_SHORT refers to a 16-bit depth value. 149 150 A <type> value of UNSIGNED_INT refers to a 32-bit depth value. 151 152 As per the OpenGL ES spec, there is no guarantee that the OpenGL ES implementation 153 will use the <type> to determine how to store the depth texture internally. 154 It may choose to downsample the 32-bit depth values to 16-bit or even 24-bit. 155 There is currently no way for the application to know or find out how the 156 depth texture (or any texture) will be stored internally by the OpenGL ES implementation. 157 158 Textures with a base internal format of DEPTH_COMPONENT are supported 159 by texture image specification commands only if <target> is TEXTURE_2D. 160 Using this format in conjunction with any other <target> will result in 161 an INVALID_OPERATION error. 162 163 CopyTexImage2D and CopyTexSubImage2D are not supported. 164 165Additions to Chapter 4, section 4.4.2 of the OpenGL ES 2.0 specification 166 167 Textures of <format> = DEPTH_COMPONENT are depth renderable. 168 169Errors 170 171 The error INVALID_OPERATION is generated if the <format> and <internalFormat> 172 is DEPTH_COMPONENT and <type> is not UNSIGNED_SHORT, or UNSIGNED_INT. 173 174 The error INVALID_OPERATION is generated if the <format> and <internalFormat> 175 is not DEPTH_COMPONENT and <type> is UNSIGNED_SHORT, or UNSIGNED_INT. 176 177 The error INVALID_OPERATION is generated if <target> is not TEXTURE_2D. 178 179New State 180 181 None. 182 183Revision History 184 185 1/17/2006 First Draft. 186 6/14/2006 CopyTexImage2D and CopyTexSubImage2D are not supported. 187 7/19/2007 Added Issues section + updates to section 3.8 + 188 add section on supporting framebuffer texture attachements 189 for depth textures. 190 7/30/2007 Update issues section with adopted resolutions. 191 Updates to the Errors section. 192 7/31/2007 Updates to conversion table 2.9 193 9/4/2007 Added item 3 to Issues List. 194 Resolution for issue 1 changed to b) - decided in ES WG meeting on 8/29/2007. 195 9/24/2007 Removed UNSIGNED_INT_24_OES. Added reasoning to resolutions in Issues section. 196 Removed dependencies on OES_depth24 and OES_depth32. 197 10/20/2007 Added issues 4. and 5. 198 10/08/2009 Changed INVALID_VALUE to INVALID_OPERATION error (bug 5209). 199 01/29/2012 Move depth cube map texture support to OES_depth_texture_cube_map. 200