XRCamera3D Far Plane Limit

Godot Version

4.2.1

Question

I am a Godot newbie, experimenting with Godot VR for a spaceflight sim. At the moment, I am modeling my planet as a simple sphere, with a radius of 300,000 meters, but keeping the origin at the player at all times to avoid issues with small floats. It’s actually working great on the desktop screen, and I’m very happy so far.

In order to take in the entire planet, I set the Camera3D far plane to 1,000,000 and that seems to be fine, too. However, when I add an XRCamera3D, this far plane value prevents any meshes from rendering in XR. Since I have both cameras in the scene at once, I noticed some interesting things that I couldn’t find in the documentation:

  • The XRCamera3D always ignores its Far parameter and uses the Camera3D far value instead.
  • If the Camera3D Far parameter is higher than 699050 meters, then nothing will be displayed in the VR headset except the sun in the sky; no meshes are rendered.
  • If the Camera3D is removed from the scene altogether, then the XRCamera3D Far parameter will be effective, but using a value above 699050 will result in no meshes, also.
  • No errors or warnings are emitted to the console.

Is this a known, or logical behavior that I should expect to work around, or should I consider it an issue and log it on Github? I am new to working with game engines, so I don’t know what I don’t know, you know?

Thanks!

Only one camera can be current on a viewport, if your Camera3D node is the current camera, it’s near and far value will be used when rendering the scene.

The only thing that is special about the XRCamera3D node is that it is positioned by the tracking system so you can write game logic around that and child objects so they are placed in your field of view.

Other than that the use_xr setting on the viewport triggers the logic that camera position and projection matrix are always obtained from the XR runtime directly with as little latency as possible, using the near and far plane of whatever camera is active.

Ergo: when switching over to XR, make sure to set the current flag on your XRCamera3D node to true.

That said, using a 1,000,000 far plane probably will give you problems in the long run, you’ll have terrible precision in your z-buffer

1 Like

Thank you! Setting the current flag straightened out the conflict between the two cameras.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.