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

Add additional hooks to GLTFDocument to support draco decompression via GDExtension #8576

Open
stuarta0 opened this issue Dec 3, 2023 · 5 comments

Comments

@stuarta0
Copy link

stuarta0 commented Dec 3, 2023

Describe the project you are working on

I started looking into writing a GDExtension for Cesium integration in Godot. Rather than including the cesium-native glTF IO alongside Godot's built-in support, it may be better to just use Godot's implementation. However, Godot doesn't support the KHR_draco_mesh_compression extension used in 3D Tiles.

Describe the problem or limitation you are having in your project

Regardless of using Godot's built-in glTF logic for Cesium, it would be useful to support the KHR_draco_mesh_compression extension when loading real-time glTF models from external sources. However, it doesn't appear that there's enough granularity in the hooks provided in GLTFDocument/GLTFDocumentExtension to properly support this feature being provided as a GDExtension.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add additional hooks during the load of a glTF file to allow a GDExtension to provide draco compression handling.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In GLTFDocument::_parse_gltf_state, the file is parsed in stages, but there are only a handful of places where GLTFDocument will iterate the registered GLTFDocumentExtensions to provide some additional handling.

To provide draco support in a way that the GLTFDocument can be agnostic to the extension, one approach could be to have a hook after the file is completely represented in Godot's data structures, but before data itself (images, meshes, etc), are loaded. Possibly just above this line. This could allow a GDExtension to update the GLTFState object by decompressing the draco compressed bufferViews, and update the relevant accessors for the mesh primitive.

Alternatively, changes could be made to _parse_meshes(), but I'm not sure there's a flexible way to achieve this, as the draco extension has requirements for the handling of accessors, in additional to the compressed buffer.

Keep in mind I'm new to Godot's codebase, so if this can be achieved via existing architecture, or if there are other concerns, please let me know.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Provide a completely separate implementation of glTF IO that supports draco.

Is there a reason why this should be core and not an add-on in the asset library?

The change described above is minimal and should allow the remainder of the feature to be provided via GDExtension.

@stuarta0 stuarta0 changed the title Add additional hooks to GLTFDocument to support draco decompression via GLExtension Add additional hooks to GLTFDocument to support draco decompression via GDExtension Dec 3, 2023
@fire
Copy link
Member

fire commented Dec 3, 2023

I prefer mesh opt’s implementation over draco. Whats your thoughts on that in core?

@fire
Copy link
Member

fire commented Dec 3, 2023

Seems like we need to support both.

@stuarta0
Copy link
Author

stuarta0 commented Dec 3, 2023

I'm not particularly familiar with mesh opt either, but it's less about preference and more about support for third party authored models using the draco extension.

If this feature is useful for others, I feel like it would be a good project to cut my teeth on. If not, I can still hack on it before attempting something much larger like Cesium integration.

In regard to Cesium, the more I dig into it the more I may just need to use their implementation anyway, since they have their own custom extensions for their use case, i.e. EXT_mesh_features, EXT_mesh_gpu_instancing, EXT_instance_features, EXT_structural_metadata.

https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/glTF

@fire
Copy link
Member

fire commented Dec 3, 2023

I have some interest in a few of those but I need to define sone principles that determines what is in core. however exposing integration points is doable.

@GeorgeS2019

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants