Enable gltf crate KHR feature flags so models with extensionsRequired render - #1
Open
infinitelayerscc wants to merge 1 commit into
Open
Conversation
The gltf crate gates each KHR extension behind a cargo feature and rejects
any glTF whose extensionsRequired lists an extension it was not compiled
with, returning Validation([(Path("extensionsRequired[0] = ..."), Unsupported)]).
Because glimpse depends on `gltf = "1.4"` with default features only, models
that mark KHR_materials_unlit as required fail to load. load_from_bytes falls
through to the lenient Gltf::from_slice path, but that runs the same validation
and fails identically, so no thumbnail is produced at all.
This is common in the wild: Kenney's blocky-characters, retro-fantasy-kit and
retro-urban-kit all mark KHR_materials_unlit as required.
Enabling the flags is enough on its own; no code changes are needed, since the
existing material handling already reads base color and textures.
Measured over 99 real GLB files (86 Kenney models spanning 44 kits, 13 from a
personal project): hard failures dropped from 7 to 1. The remaining failure
requires KHR_mesh_quantization, which the gltf crate does not support and has
no feature flag for.
All 110 existing tests pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jv8DyjXuNjQBrCeRnBGDPE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for glimpse — it's the only current, purpose-built glTF thumbnailer I could find for Windows 11, and the software rasterizer is a genuinely good call.
The problem
The
gltfcrate gates each KHR extension behind a cargo feature, and rejects any glTF whoseextensionsRequiredlists an extension it wasn't compiled with:Since
Cargo.tomldeclaresgltf = "1.4"with default features only, any model markingKHR_materials_unlitas required fails to load entirely.The lenient fallback in
load_from_bytesdoesn't rescue it —gltf::import_slicefails, thengltf::Gltf::from_sliceruns the same validation and fails identically, so no thumbnail is produced at all rather than an untextured one.load_from_pathhas no fallback, so it surfaces as a hard error there too.This is common in the wild. Kenney's
blocky-characters,retro-fantasy-kitandretro-urban-kitall markKHR_materials_unlitas required. Note that models listing it inextensionsUsedonly (e.g.furniture-kit,nature-kit) load fine today — it's specifically theextensionsRequiredlist that's fatal.The change
One line, enabling the flags. No code changes needed — the existing material handling already reads base color and textures correctly once the document parses.
Measurements
Tested over 99 real GLB files — 86 Kenney models spanning 44 kits, plus 13 from a personal project — driven through
renderer::render_thumbnail:The one remaining failure requires
KHR_mesh_quantization, which thegltfcrate doesn't support and has no feature flag for. That one looks unfixable without upstream work ingltf-rs.All 110 existing tests pass.
Cargo.lockis unchanged by this — the features resolve withingltf-json, so the dependency graph is identical.Not included here
While testing I also found that external-texture models (Kenney kits reference a shared
Textures/colormap.png) render as untextured gray via Explorer, because the shell prefersIInitializeWithStreamand stream init has no directory context to resolve the URI from. Declining that interface so the shell falls back toIInitializeWithFiletakes those from gray to fully textured.I've left that out of this PR — it trades away process isolation and feels like it should be your call, likely an installer option rather than a default. Happy to open it separately if you'd want it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Jv8DyjXuNjQBrCeRnBGDPE