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

Support for KHR_materials_variants #11631

Open
javagl opened this issue Nov 16, 2023 · 0 comments
Open

Support for KHR_materials_variants #11631

javagl opened this issue Nov 16, 2023 · 0 comments

Comments

@javagl
Copy link
Contributor

javagl commented Nov 16, 2023

tl;dr:

KHR_materials_variants is a ratified glTF extension that allows defining different material variants for meshes. The extension defines a set of 'variant names' that can be activated. For each mesh primitive, the extension defines the material that should be used when a certain variant is activated.

Cesium MaterialVariants Demo

It should be possible to extract the information about material variants from a glTF asset, and select the active material variant in CesiumJS, switching the material/textures at runtime.


Related:


The first step would be to transport the information about the KHR_materials_variants extension through the Model.fromGltf loading process. This may already raise some tricky low-level questions (e.g. whether the textures should be loaded immediately, or only when a certain material variant is activated), but should be doable

Based on that, one could expose the information about the material variants on an API level. Clients should be able to do basic things like

const materialVariantNames = model.getMaterialVariantNames();
model.setActiveMaterialVariant(materialVariantNames[i]);

in a sandcastle. (Eventually, there might even be a UI for that)


Support for material variants on a tileset level:

The issue in cesium-native describes a concept for storing material variants information on the level of a tileset. The summary is:

  • The tileset JSON contains metadata that includes an array of strings with the TILESET_MATERIALS_VARIANTS_NAMES semantic
  • These strings are the material variant names that are expected to be present in all glTF assets that are used as the tile content in this tileset
  • Setting a certain "active" material variant on the level of the tileset will activate this variant in all glTF tile contents that are currently loaded for that tileset
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

2 participants