-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebGLRenderTarget: DepthTexture cannot be changed after initial use #19447
Comments
@Mugen87 @mrdoob are there any existing patterns that can be used to fix this? I was looking into how to address it but there are quite a few corner cases. Here are the cases: depthBuffer = true, depthTexture = null
depthBuffer = false, depthTexture = null
depthBuffer = true, depthTexture = DepthTexture instance
depthBuffer = false, depthTexture = DepthTexture instance
I wonder if something like the version and needsUpdate pattern might work for renderTargets, too? |
FYI for anyone running into this my workaround has been perform a manual copy of the depth textures using the |
I just want to confirm if i understand the example, is what you're trying to achieve possible by turning the depth mask off while rendering to the color attachment? |
const origTarget = new WebGLRenderTarget( ... );
const effectTarget = new WebGLRenderTarget( ... );
const depthTexture = new DepthTexture();
const effectQuad = new FullScreenQuad( ... );
// ...
origTarget.depthTexture = depthTexture;
renderer.setRenderTarget( origTarget );
renderer.render( scene, camera );
effectQuad.material.uniforms.texture.value = origTarget.texture;
renderer.setRenderTarget( effectTarget );
effectTarget.depthTexture = null;
effectQuad.render( renderer );
effectQuad.depthTexture = depthTexture;
// draw more meshes after the effect has been rendered |
Fixed in #28584 |
I'm using a render target depthTexture to render the main scene, then would like to modify the contents of the color buffer without touching the contents of the depth buffer but it looks like once a render target has been set with a given depthTexture setting it cannot be modified later. Here's a simplified example of what I'm trying to do. In practice I'm using multiple textures and a fullscreen quad to render the second time:
Looking through the code it looks like these lines are to blame for the depth texture not updating:
three.js/src/renderers/WebGLRenderer.js
Lines 1964 to 1968 in c4d1e88
textures.setUpRenderTarget
will only get called once per render target, which is where the depth texture gets initialized and bound to the frame buffer.The text was updated successfully, but these errors were encountered: