-
-
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
support direct use of gpu frames such as from webcodecs by library users #29528
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Do you mind sharing more details of your use case and how you're using this? |
I use the webcodecs api to decode video frames and use those as textures in a three.js scene. |
Can you share some example code? |
We want to move away from the The engine has kept the usage of However, it is not recommended to use |
This would be extremely cumbersome tbh, we really want to just directly use the webcodec images |
And these are effectively video textures, but with more control. If you block this you effectively make threejs incompatible with webcodecs (minus cumbersome workarounds). All this while the required change is very minimal |
@maddanio for us to consider making changes to support webcodecs (whether these proposed changes, or others), I think we would need to have example code as requested in #29528 (comment). Otherwise we don't know how to test this and cannot safely maintain it. Keep in mind that while your PR is indeed minimal, you are also implicitly asking three.js maintainers to maintain support for this flag indefinitely. We will have respond when users ask why color management breaks when the |
Ok, I just checked again, and there is a very significant performance boost in using images from the webcodecs api as texture with my patch, so it is extremely relevant for us. In general, is (good) webcodecs not something that is desired by three.js? I mean, you already have VideoTexture, and now there is a better api that allows way cooler applications (streaming, live stitching, inter-stream sync etc). I fully understand wanting an example and will make one today or tomorrow. |
ah, actually this would be for canvas texture I guess, because it always has this problem due to the bug. |
Could you make it somehow work with if you derive a class from |
ok, I added an example that showcases the performance. you can switch by setting isGpu to true/false. results depend on bowser. on my old machine there is maybe a 20% difference in chrome but a 200% difference in safari. |
I will look into the subclassing idea |
hmm, actually, yes, it feels rather hacky, but just using videotexture would actiually work. I still think it should be clearer/more documented |
yes, using videotexture works, feels quite hacky, but works. so guess we can bury this pr. still think it would make sense to add something documenting the fact. should I make a pr for that? |
I could also make a VideoFrameTexture that has a nicer interface and also effectively serves as documentation |
I'm curious how the API would look like. Could you sketch a PR for that? That would help us to better understand your use case. |
I just changed the commits on my branch, so you can see it directly here now. also added some documentation |
hmm, this pr didnt update...will make a new one then :) |
Description
This introduces a user accessible isGPU flag that avoids pixel storage allocation and forces use of only the TexImage api. Previously this was only conceived for the VideoTexture class of three.js, but it is also desirable for example when using the WebCodecs api and feeding resulting frames to three.js