bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
33.93k stars 3.31k forks source link

OpenXR: Virtual Reality Rendering #115

Open johannesvollmer opened 3 years ago

johannesvollmer commented 3 years ago

Hi! This project sounds awesome. I just discovered it and wanted to talk about XR support.

One could assume that this could be implemented as an external module. However, the OpenXR library creates one or more render targets (for Vulkan/GL/...) based on the physical XR hardware. Therefore, the XR module needs to talk to the rendering module. As a consequence, a few generic changes to the rendering module may possibly be required, changes that are most probably unspecific to OpenXR. That's why it's reasonable to talk about this now already.

I'd like to look into OpenXR, which already has Rust bindings. However, the architecture should probably be prototyped in collaboration, as I don't know all the bevy stuff yet. I'll read all the bevy documentation and then come back to this issue.

I'd be happy to hear your thoughts to this! Cheers

cart commented 3 years ago

I would love to support XR. I've never personally written code in that space, but I have a general idea about a few ways it could integrate with bevy. Does OpenXR interact directly with render apis (ex vulkan / opengl) or is it abstract (in a way that we could use the bevy render api directly)?

If it needs direct vulkan access, then we can either:

  1. build a wgpu extension that exposes the relevant apis
  2. build a second bevy render backend that uses an api (like vulkan) directly

my preference would be to do this through wgpu to reduce complexity on our end (and also improve the wgpu ecosystem).

erlend-sh commented 3 years ago

Probably should be done upstream: https://github.com/gfx-rs/gfx/issues/3219

johannesvollmer commented 3 years ago

Yeah, it needs direct vulkan access. It should really be done upstream.

This means that bevy should only expose the gfx XR API after gfx adds support

StarArawn commented 3 years ago

I want to point out once gfx-hal supports openXR you'd have to create a wgpu native(web wont get this) extension as well. Keep in mind we'd need some way of turning on/off wgpu native extensions in bevy. Current extensions can be found here: https://wgpu.rs/doc/wgpu/struct.Features.html

IceSentry commented 3 years ago

https://github.com/gfx-rs/gfx/issues/3219 mentions that the api could potentially be based on WebXR which means it could also target the web without needing a native and web extension

ambeeeeee commented 3 years ago

The WGPU API will be based on WebXR, the gfx one is going to be based on OpenXR.

jpryne commented 3 years ago

Is this a work in progress? Can I study the code, perhaps even make a pull request?

ndarilek commented 3 years ago

I could be wrong about this, but I've been in the community for a while and haven't seen anyone actively moving it forward. I imagine you could take it if you wanted.

I, personally, am interested in this if only because I hope it'll get us better spatial audio support, which I think is a bigger deal in VR than it is in most desktop/mobile games.

Be prepared to draw up an RFC first, though, as that seems to be the direction we're headed in. Alternatively, you may be able to knock together a renderer similar to what bevy_webgl2 did, though at some point there'll probably be a bureaucratic hurdle to overcome. :)

agrande commented 3 years ago

I've been working on this for a while, continuing what @amberkowalski started on the gfx side of things, but I'm new to Rust, Vulkan and OpenXR. Here's what I have so far: https://github.com/agrande/gfx/tree/gfx-xr. Not quite there yet, but I'm actively working on it. I don't feel experienced enough to lead the effort, but since no one seemed to be doing it, and I really want to have VR in bevy, I decided to give it a go. Maybe we should open a channel on the discord to coordinate the efforts and make sure we all have the same level of information, as several people seem interested in the topic...

SafariMonkey commented 3 years ago

I am not experienced in OpenXR, but I have some OpenVR experience. I would like to see a channel or other place for discussion if that's possible, as I am also in the position of wanting to contribute, but not having enough experience that I feel able to lead the effort. If we can coordinate, we can hopefully make some progress without too much duplication of effort.

agrande commented 3 years ago

Ok, so now we have an XR channel on discord to coordinate the effort 🙌

johannesvollmer commented 3 years ago

Nice. I'm afraid I can't help as I currently do not have access to a vr headset anymore

blaind commented 3 years ago

I've created a proof-of-concept (but functional) Bevy - OpenXR that works on Oculus Quest 2 and most probably on PC with Monado as well. See https://github.com/blaind/xrbevy.

palodequeso commented 2 years ago

Love to see this integration, as someone who watched Amethyst closely and am now here, I really love VR dev. Would be happy to test on SteamVR and contribute as needed.

IceSentry commented 2 years ago

For the record, there's some work being done in this PR https://github.com/bevyengine/bevy/pull/2319 to support XR in bevy

dkhovanskii commented 1 year ago

I am wondering if there any progress on WebXR?

mrchantey commented 1 year ago

Edit: here's a summary of bevy xr forks I've come across with my understanding of the difference in features:

alice-i-cecile commented 8 months ago

Much more recent, actively developed XR plugin for Bevy: https://github.com/awtterpip/bevy_openxr

Largely built off the work listed above <3

Currently targeting main, but should be usable with Bevy 0.12 in a couple weeks.