Using depthMap with vrHelper

I’m trying to get the depthMap to work in a project that is also using the vrHelper. Here is a PG showcasing the issue:

https://www.babylonjs-playground.com/#T5YWJQ#6

While using scene.activeCamera when initializing the depthMap works fine, after switching to VR mode, the depthmap isn’t being updated anymore. I guess that’s to expected, since VR uses a different set of cameras.

I would like to be able to access the correct depthmap in VR mode as well though. How would I do that?

The vr helper has observables for when you exit/enter VR. Also, the vr helper has a property for current VR camera. You can combine them like this:
https://www.babylonjs-playground.com/#T5YWJQ#7

1 Like

Thank you @brianzinn, that’s what I thought too, but it looks that isn’t working.

If you check out your playground, in VR, the texture should be updating, when you move the camera, just like it does outside of VR. In the playground it only updates once you leave VR again.

Adding @trevordev for the VR part

@jhadenfeldt give this a try: https://www.babylonjs-playground.com/#T5YWJQ#9 . Once you enter vr you need to wait for the vrcamera to render and then get the depth map from one of the eyes.