Skip to content
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

[XR] Implementation of WebXR Depth Sensing Feature #13159

Closed
wants to merge 10,000 commits into from
Closed

[XR] Implementation of WebXR Depth Sensing Feature #13159

wants to merge 10,000 commits into from

Conversation

drumath2237
Copy link
Contributor

Add a WebXR Feature of Depth Sensing Module.

Related issue is #11876

Related forum page is here.

carolhmj and others added 30 commits September 27, 2022 16:52
* correction

* make ref 0 vector
…enshot with RenderTargetTexture, because we can just set the RTT active camera instead.
[GUI] add picking for fullscreen ADTs
Fix creation of cube textures from URL
* Start command bar on VSM.

* Update Storybook to 7

* Modularizing CSS

* Match style with GUI Editor

* More basic declarations and styling.

* Text styling and removing unused styling

* Removing more styling

* Remove more unneeded stuff

* Linting...
* Remove unneeded prefixes

* further prefix removals

* fix build

* fix the running tests
Add applyPostProcess flag on ADV to optionally draw it after the post…
* fix declaration generation

* formatting
Fix wrong plugin name check for babylon serialization
Popov72 and others added 10 commits October 24, 2022 11:54
* Fix samples support in render targets

* Add labels to some WebGPU descriptors

* Remove unused code

* Fix code injection at start

* Add some more logs

* Fix usage of destroyed textures

* Fix reentrancy problems with observables

* Remove unncessary call (and fix problem in WebGPU)

* Create the RTT with the right samples from start

* Fix uniform analysis in WebGPU

* Fix reserved keyword (in WebGPU) used as variable

* Factorize visualization test code and fix some tests

* Fix visualization test

* linting
ParticleSystem: Add BILLBOARDMODE_STRETCHED_LOCAL mode
Fix loading the gltf loaders and validations twice
@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

@sebavan sebavan requested a review from RaananW October 25, 2022 14:01
@drumath2237 drumath2237 marked this pull request as ready for review October 25, 2022 18:31
Copy link
Member

@RaananW RaananW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for thie PR! Great work :-)

We try not to provide the dev directly with WebXR objects but abstract the usage as much as we can.

For example - CPU usage, it seems like we can "init" the XRCPUDepthInformation object internally, and then, once available, provide the getDepthInMeters directly, or at least abstract that to the dev.

Regarding GPU, we should not provide a WebGL2Texture to the user, but a babylon texture that the user can use. Internally, the user can have access to the internal texture, but the public API should be a babylon object and not a WebXR/WebGL object.

We should provide something extra to the dev, otherwise there is no difference between using the feature and implementing it yourself.

@drumath2237
Copy link
Contributor Author

@RaananW
Sorry for very late reply.

I've thought about API specification of the WebXRDepthSensing feature and managed to draw a proposal.

image

The parameters of XRDepthInformation are exposed directry for example width, height, and rawValueToMeters.
These are acquired from cached XRDepthInformation internally.

And specific fields of XRCPUDepthInformation and XRWebGLDepthInformation are provided as nullable data.

When the Usage is 'cpu-optimized', we can access data field as ArrayBuffer.

interface XRCPUDepthInformation extends XRDepthInformation {
    readonly data: ArrayBuffer;

    getDepthInMeters(x: number, y: number): number;
}

This type of array can be changed by depth information data format between luminance-alpha and float32.

When the usage is 'gpu-optimized', we can access texture field as WebGLTexture.
I assumed that WebGLTexture can be convert to InternalTexutre and wraped by RawTexture.
(I'm not sure this is correct and best way. So, please fix if I'm wrong.)

Maybe, when the usage is 'cpu-optimized', we can generate RawTexture from ArrayBuffer.

How do you think abou this?

@RaananW
Copy link
Member

RaananW commented Nov 7, 2022

Maybe, when the usage is 'cpu-optimized', we can generate RawTexture from ArrayBuffer.

Yes to all! :-)

We should use a texture instead of a webgl texture, so that the dev will be able to use it in a babylon material or use it just like any other texture on both gpu and cpu optimized

This type of array can be changed by depth information data format between luminance-alpha and float32.

Those will need to be configurable in the options (if it's not already the case).

getDepthInMeters should also be exposed from the module itself, and throw if not available (for example in a gpu-optimized scenario, if I understand correctly)

@sebavan
Copy link
Member

sebavan commented Nov 18, 2022

@drumath2237 any update on this PR :-) It looks like a really cool feature.

@drumath2237
Copy link
Contributor Author

@sebavan
Sorry, I couldn't worked on it these days...
Once, I'll turn this PR to draft PR.

@drumath2237 drumath2237 marked this pull request as draft November 22, 2022 13:14
@RaananW
Copy link
Member

RaananW commented Dec 9, 2022

I have to close this PR because of the repo cleanup. Let's open it again from a clean branch

@RaananW RaananW closed this Dec 9, 2022
@drumath2237 drumath2237 deleted the feature/webxr-depth-feature branch December 9, 2022 12:02
@drumath2237 drumath2237 restored the feature/webxr-depth-feature branch January 4, 2023 09:12
RaananW pushed a commit that referenced this pull request Mar 3, 2023
…#13563)

* add: definitions of type and interfaces of depth sensing feature

* add: native XRFrame method

* add: WebXR Depth Sensing Feature class implementation

* Add implementations exposing DepthInformation fields and methods

* Remove depth information observers

* Add an implementation of generate RawTexture from cpu depth information

* Add and fix implementations of texture generation

* Fix implementations of texture generation of cpu mode

* Add process depth information method

* Add documentation comments and fix naming

* Fix import paths

* add: latest depth buffer field

* fix: change Texture format to RGBA and create depth texture

* add: sandbox impl of luminance-alpha depth image texture

* Change Texture format from LuminaceAlpha to RTexture

* Fix cpu depth image processings

* Change image processing implementations

* Rename _latestDepthImageTexture to _cachedDepthImageTexture

make a difference between public latest data and provate cached data

* Changed depth texture pixel algorithm

* small refactor of obtaining rawValueToMeters

* Add getDepthInMeters observer to notify active one

* Fix comment of webxr.d.ts

* Fix formatting errors

* Change null union types to Nullable generics

* changed to returning InternalTexture instead of WebGLTexture

* Define original depth types to avoid using XR native type

* Create individual private fields of public fields

* add @SInCE to docs comment

* detach if depth usage is unknown

* throw an error in nativeXRFrame depth method until the functionality is implemented

* correct some docs comments
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.