Skip to content

depthTexture share source after RenderTarget.clone() #30540

@TheBlek

Description

@TheBlek

Description

Cloning a RenderTarget does not create a new Source for the new DepthTexture.

I've encountered this bug while using EffectComposer. If you pass a RenderTarget with depthTexture into EffectComposer, it will clone the depthTexture, but will not update its Source. This results in GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture if you use passes that use depth texture.

I've found two very similar issues: one two

Reproduction steps

  1. Create RenderTarget
  2. Create DepthTexture for ithe RenderTarget
  3. Clone RenderTarget
  4. Compare sources of depth textures of new and old RenderTargets

Code

const fbo = new THREE.WebGLRenderTarget(640, 480);
fbo.texture.format = THREE.RGBFormat;
fbo.texture.generateMipmaps = false;
fbo.depthBuffer = true;
fbo.depthTexture = new THREE.DepthTexture(640, 480);
fbo.depthTexture.format = THREE.DepthFormat;
console.log(fbo.depthTexture.source);
console.log(fbo.depthTexture.clone().source);

See jsfiddle for the example where that breaks EffectComposer

Live example

https://jsfiddle.net/teu61qyj/3/
P.S. jsfiddle does not print the feedback error for me, but the rendering still breaks

Screenshots

No response

Version

r173

Device

Desktop

Browser

Chrome

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions