瀏覽代碼

WebGPURenderer: implement WebGLBackend copyFramebufferToTexture() (#27012)

Co-authored-by: aardgoose <[email protected]>
aardgoose 1 年之前
父節點
當前提交
7806f49e2a
共有 1 個文件被更改,包括 13 次插入2 次删除
  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 );
 
 	}