From c1b29e1e6575820edc327ff0382c20976f0073ee Mon Sep 17 00:00:00 2001 From: Olli Etuaho Date: Tue, 12 Jan 2021 12:27:15 +0200 Subject: [PATCH 1/2] Get all float texture color buffer extensions Different extensions may be required to enable rendering to floating point textures depending on WebGL version and implementation. --- src/renderers/WebGLRenderer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 0bde8ad6ad3106..b0671752a209b8 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -276,7 +276,11 @@ function WebGLRenderer( parameters ) { capabilities = new WebGLCapabilities( _gl, extensions, parameters ); - if ( capabilities.isWebGL2 === false ) { + if ( capabilities.isWebGL2 ) { + + extensions.get( 'EXT_color_buffer_float' ); + + } else { extensions.get( 'WEBGL_depth_texture' ); extensions.get( 'OES_texture_float' ); @@ -290,6 +294,7 @@ function WebGLRenderer( parameters ) { } extensions.get( 'OES_texture_float_linear' ); + extensions.get( 'EXT_color_buffer_half_float' ); utils = new WebGLUtils( _gl, extensions, capabilities ); From f9a1b7fc1a943d69697167c29e9b538aa44d6b83 Mon Sep 17 00:00:00 2001 From: Olli Etuaho Date: Tue, 12 Jan 2021 12:38:08 +0200 Subject: [PATCH 2/2] Fix EXT_color_buffer_half_float check for WebGL 2 EXT_color_buffer_half_float may be supported on WebGL 2 on platforms that support 16-bit float render targets but not 32-bit float render targets. --- src/renderers/WebGLRenderer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index b0671752a209b8..2f9ba9fcf4d6b8 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1894,9 +1894,11 @@ function WebGLRenderer( parameters ) { } + const halfFloatSupportedByExt = textureType === HalfFloatType && ( extensions.get( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.get( 'EXT_color_buffer_float' ) ) ); + if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513) ! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox - ! ( textureType === HalfFloatType && ( capabilities.isWebGL2 ? extensions.get( 'EXT_color_buffer_float' ) : extensions.get( 'EXT_color_buffer_half_float' ) ) ) ) { + ! halfFloatSupportedByExt ) { console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' ); return;