Perspective() in VR mode

Hello everyone!

I’m currently working on a VR project in which I am trying to simulate a camera. One of the things I want to simulate is zooming in and out. I first thought simply changing the fov in perspective() was the way to go, but I got greeted with the message:

Perspective cannot be modified in VR mode

I have also tried just making the scene come closer to the viewer, but it just does not look like zooming in. Does anyone have any idea how I can affect fov in VR?


Hi, just saw your post. The camera parameters cannot be modified in VR since they are set so they follow the headset movement and simulate stereoscopic vision. In order to make the scene closer to the viewer, you could simply apply translations to the objects.

Thanks for you answer Andres!

This is indeed what I’ve been doing in the meantime, while I was trying to find some way to change the fov since it seems like a much more realistic “camera zoom effect” than just moving the objects. However, I understand that it can’t be done in order to maintain the VR.

Would there be any way to modify the clipping planes or are they set as well? I’ve been running into problems when translating objects for this effect since they pass the far clipping planes every once in a while.

Thank you very much for your help!

You are right, changing the clipping planes should be a possibility… and yes, revising the renderer’s code I see that the camera’s near and far values can be changed in VR too. There should be a better API, but right now you should be able to simply set the desired values into the defCameraFar and defCameraFar variables:

void setup() {
  ((PGraphicsVR)g).defCameraNear = 1;
  ((PGraphicsVR)g).defCameraFar = 1000;

Great! Thanks a lot for your help!