x3dom / x3dom

X3DOM. A framework for integrating and manipulating X3D scenes as HTML5/DOM elements.
http://x3dom.org
Other
813 stars 271 forks source link

Update WebVR code to WebXR #1235

Closed msub2 closed 11 months ago

msub2 commented 1 year ago

Opening a draft PR while I work this out still. Right now I've gotten it to a point where it's successfully spinning up an XRSession and rendering to the headset, but for some reason it's only appearing in the right eye. It's not immediately clear why this is but I'll continue to work on it.

msub2 commented 1 year ago

After more tinkering I believe the rendering issue stems from somewhere in the code for the shaders, somewhere around https://github.com/x3dom/x3dom/blob/master/src/shader/ShaderComposed.js#L75 and other areas that check isVR == 1. There are also the various VRmode == 2 codepaths in gfx_webgl.js, I'm just having a bit of difficulty nailing down exactly what's making it only render in the right eye still.

tsturm commented 1 year ago

x3dom uses a Instanced-based single pass technique to render both eyes in one frame. I think the problem is that you set the wrong Viewport at https://github.com/msub2/x3dom/blob/webxr/src/Viewarea.js#L175

If you remove this line it should work

msub2 commented 1 year ago

If I remove that, it looks closer to correct on a flatscreen view (i.e. with a WebXR API Emulator) but does not render correctly in-headset (my test scene contains a cube positioned directly ahead of the camera, but currently it renders distorted and in the far bottom-left of my view).

Flatscreen view

In-headset view (this also requires looking down and to the left in real life)

andreasplesch commented 1 year ago

great progress !

MacrayBlackhand commented 1 year ago

Let me add my appreciation for this effort and, while I doubt being able to contribute to coding, if I can help in any other way, just let me know!

---- On Mon, 14 Nov 2022 15:14:35 -0600 Andreas Plesch @.***> wrote ---

great progress !

— Reply to this email directly, https://github.com/x3dom/x3dom/pull/1235#issuecomment-1314388866, or https://github.com/notifications/unsubscribe-auth/AWTX3ZXGFEP4OIJBDUSXZMLWIKTTXANCNFSM6AAAAAARSBMHPA. You are receiving this because you are subscribed to this thread.

msub2 commented 1 year ago

Appreciate the encouragement! I'm always juggling several different projects at once but I'll try and continue to chip away at this as I can.

andreasplesch commented 1 year ago

Would it make sense to try the 'local' reference space ?

 session.requestReferenceSpace("local").then(function ( space )
tsturm commented 1 year ago

I already have a version which works on my old Oculus Go, I will push it to a webxr branch as soon as possible.

tsturm commented 1 year ago

@msub2 I have pushed my current state to a new webxr branch for testing:

https://github.com/x3dom/x3dom/tree/webxr

msub2 commented 1 year ago

@tsturm Fantastic, will take a look at it later today.

msub2 commented 1 year ago

Rendering does indeed work on that branch, reset mine to it and fixed a small issue that was causing a DOMException. I do have a couple questions/thoughts:

rghv96 commented 1 year ago

Hello @tsturm @msub2 @andreasplesch, I tried to test this pull request and found issues which I have highlighted here https://github.com/x3dom/x3dom/issues/1245. Please let me know if I am missing something to resolve the issues.

msub2 commented 11 months ago

Closing now that https://github.com/x3dom/x3dom/commit/18cf88c7d3fec2719846d055a4433018396a4b5a has been merged