-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Import/export GLTF extras to node->meta
and back
#86183
Conversation
Please open a proposal to discuss the need and use cases for this feature |
Thanks, looks like there is one in godotengine/godot-proposals#8271, so I'll try to reuse that one |
I tested it with a sample scene and overall it works well but I noticed a few things:
|
acfb4fc
to
d26cf93
Compare
@noidexe I've uploaded new version
|
Part of my goal is that meta import and export is symmetrical for gltf. Let me know if thats too much or you agree. |
I was thinking the same thing. I wanted to add a test that creates a scene, serializes it to gltf, deserializes it and checks it has the right meta, but the fact the mesh re-generation is happening in ResourceImporterScene makes testing it hairy. I also don't understand github too much, so thought I was not including it in this PR, but somehow my in-progress stuff got attached - ignore it for now, I'll try to figure out. |
I feel bad for having you review this, apologies. I meant to say in my last comment that it needs more work - especially the test change, which I did not want to attach at all. I guess I should mark it as draft? |
5d47d41
to
e59dac2
Compare
I've added both import and export as discussed in #86183 (comment) and added a test it works as expected. I haven't found any import/export testing to take inspiration from - it might be my unfamiliarity with Godot, but the test has to instantiate way more of Godot that I would like - the whole import process is extremely intertwined with Editor/Engine (and their subsequent dependencies). It's also not possible to do this in-memory, so a number of files (.gltf, .bin, .scn) get written and subsequently read from disk during the test run, which I'm not happy about. Please take a look, cheers |
@demolke Please review the CI failure and resolve all issues until the CI turns green. Only then is it ready for human review. |
I understand what you mean, but from my perspective, the glTF format provides the possibility to include extra properties, and it is the engine's job to read this format and import it in the best possible way. Godot already does things like transforming specific names into certain nodes (e.g., Not only Blender but any program can export such extra properties in a glTF file. From my perspective, it would be interesting for Godot to offer the possibility of using this to its advantage since it treats each property uniquely. However, I understand that this is a sensitive decision and may diverge from the principles that Godot upholds. |
These are existing hacks that were "grandfathered in". Node name suffixes are not as flexible, and they're not standardized across engines, and they aren't something we want to add more of in the future. They aren't actually even part of Godot's GLTF code, they exist in the scene importer in general, for all scene-imported file types including GLTF, FBX, Collada, etc. EDIT: Also note, this means it only works in the editor, the suffixes don't work for runtime imports. |
Got it, and thanks for the explanation. I didn't know that Godot had 'changed its view' regarding these 'hacks'. It makes a lot of sense not to continue with these practices. Initially, I saw potential in this type of solution, but now I can see the problems it could cause and how certain features could be difficult to remove later. |
Sorry i'm a beginner in all of this (github/source code) i want to try out this feature so i should probably compile godot from source but i still have to wait until it's merged right ? |
See here for instructions |
I already reviewed this, but Aaron asked me to take another look. I think it looks good. I'd be okay merging this in its current form and iterating on it if needed. Some feedback on @lgxm3z 's comment.
It's not that important: I think if the data is in the file it's okay to import it; and if it's in extras it's okay to export it.
I would rather work on this as extensions: I see some value in supporting additional engine functionality, but it's also non-obvious behavior and given that most properties are supported as part of the gltf spec, it will be confusing to users which properties need to be specified using extras.
Finally, I'm confused which objects support extras. In glTF, just about anything can have extras. In this PR, it's implemented for all types of nodes, but only meshes and material resources? Should we also add it to skins, animations and textures? Or should we add it only to nodes, not resources? |
In general I think it makes sense to import/export extras everywhere, but it doesn't need to happen all at once. If we miss anything, we can add it in later in another PR. So we could add it in this PR, or not, I'm good either way. |
Needs rebase, I tried building it locally and it failed compiling the tests with:
(implies building with |
This is useful for custom tagging of objects with properties (for example in Blender) and having this available in the editor for scripting. - Adds import logic to propagate the parsed GLTF extras all the way to the resulting Node->meta - Adds export logic to save Godot Object meta into GLTF extras - Supports `nodes`, `meshes` and `materials` (in GLTF sense of the words)
Done, thanks for taking a look.
I think eventually yes, all the resources should have extras supported - adding it to node vs adding it to mesh (or other resource) are distinctly different use cases. You could put generic information on the "enemy" mesh re-used everywhere and have specific extras on the node. Once this get submitted I would like to get consensus on the bones PR #87150 and then I can look into the other types. |
Thanks! |
Great work i've tested it and it just works™ i just have one question, when i import a .blend there is a root node that is made with the name of the .blend, what is this root node in blender ? |
we force the name of the blend file into the root node name |
So it does not correspond to anything on the blender side ? Then i should open a proposal to at least have the root node inherit the custom properties of the scene, because in an exported gltf you already have this data available. |
@warcaninos That root node corresponds to the Blender scene itself. Blender scenes allow multiple root nodes, which is incompatible with Godot scenes that have exactly one root node. The "proper" fix for this is to add a feature to Blender to allow it to optionally flag scenes as having a single root node. This is implemented in Godot here, it just needs Blender to add support for it. Meaning, you should open a proposal to Blender, not a proposal to Godot. |
Unless there is something i missunderstood, when you export a gltf scene from godot it doesn't get the metadata as extra. |
@warcaninos It only gets metadata named extras, not all metadata. |
I've tried metadata with the name "extras" wich automatically get called "Extras" with values of type |
@warcaninos Are you using the master branch of Godot (what will become Godot 4.4)? It's not in Godot 4.3. |
@aaronfranke I'm using 4.4 dev2 import extras does work so i assume exporting should work too. |
Should i open an issue about this ? |
@warcaninos I can't reproduce the problem. The scene in Godot: The exported file (formatted with Prettier): |
I switched to 4.4 dev 3 and i do not have this problem anymore. Thanks for your time. |
This is useful for custom tagging of objects with properties (for example in Blender) and having this available in the editor for scripting.
extras
all the way to the resulting Node->meta where it createsextras
dictionarymeta
/extras
dictionary into GLTFextras
nodes
,meshes
andmaterials
(in GLTF sense of the words)Closes: godotengine/godot-proposals#8271