-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Allow GLTFLoader to use ImageBitmapLoader #19518
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should give this a try. When merged, I can update the docs and TS files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks you!
It's worth noting that ImageBitmapLoader depends on three.js/src/loaders/ImageBitmapLoader.js Line 69 in 400acd3
...which could be a problem for some users who specify them. We should probably try to pass those request parameters into the |
Starting with
I think it may be better to try to implement glsl based Y-flipping and then implement this right in |
An alternate route to adding this would be to have the glTF loader internally use TextureLoader on browsers that don't support ImageBitmaps and ImageBitmapLoader + CanvasTextures on browsers that do. That felt messier to me, but if we're trying to keep new API surface off of TextureLoader at all costs it's a more self contained approach. |
I'd be OK with @toji's suggestion of just putting it on GLTFLoader for now, without a new API. Might be a safer place to start, and see if there are any browser support edge cases we've missed? |
Sounds good! |
Fixes mrdoob#19511 This is one potential approach for allowing GLTFLoader to utilize ImageBitmaps, which significantly reduce stalls in rendering when uploading textures to the GPU. Alternatively, if allowing a custom ImageLoader to be supplied to the TextureLoader is not desirable, we could use ImageBitmapLoader and CanvasTexture in this class directly when ImageBitmaps are supported and fallback to TextureLoader otherwise. The reason this is limited to GLTFLoader for now is that ImageBitmap-based textures don't support Y-flipping in the same way that the traditional approach does. If a workaround is figured out for that then ImageBitmaps could be used more widely.
Doesn't add additional API surface to TextureLoader
Okay, updated the PR to a variant that doesn't alter |
Okay! |
Thanks! |
Should have a user-facing option to disable the ImageBitmapLoader? I wonder if there may be other browser compatibility issues... |
I've tested Safari too. Seems like it's not shipping |
Ooof, sorry about that! I know @fernandojsg and @daoshengmu and @takahirox were looking into this, e.g., for: |
Blech. Sorry for missing the premultiplied alpha bit, but I'm glad the fix was trivial. And yes, Safari hasn't shipped |
Fixes #19511
This is one potential approach for allowing GLTFLoader to utilize ImageBitmaps, which significantly reduce stalls in rendering when uploading textures to the GPU. Alternatively, if allowing a custom ImageLoader to be supplied to the TextureLoader is not desirable, we could use ImageBitmapLoader and CanvasTexture in this class directly when ImageBitmaps are supported and fallback to TextureLoader otherwise.
The reason this is limited to GLTFLoader for now is that ImageBitmap-based textures don't support Y-flipping in the same way that the traditional approach does. If a workaround is figured out for that then ImageBitmaps could be used more widely.