|
@@ -2,7 +2,7 @@
|
|
|
* @author mrdoob / http://mrdoob.com/
|
|
|
*/
|
|
|
|
|
|
-import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, FloatType, HalfFloatType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants';
|
|
|
+import { LinearFilter, NearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, ClampToEdgeWrapping, NearestMipMapLinearFilter, NearestMipMapNearestFilter } from '../../constants';
|
|
|
import { _Math } from '../../math/Math';
|
|
|
|
|
|
function WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, info ) {
|
|
@@ -446,12 +446,40 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( texture.format === DepthFormat && internalFormat === _gl.DEPTH_COMPONENT ) {
|
|
|
+
|
|
|
+ // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
|
+ // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT
|
|
|
+ // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
|
+ if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
|
|
|
+
|
|
|
+ texture.type = UnsignedShortType;
|
|
|
+ glType = paramThreeToGL( texture.type );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// Depth stencil textures need the DEPTH_STENCIL internal format
|
|
|
// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
|
if ( texture.format === DepthStencilFormat ) {
|
|
|
|
|
|
internalFormat = _gl.DEPTH_STENCIL;
|
|
|
|
|
|
+ // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are
|
|
|
+ // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.
|
|
|
+ // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)
|
|
|
+ if ( texture.type !== UnsignedInt248Type ) {
|
|
|
+
|
|
|
+ console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
|
|
|
+
|
|
|
+ texture.type = UnsignedInt248Type;
|
|
|
+ glType = paramThreeToGL( texture.type );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
state.texImage2D( _gl.TEXTURE_2D, 0, internalFormat, image.width, image.height, 0, glFormat, glType, null );
|