3 <ratified href="WEBGL_depth_texture/">
4 <name>WEBGL_depth_texture</name>
6 <alias>WEBKIT_WEBGL_depth_texture</alias>
7 <alias>MOZ_WEBGL_depth_texture</alias>
10 <a href="https://www.khronos.org/webgl/public-mailing-list/">WebGL working group</a> (public_webgl 'at' khronos.org)
13 <contributor>Members of the WebGL working group</contributor>
14 <contributor>Florian Bösch (pyalot 'at' gmail.com)</contributor>
21 <p>This extension exposes the
22 <a href="http://angleproject.googlecode.com/svn/trunk/extensions/ANGLE_depth_texture.txt">ANGLE_depth_texture</a>
23 functionality to WebGL. ANGLE_depth_texture provides a subset of the
24 functionality from the OpenGL ES 2.0 extensions
25 <a href="http://www.khronos.org/registry/gles/extensions/OES/OES_depth_texture.txt">OES_depth_texture</a>
27 <a href="http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt">OES_packed_depth_stencil</a>, with certain restrictions added for portability reasons. Specifically:</p>
30 <li> ANGLE_depth_texture provides both depth and depth/stencil textures. </li>
31 <li> ANGLE_depth_texture does not provide the <code>DEPTH24_STENCIL8_OES</code> renderbuffer internal format from the OES_packed_depth_stencil extension. The core WebGL specification already supports allocation of depth/stencil renderbuffers. </li>
32 <li> ANGLE_depth_texture does not support loading image data via the TexImage or TexSubImage commands. Depth and depth/stencil textures created via this extension can only have their contents specified by rendering to them. </li>
35 <p>Consult the Errors section below for specific restrictions.
40 The <code>texImage2D</code> entry point is extended to accept the
41 <code>format</code> parameter <code>DEPTH_COMPONENT</code> and
42 <code>DEPTH_STENCIL</code>
45 The <code>texImage2D</code> entry point is extended to accept the
46 <code>internalFormat</code> parameter <code>DEPTH_COMPONENT</code>
47 and <code>DEPTH_STENCIL</code>
50 The <code>texImage2D</code> entry point is extended to accept
51 the <code>type</code> parameter <code>UNSIGNED_SHORT</code>,
52 <code>UNSIGNED_INT</code>, and
53 <code>UNSIGNED_INT_24_8_WEBGL</code>
56 The <code>framebufferTexture2D</code> entry point is extended to
57 accept the <code>target</code> parameter
58 <code>DEPTH_ATTACHMENT</code> and
59 <code>DEPTH_STENCIL_ATTACHMENT</code>
62 The <code>texImage2D</code> entry point is extended to accept
63 <code>ArrayBufferView</code> of type <code>Uint16Array</code> and
64 <code>Uint32Array</code>
68 The WebGL-specific constraints about <a href="http://www.khronos.org/registry/webgl/specs/1.0/#FBO_ATTACHMENTS">Framebuffer Object Attachments</a> are extended:</p>
71 <li> A texture attached to an FBO's <code>DEPTH_ATTACHMENT</code> attachment point must be allocated with the <code>DEPTH_COMPONENT</code> internal format. </li>
72 <li> A texture attached to the <code>DEPTH_STENCIL_ATTACHMENT</code> attachment point must be allocated with the <code>DEPTH_STENCIL</code> internal format. </li>
76 In the WebGL API, it is an error to concurrently attach either
77 renderbuffers or textures to the following combinations of
78 attachment points:</p>
81 <li> <code>DEPTH_ATTACHMENT</code> + <code>DEPTH_STENCIL_ATTACHMENT</code> </li>
82 <li> <code>STENCIL_ATTACHMENT</code> + <code>DEPTH_STENCIL_ATTACHMENT</code> </li>
83 <li> <code>DEPTH_ATTACHMENT</code> + <code>STENCIL_ATTACHMENT</code> </li>
88 <a href="http://www.khronos.org/registry/webgl/specs/1.0/#FBO_ATTACHMENTS">Framebuffer Object Attachments</a>
89 in the WebGL specification for the behavior if these
90 constraints are violated.
95 As per the OpenGL ES spec, there is no guarantee that the OpenGL ES implementation
96 will use the texture type to determine how to store the depth texture internally.
97 It may choose to downsample the 32-bit depth values to 16-bit or even 24-bit.
98 When a depth or depth/stencil texture is attached to a framebuffer object, calls to getParameter
99 with the DEPTH_BITS and STENCIL_BITS enums return the following:
102 <th>Texture Type</th>
103 <th>DEPTH_BITS (GLint)</th>
104 <th>STENCIL_BITS (GLint)</th>
107 <td>UNSIGNED_SHORT</td>
112 <td>UNSIGNED_INT</td>
117 <td>UNSIGNED_INT_24_8_WEBGL</td>
126 <idl xml:space="preserve">
128 interface WEBGL_depth_texture {
129 const GLenum UNSIGNED_INT_24_8_WEBGL = 0x84FA;
134 The error <code>INVALID_OPERATION</code> is generated by
135 <code>texImage2D</code> if the <code>format</code> parameter is
136 <code>DEPTH_COMPONENT</code> or <code>DEPTH_STENCIL</code> and the
137 <code>target</code> is
138 <code>TEXTURE_CUBE_MAP_{POSITIVE,NEGATIVE}_{X,Y,Z}</code>.
141 The error <code>INVALID_OPERATION</code> is generated by
142 <code>texImage2D</code> if <code>format</code> and
143 <code>internalformat</code> are <code>DEPTH_COMPONENT</code> and
144 <code>type</code> is not <code>UNSIGNED_SHORT</code> or
145 <code>UNSIGNED_INT</code>.
148 The error <code>INVALID_OPERATION</code> is generated by
149 <code>texImage2D</code> if <code>format</code> and
150 <code>internalformat</code> are not <code>DEPTH_COMPONENT</code>
151 and <code>type</code> is <code>UNSIGNED_SHORT</code> or
152 <code>UNSIGNED_INT</code>.
155 The error <code>INVALID_OPERATION</code> is generated by
156 <code>texImage2D</code> if <code>format</code> and
157 <code>internalformat</code> are <code>DEPTH_STENCIL</code> and
158 <code>type</code> is not <code>UNSIGNED_INT_24_8_WEBGL</code>.
161 The error <code>INVALID_OPERATION</code> is generated by
162 <code>texImage2D</code> if <code>format</code> and
163 <code>internalformat</code> are not <code>DEPTH_STENCIL</code> and
164 <code>type</code> is <code>UNSIGNED_INT_24_8_WEBGL</code>.
167 The error <code>INVALID_OPERATION</code> is generated in the following situations:
170 <code>texImage2D</code> is called with <code>format</code> and
171 <code>internalformat</code> of <code>DEPTH_COMPONENT</code> or
172 <code>DEPTH_STENCIL</code> and
174 <li> <code>target</code> is not TEXTURE_2D, </li>
175 <li> <code>data</code> is not NULL, or </li>
176 <li> <code>level</code> is not zero. </li>
180 <code>texSubImage2D</code> is called with <code>format</code> of
181 <code>DEPTH_COMPONENT</code> or <code>DEPTH_STENCIL</code>.
184 <code>copyTexImage2D</code> is called with an
185 <code>internalformat</code> that has a base internal format of
186 <code>DEPTH_COMPONENT</code> or <code>DEPTH_STENCIL</code>.
189 <code>copyTexSubImage2D</code> is called with a target texture
190 that has a base internal format of <code>DEPTH_COMPONENT</code>
191 or <code>DEPTH_STENCIL</code>.
194 <code>generateMipmap</code> is called on a texture that has a
195 base internal format of <code>DEPTH_COMPONENT</code> or
196 <code>DEPTH_STENCIL</code>.
203 As per the ANGLE_depth_texture specification, when a depth
204 texture is sampled, the value is stored into the RED channel.
205 The contents of the GREEN, BLUE and ALPHA channels are
206 implementation dependent. It is therefore recommended to use
207 only the <code>r</code> component of variables in GLSL shaders
208 that are used to reference depth textures.
212 <revision date="2012/01/23">
213 <change>Initial revision.</change>
215 <revision date="2012/01/25">
216 <change>Added provisions to exclude cube depth textures.</change>
218 <revision date="2012/02/06">
219 <change>Changed referenced WebGL API version from 2.0 to 1.0</change>
221 <revision date="2012/02/24">
222 <change>Removed the enumerants from the IDL which are contained in the context and added aliases to the extension name</change>
224 <revision date="2012/03/01">
226 Renamed with OES prefix and removed the addendum due to expected harmonization between OES_depth_texture and ARB_depth_texture
230 <revision date="2012/06/04">
232 Renamed to WEBGL prefix, and changed to reference ANGLE_depth_texture, because of
233 limitations preventing the current ANGLE library from loading of image data to depth
234 textures. Incorporated errors from ANGLE_depth_texure extension specification.
237 <revision date="2012/06/20">
239 Incorporated depth/stencil support and UNSIGNED_INT_24_8_WEBGL enum after discussion on
240 public_webgl mailing list, including supported behavior and additional error behavior.
241 Extended rules in Section 6.5 ("Framebuffer Object Attachments") to handle texture
245 <revision date="2012/06/27">
247 Updated references to texSubImage2D. Added
248 DEPTH_STENCIL_ATTACHMENT to framebufferTexture2D.
251 <revision date="2013/01/26">
252 <change>Moved from draft to community approved status</change>
254 <revision date="2013/02/28">
255 <change>Updated to track ANGLE_depth_texture, indicating that only red channel is guaranteed.</change>
257 <revision date="2013/05/15">
258 <change>Ratified by Khronos Board of Promoters.</change>
260 <revision date="2014/07/15">
261 <change>Added NoInterfaceObject extended attribute.</change>