Skip to content

WebXR fix frustum culling (right eye)#7411

Closed
Maksims wants to merge 1 commit into
playcanvas:main_v1from
Maksims:webxr-frustum-fix
Closed

WebXR fix frustum culling (right eye)#7411
Maksims wants to merge 1 commit into
playcanvas:main_v1from
Maksims:webxr-frustum-fix

Conversation

@Maksims

@Maksims Maksims commented Mar 6, 2025

Copy link
Copy Markdown
Collaborator

Fixes #5787

This PR changes the way view projection matrix is calculated when in stereo XR, by constructing average view matrix and offsetting it slightly backwards. This solves an issue where in right view (eye) objects were frustum culled too early (at the edge of right eye's frustum).

There is potentially a better way, by constructing a frustum that is based on left plane of left's frustum and right plane of right's frustum, but I'm not that smart to figure it out 😃

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@willeastcott

Copy link
Copy Markdown
Contributor

I thought this was interesting:

https://computergraphics.stackexchange.com/a/8468

@Maksims

Maksims commented Mar 16, 2025

Copy link
Copy Markdown
Collaborator Author

I thought this was interesting:

https://computergraphics.stackexchange.com/a/8468

Perhaps a different method for culling (not frustrum) should be used in such edge cases. And that would be a separate PR.

@willeastcott

Copy link
Copy Markdown
Contributor

I think that over the 180 degree threshhold, you need to cull per eye. But below that, I think we simply need to have a Frustum#add or Frustum#merge function.

@Maksims

Maksims commented Mar 16, 2025

Copy link
Copy Markdown
Collaborator Author

I think that over the 180 degree threshhold, you need to cull per eye. But below that, I think we simply need to have a Frustum#add or Frustum#merge function.

As mentioned:

I'm not that smart to figure it out

Frustum#merge - would be great here, but bear in mind that this is not that simple, and in many cases, frustums are not mergeable.

For now, this PR improves a current situation, by removing culling issues on right eye on most XR devices I've tested. Future PR's can improve that. I believe that this issue been there for far too long, and decided to fix it within my mathematical abilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants