filament
filament copied to clipboard
SheenCloth sample model crashes gltf_viewer with assertion
Describe the bug Debug builds of gltf_viewer crash when loading the SheenCloth.gltf sample model.
in void utils::panic(const char *, const char *, int, const char *):32
in file ../../libs/utils/src/debug.cpp
reason: ../../libs/gltfio/src/FilamentAsset.cpp:130: failed assertion `info.bindings.size() == 0 || info.flags == flags'
To Reproduce Steps to reproduce the behavior:
- Build gltf_viewer for debug
- Download the SheenCloth glTF 2.0 sample model.
- Load the SheenCloth.gltf model into gltf_viewer
Investigation
A comment above the assertion reads:
// All bindings for a particular glTF texture must have the same transform function.
However, as seen with SheenCloth.gltf, this isn't always the case.
In the SheenCloth model, sheenColorMap (which wants a sRGB texture), and sheenRoughnessMap (which wants a linear texture) could both map to the same glTF texture.
In that case, one solution is to create two copies of the texture: one sRGB, and one linear. This, however, doubles the required texture memory.
Desktop (please complete the following information):
- OS: macOS
- Backend: All backends
Or maybe we could do the conversion in the shader for one of the input when they are mixed. With spec constants, this could even be "free" when both match.
Yeah, I was thinking of something along those lines could work too. I think this is a somewhat rare edge-case.
maybe in the meantime, we could do something to avoid the crash (and I guess get bad roughnessMap instead), and downgrade this bug to "correctness" from "crash"?
Yeah I'm fine with that