Explorar o código

WebGPURenderer: implement WebGLBackend copyFramebufferToTexture() (#27012)

Co-authored-by: aardgoose <[email protected]>
aardgoose hai 1 ano
pai
achega
7806f49e2a
Modificáronse 1 ficheiros con 13 adicións e 2 borrados
  1. 13 2
      examples/jsm/renderers/webgl/WebGLBackend.js

+ 13 - 2
examples/jsm/renderers/webgl/WebGLBackend.js

@@ -830,9 +830,20 @@ class WebGLBackend extends Backend {
 
 	}
 
-	copyFramebufferToTexture( /*texture, renderContext*/ ) {
+	copyFramebufferToTexture( texture /*, renderContext */ ) {
 
-		console.warn( 'Abstract class.' );
+		const { gl } = this;
+
+		const { textureGPU } = this.get( texture );
+
+		gl.bindFramebuffer( gl.FRAMEBUFFER, null );
+		gl.bindTexture( gl.TEXTURE_2D, textureGPU );
+
+		gl.copyTexSubImage2D( gl.TEXTURE_2D, 0, 0, 0, 0, 0, texture.image.width, texture.image.height );
+
+		if ( texture.generateMipmaps ) gl.generateMipmap( gl.TEXTURE_2D );
+
+		gl.bindTexture( gl.TEXTURE_2D, null );
 
 	}