I’ve been working on a personal game project for over a year now and I’m having an issue with the WebGLRenderer and reversedDepthBuffer in VR. I found a fix for most of the issues I had but 2 remain. I know I can use logarithmicDepthBuffer but there is a performance cost and reversedDepth gives me a better result.
First, I would like to share what I had to do to make this work. When switching to VR (button) with RDB (reversedDepthBuffer) everything is not ordered properly. It’s in reverse. After some digging and help from Google Gemini
, I corrected this issue by doing the following:
- Update Material Depth Function
Traverse the scene and set material.depthFunc = THREE.GreaterEqualDepth; - Ensure Proper Clearing
renderer.state.buffers.depth.setClear( 0 );
I feel this fix should be part of Three somehow. Maybe it’s a work in progress or I missed something. Let me know.
The remaining issues are:
- Shaders
I could dig deeper for those, but would be gratefull for some help on what to adjust. - VR Controllers
For some reason they don’t seem to be catched by the scene.traverse when setting the depthFunc. So they don’t display properly.
I believe it’s easy to reproduce for VR by using the Immerssive Web Immulator Chrome extension.
If anyone can help me with these two issues I would appreciate greatly.