-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebXR Raw Camera Access #5780
Comments
Below is an example of an potential API. It implements access to views that session has. // constants
// it comes from XRView eye property
XREYE_NONE = 'none' // usually it is a mobile screen
XREYE_LEFT = 'left'
XREYE_RIGHT = 'right'
// pc.XrManager
xr.views // XrViews object that provides access to views
xr.start(camera, pc.XRTYPE_AR, pc.XRSPACE_LOCALFLOOR, {
cameraColor: true // new option to enable access to camera color information
});
// pc.XrViews
// this class represents number of views, their capabilities and access to individual views
views.supportedColor // true if color information is supported
views.availableColor // true if color information is available.
// It can be supported but not available due to lack of session eatures request or e.g.
// Quest 3 - implements necessary features, but does not expose `camera-access` to users.
views.get(eye) // returns XrView or null based on XREYE_*
views.list // an array of XrView instances
views.size // number of views
views.on('add', (XrView) => { }); // event when new XrView is added
views.on('remove', (XrView) => { }); // event when XrView is removed
// pc.XrView
// this class represents a specific view with its data
view.eye // returns a string (constants XREYE_*). 'none' - means it is not an eye, and
// most likely is a mobile screen
view.textureColor // returns a texture with color information. If color information is not
// available, texture will be blank 4x4 Example of how to request access to camera color: app.xr.start(camera, pc.XRTYPE_AR, pc.XRSPACE_LOCALFLOOR, {
cameraColor: true
}); Example of how to subscribe to access camera color: const views = app.xr.views;
if (views.supportedColor) {
// camera color might not be supported
app.xr.on('start', () => {
if (!views.availableColor) {
// camera color might be unavailable
return;
}
views.on('add', (view) => {
// get access to color texture
const texture = view.textureColor;
});
});
} Example of how to access camera color with already running XR session and available views: const views = app.xr.views;
if (views.supportedColor && views.availableColor) {
const viewMobile = views.get(pc.XREYE_NONE);
if (viewMobile) {
const texture = viewMobile.textureColor;
}
} |
I'm experiencing a challenge with the implementation, as Camera Access introduces "Opaque Texture" concept, which provides a WebGL texture that only lives for the duration of the requestAnimationFrame and should be unbound from the program (shader) at the end of animation frame. Also it is provided flipped vertically, I guess not much we can do about it without re-rendering? |
I need to do a similar solution to the video texture for WebGPU, which is valid only within the animation frame .. so perhaps we can find a single solution here. #5691 My current thinking was to do a copy to a normal texture to avoid this limitation. You could even do a flip during that time. Not ideal though. |
Copying is probably a good first solution, as it will allow us implementing API, and if performance is an issue in the future, we can think of direct use optimisation. |
At the moment probably just use drawQuadWithShader, that's probably the easiest. |
I've tried implementing it using framebuffer blit: https://github.com/playcanvas/engine/pull/5786/files#diff-4b7c531868727cdd27e21051721e99f838516832cf4d1ea1135c8719b8494d60R241-R295 |
I commented on PR. I'd prefer we do not use GL directly in XR. |
Since Quest 3 got released, it gets access to camera's raw textures.We would want to have an API that gives an easy and integrated way to access and update such textures.
Specs: https://immersive-web.github.io/raw-camera-access/
EDIT:
Android has access to raw camera texture.
The text was updated successfully, but these errors were encountered: