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
Move GetTextureDataAsync from inspector to core #14312
Conversation
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/14312/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/14312/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/14312/merge#BCU1XR#0 |
This code copies an existing texture (compressed or not) to a non-compressed RGBA texture, which is not what we want in the exporter (the exporter is already able to export compressed textures, but it exports the result of the expansion to RGBA 8 bits to a .png file, not the original compressed data). [EDIT] To be able to export compressed textures in their compressed form, we would need to be able to retrieve the compressed data, which is not possible because https://playground.babylonjs.com/#E6WY1N You will get this error in the console log: [.WebGL-00002DB408078E00] GL_INVALID_FRAMEBUFFER_OPERATION: Framebuffer is incomplete: Attachment is not renderable. And the buffer will be all zero. Even if that worked, you would only get the transcoded data that was suitable for the target GPU when the texture has been created, whereas you would need the non-transcoded data for the export. Regarding the function itself, I'm not sure we should move it into the misc tools, as it seems quite specific to the inspector... cc @sebavan for his opinion. |
If the decision is whether or not the texture is exported, this seems to be a viable solution My EDIT - just saw YOUR edit :-). This can be ignored. |
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.
LGTM. I agree with @Popov72 regarding the inspector-only code, which should stay in the inspector
Yeah, just to clarify, as you found the glTF exporter does not handle GPU compressed textures now. There is a related issue here: #12257 So the idea with this helper function would be to render out a copy of the compressed texture as RGBA. (I have tried a local version of this and it does indeed work. The 'compressed' texture gets serialized as a png) |
I think this is ready to merge. |
This is a refactor that will eventually enable a serializer like GLTFExporter to use the now core-based
GetTextureDataAsync
in order to serialize textures that are not directly retrievable as RGBA e.g., GPU-compressed formats.For more discussion on that point, see #12257. The part that is missing to ultimately solve this is some sort of function or BaseTexture-property that can tell whether the texture uses a GPU compressed format. Once that exists, then it should be easy to do something like this... from
glTFMaterialExporter.ts
: