Consider this code:
let newTex = new THREE.Texture( { width : renderTargetDist.width, height : renderTargetDist.height} );
this.renderer.setRenderTarget(renderTargetDist);
this.renderer.copyFramebufferToTexture( new THREE.Vector2(0,0), newTex, 0 );
this.renderer.setRenderTarget(null);
This gives no errors or warnings, but __webglTexture is undefined because version is 0 & there’s been no upload. The problem is that all code paths to allocate webgl texture seems to also want me to upload texture data.
Do you mind updating the following official example to demonstrate the issue? three.js webgl - framebuffer - texture
Notice that the following pattern is not valid:
Use DataTexture
if your image source is not an image.
1 Like
I was under the impression that DataTexture also needed to be fed data, which was what I’m trying to avoid since I’ll be copying from the frame buffer anyway. But this seems to work:
let newTex = new THREE.DataTexture( null, renderTargetDist.width, renderTargetDist.height, THREE.RGBAFormat );
this.renderer.setRenderTarget(renderTargetDist);
this.renderer.copyFramebufferToTexture( new THREE.Vector2(0,0), newTex, 0 );
this.renderer.setRenderTarget(null);