De-Panther / unity-webxr-export

Develop and export WebXR experiences using Unity WebGL
https://de-panther.github.io/unity-webxr-export/
Apache License 2.0
1.04k stars 110 forks source link

Looking Glass WebXR Support #260

Open BryanChrisBrown opened 1 year ago

BryanChrisBrown commented 1 year ago

So, this issue is mostly to ask a few questions about the project, specifically around Unity's handling of multiple views as I'm looking to see if it's possible to use this to support the Looking Glass WebXR Library.

It looks like unity currently renders both views to the full framebuffer based on some digging with nvidia nsight,

I've attempted to load the Looking Glass WebXR Library with the Unity WebGL output, and while it does initiate an XR Session it doesn't render beyond two views, this part makes sense because of the way the plugin was written. I'm working on a PR now that remedies this, but was more curious about the full canvas rendering.

The way the Looking Glass WebXR Library works is that it renders a grid of views to the XRWebGLLayer, then runs those through a subpixel shader to render for the Looking Glass display. Currently, the Unity WebGL build seems to render the views to the full framebuffer, rather than the specific quadrant associated with a view, is this something baked into unity, or something that can be configured with how the WebXR Exporter is handled?

Thanks!

De-Panther commented 1 year ago

As Unity is a closed box, the simplest solution was to send the views to the full framebuffer.

I guess you already looked at webxr.jspre. Some pointers that might help, Look where we override bindFramebuffer. And at the start of XRManager.prototype.animate.

Notice that Unity's JS minimizer on some versions supports only ES5, so newer JS syntax won't work in the jspre file.

De-Panther commented 1 year ago

Any updates? Or things that I can change that would help with this implementation?

BryanChrisBrown commented 1 year ago

I did try building out a basic implementation in unity to test performance. One of the issues that I ran into was unity's webGL / WASM output being limited to a single-thread, rendering 48 cameras at once is much slower than in native builds.

I briefly tried looking into some optimizations for it, but didn't have too much luck and sort of left it at that for the time being.

De-Panther commented 9 months ago

I tried to look if there's open source Looking Glass Unity package, but it seems that I need to download a .unitypackage file... How does the current Looking Glass Unity support works? Number of Cameras? Render Textures? XR SDK?

I recently added support for Unity XR SDK to WebXR Export, but sadly there's no Single Pass or Multiview support for web. I wonder how the current non-web support for Looking Glass handles the rendering of so many views.