Skip to content

WebGLRenderer: Calling "copyTextureToTexture" on an unused WebGLRenderTarget does nothing #28282

@gkjohnson

Description

@gkjohnson

Description

Found during #28281

If you call copyTextureToTexture to copy data into a RenderTarget that hasn't been rendered to, yet, then nothing occurs and an error is logged:

GL_INVALID_VALUE: Offset overflows texture dimensions.

Reproduction steps

  1. Create a new WebGLRenderTarget
  2. Create a new data texture
  3. Copy data texture data into the render target
  4. Render target is still empty and a warning is logged

Code

const target = new THREE.WebGLRenderTarget( 16, 16 );
const source = new THREE.DataTexture( new Uint8Array( 16 * 16 * 4 ).fill( 255 ), 16, 16 );

// uncomment these lines initialize the render target and prevent the error for logging
// renderer.setRenderTarget( target );
// renderer.render( scene, camera );
// renderer.setRenderTarget( null );

renderer.copyTextureToTexture( new THREE.Vector2( 0, 0 ), source, target.texture );

// logs warning

Live example

https://jsfiddle.net/2yakmh60/3/

Screenshots

No response

Version

dev

Device

Desktop

Browser

Chrome

OS

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions