Browse Source

WebGLTextures: WebGL2 framebuffer RGBformat fallback

Guilherme Avila 5 years ago
parent
commit
98114a1510
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/renderers/webgl/WebGLTextures.js

+ 12 - 0
src/renderers/webgl/WebGLTextures.js

@@ -987,6 +987,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 		var isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );
 		var supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;
 
+		// Handles WebGL2 RGBFormat fallback - #18858
+
+		if ( isWebGL2 &&
+			renderTarget.texture.format === RGBFormat &&
+			( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) {
+
+			renderTarget.texture.format = RGBAFormat;
+
+			console.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' );
+
+		}
+
 		// Setup framebuffer
 
 		if ( isCube ) {