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

Fix iOS NativeCamera texture pixel format #1125

Merged

Conversation

docEdub
Copy link
Contributor

@docEdub docEdub commented Aug 26, 2022

The BJS side creates the texture and specifies the format (as RGBA8, in NativeEngine.createDynamicTexture), and then the native side overrides the texture handle in the Graphics::Texture, but the other properties (including format) are not updated, so the format (BGRA8) is incorrect, and operations like readPixels won't work.

This change fixes the issue by using a shader to convert the camera's YpCbCr format into RGBA, similar to how it's done in XR.mm.

Related issue

#1107

@docEdub docEdub marked this pull request as draft August 26, 2022 01:09
@docEdub
Copy link
Contributor Author

docEdub commented Aug 26, 2022

Converted this to a draft because it's not up to date with Alex's latest changes. I'm not 100% happy with it yet but I'd like to get some eyes on it to make sure I'm not doing something dumb.

The "best" prefix in the `bestPixelFormat` local variable name only makes sense for the current iOS implementation. It doesn't make sense on macOS since we're not selecting a "best" device. On macOS we're selecting the default device.

This change updates the local variable name so it makes sense for the current implementation on both iOS and macOS.
@docEdub docEdub marked this pull request as ready for review August 31, 2022 17:14
@docEdub
Copy link
Contributor Author

docEdub commented Aug 31, 2022

This is now working for macOS again and is ready for merge if there are no more changes needed.

@docEdub docEdub enabled auto-merge (squash) August 31, 2022 17:18
@docEdub docEdub merged commit 235552a into BabylonJS:master Sep 6, 2022
@docEdub docEdub deleted the 220825-webcam-video-texture--arc-on-2 branch September 7, 2022 00:01
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.

3 participants