Depth Test Doesn't Work When Depth Buffer Set to False While Creating Render Target
See original GitHub issueDescription of the problem
This is an image from webgl_rtt.html
sample.

When I set depthBuffer
to false
, the depth test doesn’t work.
rtTexture = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat, depthBuffer: false } );
Three.js version
Current version
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Depth test inverted by default in OpenGL, or did I get it wrong?
By clearing the depth buffer to 1, you are essentially saying that all objects closer than the maximum depth should be drawn. Changing...
Read more >Depth test for custom framebuffer not working - Khronos Forums
The problem is that the depth testing for the local rendering doesn't work. The result of the rendering operation depends on the order...
Read more >opengl - FBO Depth Buffer not working
I have set glClearDepth(1.0) and I clear bot the COLOR_BUFFER_BIT and DEPTH_BUFFER_BIT before I draw to the FBO, however the value is still...
Read more >Depth testing - LearnOpenGL
OpenGL performs a depth test and if this test passes, the fragment is rendered and the depth buffer is updated with the new...
Read more >Configuring Depth-Stencil Functionality - Win32 apps
Set DepthEnable to FALSE to disable depth testing and prevent ... When a buffer is used as a render target, depth-stencil testing and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Depth testing in the render target requires a depth buffer so there is something to depth test against.
The fiddle appears to be working as expected. https://jsfiddle.net/p4ob9d2e/2/
Here’s the jsfiddle:
https://jsfiddle.net/p4ob9d2e/
Change line 76 to
depthBuffer: true
then it works well.