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

KTX textures in model are not loading properly #12397

Open
jak983464779 opened this issue Dec 27, 2024 · 6 comments
Open

KTX textures in model are not loading properly #12397

jak983464779 opened this issue Dec 27, 2024 · 6 comments

Comments

@jak983464779
Copy link

What happened?

Loading a gltf model Some textures do not load properly, and some textures can be displayed
image
in threejs:
image

Reproduction steps

...

Sandcastle example

No response

Environment

Browser: chrome
CesiumJS Version: 1.124
Operating System:

@javagl
Copy link
Contributor

javagl commented Jan 1, 2025

A first diagnosis step could be to drag-and-drop one of the models into the glTF validator at https://github.khronos.org/glTF-Validator/ to see whether it contains any errors, and to look at the Developer Console (by hitting F12 in Chrome or FireFox) to see whether it prints any error messages. If there are no errors or messages: Can one of the models be shared? (Maybe publicly, but in doubt, privately?)

@ggetz ggetz added the needs feedback On hold until additional info is supplied label Jan 2, 2025
@ggetz
Copy link
Contributor

ggetz commented Jan 2, 2025

Thanks @javagl for the tip!

@jak983464779 To confirm the model's validity, please run it through the glTF-Validator tool and let us know the results.

@javagl
Copy link
Contributor

javagl commented Jan 8, 2025

The model does generate some error messages. These should be fixed.

But these errors are unrelated to the issue here.

And unfortunately, the issue seems to be somewhat more fundamental. CesiumJS simply does not display some of the KTX textures. I pulled out two textures (one that is displayed, and and that is not displayed) and put them on unit squares:

Cesium issue 12397 KTX not displayed

In the left part, there is a completely black square for that glTF in CesiumJS (below the visible one - a bit hard to see in the screenshot)
The same glTF is displayed properly in https://gltf-viewer.donmccurdy.com/ and https://gltf.report/
The same glTF is not displayed properly in https://sandbox.babylonjs.com/ - it also shows a black square there.

Here are the glTF files and the test sandcastle:

CesiumJS 12397 KTX texture not displayed 2025-01-08.zip

From looking at the basic properties of the KTX files, there was nothing that could explain the different behavior for me:

Cesium issue 12397 KTX not displayed values

But interestingly, when running ktx info on both of them, then it did report

  • no error for the one that is not displayed
  • an error for the one that is displayed

🤪

Specifically, the error one that one that worked is

error-4001: Invalid Level Index. Indices must be sorted from the largest level to the smallest level.
    Indexes for level 8 with byteLength 3 and level 9 with byteLength 4 are incorrectly ordered.
warning-5004: Non-conformant texture file accepted by libktx.
    KTX 2.0 file does not conform to the specification but it is currently accepted by libktx.

The output attached here, just for convenience...

_info_texture_01-broken.txt
_info_texture_02-ok.txt


EDIT: One random thought that I had was that it might be the combination of that KTX file having MipMaps, and not being square at the top level. That's not a profound or justified guess, but just ~"the only 'structural' difference'" that I saw between these files...

@ggetz ggetz added category - model and removed needs feedback On hold until additional info is supplied needs triage labels Jan 8, 2025
@ggetz ggetz changed the title Model textures cannot load properly KTX textures in model are not loading properly Jan 8, 2025
@jak983464779
Copy link
Author

Strangely enough, I modified gltf samplers to display textures normally。

Normal

image

Abnormal
image

normal.zip

@javagl
Copy link
Contributor

javagl commented Jan 13, 2025

So there's more evidence that it is related to the MipMapping. I wondered whether there is any connection to #9876 (see the bottom of that PR for some related issues/PRs that came up recently). At least, I could imagine that the fix for this issue may affect a similar area of the code.

EDIT: Just for convenience:

The screenshots suggest that it did not work for minFilter=9987, which is GL_LINEAR_MIPMAP_LINEAR. but it did work for minFilter=9729, which is GL_LINEAR.

The MipMap levels of the texture look fine, though:

Cesium Issue 12397 MipLevels

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

3 participants