diff --git a/cocos/core/gfx/webgl/webgl-commands.ts b/cocos/core/gfx/webgl/webgl-commands.ts index 460f4cc8e6..bbac63cf84 100644 --- a/cocos/core/gfx/webgl/webgl-commands.ts +++ b/cocos/core/gfx/webgl/webgl-commands.ts @@ -162,7 +162,7 @@ function GFXFormatToWebGLInternalFormat (format: GFXFormat, gl: WebGLRenderingCo case GFXFormat.R5G6B5: return gl.RGB565; case GFXFormat.RGB5A1: return gl.RGB5_A1; case GFXFormat.RGBA4: return gl.RGBA4; - case GFXFormat.D16: return gl.DEPTH_COMPONENT16; + case GFXFormat.D16: return gl.DEPTH_COMPONENT; case GFXFormat.D16S8: return gl.DEPTH_STENCIL; case GFXFormat.D24: return gl.DEPTH_COMPONENT; case GFXFormat.D24S8: return gl.DEPTH_STENCIL; @@ -799,6 +799,10 @@ export function WebGLCmdFuncCreateTexture (device: WebGLGFXDevice, gpuTexture: W gl.bindRenderbuffer(gl.RENDERBUFFER, gpuTexture.glRenderbuffer); device.stateCache.glRenderbuffer = gpuTexture.glRenderbuffer; } + // Special treatment, refer to https://developer.mozilla.org/zh-CN/docs/Web/API/WebGLRenderingContext/renderbufferStorage + if (gpuTexture.glInternelFmt === gl.DEPTH_COMPONENT) { + gpuTexture.glInternelFmt = gl.DEPTH_COMPONENT16; + } gl.renderbufferStorage(gl.RENDERBUFFER, gpuTexture.glInternelFmt, w, h); }