Skip to content

Implement support for ViewportTextures with XR-enabled ViewportsΒ #13016

@funkysandwich

Description

@funkysandwich

Describe the project you are working on

A VR game that would have options for a Spectator/Streaming Camera

Describe the problem or limitation you are having in your project

If the user is running it in VR, I spawn the XR player rig scene as a child of the XRManager, which is it's own SubViewport separate from the main one, because XR viewports don't render 2D nodes. (in my testing)

I also disable 3D on the main viewport, because I don't want the game to render an additional camera if it doesn't need to. (I did this recently, having it enabled was increasing GPU time by a lot.)

Ideally, I want to copy the texture from the XR viewport, and display that on the desktop.
I tried this, but the texture returned is entirely black.

Image

Right window is the VR View directly from SteamVR, left is the game window.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

If support is implemented, it would be possible to mirror the VR view from a SubViewport to a TextureRect that you could then display in another viewport.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

If a ViewportTexture is linked to an XR Viewport, it should display the left, right, or both eyes.
It would be nice to have the option to select which.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not to my knowledge.

Is there a reason why this should be core and not an add-on in the asset library?

I'm not sure how possible it would be to have this as an addon, but given that ViewportTextures and VR are both core, I think the ability to do this should be implemented in core.
I personally thought this is a bug, but I'm not sure if I should make this a bug report or a proposal, so I'm starting with a proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions