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

Single glTF model appears different colour when tiled vs original #12491

Open
scottmcnab opened this issue Feb 21, 2025 · 6 comments
Open

Single glTF model appears different colour when tiled vs original #12491

scottmcnab opened this issue Feb 21, 2025 · 6 comments

Comments

@scottmcnab
Copy link

What happened?

Using the Cesium Sandcastle 1.126 viewer, I noticed that a single glTF model is rendered with a very different colour tint when loaded as a tileset.json containing a single model file, compared to the exact same single model file loaded as a "tiled" tileset with implicitTiling enabled:

Image

Here are the tileset.json files used to generate each view (the model itself is omitted as it is confidential).

tileset-single-model.json
tileset-tiled.json

For the purposes of this test, I copied building.glb and renamed it to replace the top-level content_0__0_0_0.glb file. I also removed all the other .glb files so we can be certain that the model file is identical in both cases.

Can anyone please explain why the model should have a different colour appearance in the tiled case?
Is there a way to make the tiled case match the original non-tiled model?

Reproduction steps

  1. Create a tileset.json referencing a single glTF model.
  2. View the tileset using the Cesium Sandcastle viewer.
  3. Create another tileset.json referencing the same glTF model, but this time reference the content in the implicitTiling section (along with required .subtree files).
  4. Observe that the colour for the "tiled" tileset has a more muted / tinted hue than the original.

Sandcastle example

https://sandcastle.cesium.com/#c=hVNNb9swDP0rhLGDMySyu2LAkKbZR7thhwErlqy9+FDZZmxtsmhIcoI0yH+fZDlZlhXbJQrJ98jHDxekjIW1wA1quAaFG7hBI7qG3fe+OIuK3r4hZblQqLNoDLtMAVjU2nmmB8Iy2GylqXkgLcvBEY/GmdqPrjKVqVCImQIVskpSjqzE1tZLNPZ95cDGDiwnZsWlwaszUol5Vy1q2nzSvEFzh3qBBanS4a3usK9i9dZL9CKLvj8rJBq0DsM3XNiD4vBc3i5DuFf+XcvYEwGSJItqa9tpkkgquKzJ2OmbNL1MhnQTI1QlcdJQiZL9MKTeXrjpBPY/uccM/i3PqbvwoOK5xFvf74PQuPL9TsNQHDCzx0l8oE6VTso9ye4U4pMcQX5/qOx/sTckSYsn7GdyiLt2HGLvf/weAf5YSatFI6xYo2G8LOOht7DwI/SJqFnSMNoBMtQ9ObrPyL26O2GL+htXFQ4EgJSl48P/ScpeH40hF8uHzhZtjRqZdok6Ay/hFUsDdPRbvrtHKLirAbG7NtKjMHN/LCSRSarix48+AJJ6QYcqU3ix6xn7R59p7zJF42hm7Fbi/KDonWha0hY6d0qMJRabVnLrtp53xU+ntDAmyACYJafUWSnWIMrrZ745KCQ3xkVWnZQLt58sms8Sh/+LOij+ukYt+dbD6ov5l+BkjM0SZz7PtEQy5/os8y8

Environment

Browser: Microsoft Edge Version 133.0.3065.69
CesiumJS Version: 1.126
Operating System: Windows 11

@javagl
Copy link
Contributor

javagl commented Feb 23, 2025

I hope that this is not a red herring. But I noticed a strange effect that visually looks somehow similar in a very tiny test sandcastle:

https://sandcastle.cesium.com/index.html#c=xRj9c9o29F/R+MncqE0gTTPycRM07diSkAtJ1qz0esIWRKssc5ZMmu343/ckYywbO2Np7+YfsN/3h56envAjIRVaMvpIY3SCBH1EAypZErp3BudMGr6BB5FQhAkaTxot9PdEIDTn0ZT20IxwSVsTsWoeTcREzBLhKxYJ5MeUKHoWTmkQ0OBWMDVIpvQ9VzNHxURITjRbC8WRWn9Jn3DaTJX7xq+YyoQr8MvgECI+OCOjWPbQxxSDMpJ+pslsRmPteA+1Wxb+SdHRbCapKuL9KFxEggp187SASF7vdboFaiJAoHtg4ZRhnDTGA3yOryEVOSkkX8GrTveTjWMCcO0ctWr9i9t7L3L7YNvtzn6F23dng26F03tuu4Wynwr/NSX7+Q6xdA4P/8doXhlS/rsdUIYh0ri7iW5OofyJimJt/Nc5v3mHZnEUogelFrLneXOmHpKpCwF5f5IlmXPPMFkuLmksodS1fMdtbwiZ4TR5NcWdxEzLBUSRHlksOPPNtvHmsKNepZJHUyLpwX4LYzzA+Axe+C3GQ9zH+D3Gt/r9C8b3mvgbxl/0+xzjSDONMG7r9xXG+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yb+F6pcX8os0ceeLXocsCViwUnF/yDQk+GKCJRZwvmY/UUnjdNjD/i3RHlEdNMbwf2PkyfN9rB3ep4iXdc99gCsllRpbkqa/wE

It creates a simple embedded glTF asset and loads it (not even with a tileset being involved - just the model). And for very specific model configurations and very specific camera orientations, there's a strange difference in the appearance:

Image

Note that in that GIF, it is literally just switching from one model to another, where the differences between the models are only one rotation in one node of the glTF.

Based on the description (and given that we don't have access to the model from your screenshot), this might be unrelated to the issue here (but it looks very similar 👀 ). I hope that this sandcastle can either help to zoom into what might be wrong here, or ... it could be promoted into another issue.

@scottmcnab
Copy link
Author

I found a model that I can share the files for:

Image

The model files are here:

original.zip
tiles.zip

Note: I've copied the .glb file from the original to the content of the tiles version, so you can see that the appearance is different for the exact same model file.

To reproduce it locally, unpack the .zip files and run a local server:

http-server -a localhost -p 8003 --cors=http://localhost:8080/

Use the Sandcastle example above and adjust the tileset.json filename paths accordingly.

@scottmcnab
Copy link
Author

@javagl Can you reproduce the lighting issue using the sample tilesets uploaded above?

@javagl
Copy link
Contributor

javagl commented Feb 26, 2025

Yes. A plain comparison of the models shows the difference:

Image

(and for those who are about to investigate that: The GLB files in both cases are really identical!)

I then tried to do some side-by-side comparisonn, and ... I'm seeing some really strange effects there. Similar to the example with the "unit cubes" that I added above, the issue seems to be related to aspects of the model that I cannot yet put my finger on. Specifically, I noticed this:

Image

It's a bit subtle, but

  • It initially shows three tilesets
  • The leftmost ones are the "tiled" one, twice.
    • The color is wrong only for one of them (the leftmost one). That's strange enough
  • When slightly moving the middle one (by setting a tiny translation for the model matrix), then the wrong coloring goes away ... for the one that was not changed...

This seems to be related to the environment based lighting computations. But the fact that it affects unrelated models, depending on something as subtle as a node rotation in a glTF, leaves me stumped about where this might come from...

The sandcastle for the side-by-side case:

const viewer = new Cesium.Viewer("cesiumContainer", {
  globe: false
});

async function createTileset(name, yOffset) {
  const tileset = viewer.scene.primitives.add(
    await Cesium.Cesium3DTileset.fromUrl(
      "http://localhost:8003/"+name, {
      debugShowBoundingVolume: true,
    })
  );
  tileset.modelMatrix = Cesium.Matrix4.fromTranslation(
    new Cesium.Cartesian3(0, yOffset, 0));
}

await createTileset("original/tileset.json", -800);
await createTileset("tiles/tileset.json", 1);
await createTileset("tiles/tileset.json", -400);

viewer.scene.camera.setView({
  destination: new Cesium.Cartesian3(4494298.220637598, -499512.1207566406, -4483690.902301435),
  orientation: new Cesium.HeadingPitchRoll(3.237952644473686, -0.44609341377242284, 6.283175778644352),
});

@scottmcnab
Copy link
Author

Do you think it could have anything to do with these recent changes?

https://cesium.com/blog/2024/10/31/gltf-rendering-in-cesiumjs-pbr-improvements-and-khronos-neutral-tone-mapping/

If you compare these models with the aircraft image in that article, the colour difference looks like it could be explained by "ACES tone mapping" being applied to the tiled version, but "Khronos PBR Neutral tone mapping" being applied to the original model.

I don't know how this could be affected by changing the node transform however, unless there is some uninitialised state or shader constants and the node position changes mesh render order or something?

@javagl
Copy link
Contributor

javagl commented Feb 26, 2025

I'm on thin ice when it comes to the actual reasons. So with a grain of salt: The difference that is caused by tone mapping is usually really subtle - subjectively, much smaller than the difference that can be seen here or in that "unit cubes" example that I posted above. My gut feeling is that the changes around https://cesium.com/blog/2025/02/20/leveling-up-lighting-in-cesiumjs-ibl-dynamic-environment-maps-ambient-occlusion/ are a more likely candidate. And the strange dependency to ~"things that the appearance should not depend on" indeed looks like some unititialized state, missing update, or maybe a special case (like ~"some computation that is not done when something has an identity transform" or so). But ... these are all guesses. Maybe someone else can confirm them.

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