-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Should SharpGLTF throw an exception when an unsupported extension is required? #237
Comments
@BoyBaykiller I removed my previous comment since it was inaccurate. glTF makes a distinction between unknown
Looking at the code, |
Thats what I am currently doing with my custom extension - only put it in Other custom extensions might make schema updates. By throwing an exception, you are not allowing the user to process unknown But it's ok. I just wanted to hear your opinion on this. This is not supposed to be a bug report. You may close this. |
whether an extension is declared as used or required is really up to whether the model is correctly renderable on an engine unable to understand that extensions, but also to prevent the engine to crash with unrecognizable data, so how would you signal that to the engine that loads the model? The rule of thumb is that if it is safe for an engine to load your model without understanding your extension, it's probably fine to declare the extension as used. But if your extension changes things in a way that the engine would crash, or render the model so wrong that it would be unrecognizable, then it's when you would use the required. There's a tweak in the library, you can remove the validation at load time with one of the load extra parameters... but it disables -all the validation- which means you're in your own if there's issues. |
Ok. I've tried |
hmm... i'll take that into account, that validation is somewhat special |
Blender puts |
Do these models actually use the extension? Or blender exporter blindly adds the extension requirement even if it's not used? |
Yes, the model defines two variants. Use this Dragon Attenuation model to reproduce. It has |
I can't find any information that KHR_materials_variants should be set as "required".
I understand that it could be fine to load these models in this specific use case, but the glTF specification has "used" and "required" fields specifically to signal when you are safe to load the model and when not. So SharpGLTF is following the specification of refusing to load a model when it does not support an extension the model is signaling as "required". You might think that these models are safe to load anyway, but the library cannot know in advance when the model is "lying" about it, there's many required extensions that are really required and would crash or produce incorrect results downstream if loaded. It's responsability of the writer library to correctly signal what's used and what's required. As I said, I could consider removing the check when the Skip flag is set, but you must understand that what you're asking me is to break a feature that is working correctly in my library, because some other library is not following the standard correctly. Is there an open issue in the blender exporter library requesting to save Variants as used and not as required? |
I agree with everything you have said. The reason I would not let SharpGLTF throw an exception for unsupported extensions is not because I think that it's more correct, but as a form of leniency to avoid cases like this. I've opended a issue regarding KHR_materials_variants on the blender project. |
Reviewing the issue, there's an additional problem about allowing glTFs with unsupported but required extensions to load. When SharpGLTF encounters an unsupported extension, it has no way to deserialize it. , so instead, it stores the extension code as an "undefined" json.Node. This is fairly safe when the given extension is only "used". But for "required" extensions it means part of the data you might need to fully traverse the scene is "hidden" in these unknown json nodes.
Could you point me to the issue? so I can track it too? |
Currently SharpGLTF throws when an unsupported extension is required by a glTF file:
SharpGLTF/src/SharpGLTF.Core/Schema2/gltf.ExtensionsFactory.cs
Line 303 in b775097
Personally I think this is a bit of an overreaction. What if the user wants to process the extension themselves. What if it's a custom extension that will never be supported by SharpGLTF. glTF-Validator doesn't care if I specify an unknown required extension.
What do you think of this?
The text was updated successfully, but these errors were encountered: