-
Notifications
You must be signed in to change notification settings - Fork 1.2k
The KHR_materials_variants extension #1681
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
Merged
emackey
merged 26 commits into
KhronosGroup:master
from
zellski:ext/zell-fb-asset-variants
Aug 26, 2020
Merged
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b529179
Initial draft.
ebe3189
Updates.
9033116
Consistant naming.
ee0d8ad
Rename back, tweak.
b7c68e3
Tweaks.
fd070c3
Some further verbiage.
92771ff
Add formal schema.
ca97835
Merge branch 'master' into ext/zell-fb-asset-variants
69b7edf
Merge remote-tracking branch 'upstream/master' into ext/zell-fb-asset…
8e5d8b1
Language tweaks, update Renee's contact info.
f0ab429
One more try.
a9bee21
Clarifications, expansion.
23915e9
Rename as khronos extension KHR_variant_materials
jercytryn 07c109b
Rename extension KHR_variant_materials -> KHR_materials_variants
jercytryn 46b16fc
Fix typos, non-normative disclaimers, and clarify tag order behavior …
jercytryn 17fe9bd
Simplify extension to focus on wholesale static variant configuration…
jercytryn 910746f
Fix example melded models
jercytryn b84ae8a
Clarifying note on no active variant
jercytryn fc9b8d9
Update README.md for alt text.
60be860
Apply 3D Commerce patch to schemas and spec.
09a22ce
Updated README, removed examples, and fixed mappings in spec along wi…
sleroux 26d2629
Add new language defining mappings usage within viewer applications
jercytryn 8543426
No relative paths and fix typo
jercytryn 9bc4e4e
Bridge verb
jercytryn 9049ea8
Change to top-down language to describe the specifics of the schema p…
jercytryn 8af11ea
one more try
jercytryn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
extensions/2.0/Khronos/KHR_materials_variants/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # KHR_materials_variants | ||
|
|
||
| ## Contributors | ||
|
|
||
| - Mike Bond, Adobe, [@Miibond](https://github.com/MiiBond) | ||
| - Aurelien Vaysset, [Emersya](http://emersya.com) | ||
| - Pär Winzell, Facebook, [@zellski](https://twitter.com/zellski) | ||
| - Renee Rashid, Facebook, [@debuggrl](https://github.com/debuggrl) | ||
| - Jeremy Cytryn, Facebook, [@jercytrn](https://github.com/jercytryn) | ||
| - Edgar Simson, OLV, [@Edzis](https://github.com/edzis) | ||
| - Daniel Beauchamp, Shopify, [@pushmatrix](http://github.com/pushmatrix) | ||
| - Stephan Leroux, Shopify, [@sleroux](http://github.com/sleroux) | ||
| - Eric Chadwick, Wayfair, [@echadwick-wayfair](https://github.com/echadwick-wayfair) | ||
|
|
||
| ## Status | ||
|
|
||
| Draft | ||
|
|
||
| ## Dependencies | ||
|
|
||
| Written against the glTF 2.0 spec. | ||
|
|
||
| ## Overview | ||
|
|
||
| This extension allows for a compact glTF representation of multiple material variants of an asset, structured to allow low-latency switching at runtime. | ||
|
|
||
| A typical use case is digital commerce, where a user might be presented with e.g. a pair of sneakers and the ability to switch between different colours. | ||
|
|
||
|  | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Design Goals | ||
|
|
||
| _This section is non-normative._ | ||
|
|
||
| This extension aims to give asset creators and consumers a compact way to define multiple materials for a common set of geometry nodes in a glTF document. We explicitly optimize for the case of representing material variants which are: | ||
|
|
||
| * **finite** - the list of variants is bounded; multi-dimensional variants (e.g. color + texture) are possible but must ultimately be representable as a flattened list | ||
| * **premade** - the variants are produced at asset authoring time | ||
| * **holistic** - while composable, the variants are defined at the granularity of the glTF asset; sub-variants or hierarchical variants are not considered | ||
|
|
||
| In digital commerce, each variant may correspond to a distinct SKU or stocked product code, which naturally meet these requirements. In games or movies, each variant may represent a fixed set of curated asset skins which can be represented, moved across the wire, and loaded efficiently. | ||
|
|
||
| A non-goal of this extension is to serve _configuration authorship_ use cases (i.e. configuration builders or "configurators"). These have a separate set of concerns, are more subject to complex application-specific business logic, and may benefit from dynamic and continuous configurability with complex builder rules. | ||
|
|
||
| While not designed around this use case, we note however that this extension does implicitly communicate at the primitive level which materials are available for that primitive, for any such applications which may be interested in leveraging this information. | ||
|
|
||
| ## Material Variants | ||
|
|
||
| A _material_variant_ is a set of mappings that determine which material can be applied to a given primitive. Consider a model of a shoe where three meshes are defined along with two materials. These meshes contain an assortment of primitives that have an associated material attached. | ||
|
|
||
| Imagine a sneaker with shoelace holes that are made from materials that depend on the overall shoe colour in non-obvious ways: | ||
|
|
||
| | Meshes to Skin | Available Materials | | ||
| | ---------------------------------- | ------------------------------- | | ||
| | `laces` | `white_matte` | | ||
| | `body` | `red_matte` | | ||
| | `sole` | | | ||
|
|
||
| In one variant of the shoe, the primitives associated with each mesh listed below would have the following materials assigned to them: | ||
|
|
||
| | Meshes | Material | | ||
| | ---------------------------------- | ------------------------------- | | ||
| | `laces` | `white_matte` | | ||
| | `body` | `red_matte` | | ||
| | `sole` | `white_matte` | | ||
|
|
||
| In this case, the laces and sole of the shoe would be white while the body of the shoe would be red. | ||
|
|
||
| This material variant may have an associated SKU or product name in digital commerce. The shoe, however, also comes in an alternative color scheme that is represented by an alternative set of primitive/material mappings: | ||
|
|
||
| | Meshes | Material | | ||
| | ---------------------------------- | ------------------------------- | | ||
| | `laces` | `red_matte` | | ||
| | `body` | `white_matte` | | ||
| | `sole` | `white_matte` | | ||
|
|
||
| In the second case, the shoe would have a white body and sole but red laces. In both cases, the meshes and their associated primitives remain the same with the exception of which material is used. Looking at the laces mesh, the KHR_materials_variants extension would define this mapping as follows: | ||
|
|
||
| ```javascript | ||
| "meshes": [ | ||
| { | ||
| "name": "laces", | ||
| "primitives": [ | ||
| { | ||
| ..., | ||
| "extensions": { | ||
| "KHR_materials_variants" : { | ||
| "mappings": [ | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| "variants": [0], | ||
| "material": 1, | ||
| }, | ||
| { | ||
| "variants": [1], | ||
| "material": 2, | ||
| }, | ||
| ], | ||
| } | ||
| } | ||
| }, | ||
| // ... more primitives ... | ||
| ] | ||
| }, | ||
| // ... more meshes ... | ||
| ] | ||
| ``` | ||
|
|
||
| The variants property within each mapping refers to the index of a material variant located at the glTF root node: | ||
|
|
||
| ```javascript | ||
| { | ||
| "asset": {"version": "2.0", "generator": "Fancy 3D Tool" }, | ||
| "extensions": { | ||
| "KHR_materials_variants": { | ||
| "variants": [ | ||
| {"name": "Red Shoe with White Laces" }, | ||
| {"name": "White Shoe with Red Laces" }, | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Interaction with existing glTF functionality | ||
|
|
||
| _This section is non-normative._ | ||
|
|
||
| The primary purpose of this extension is to simply formalise the idea of static configurability, so that members of the ecosystem can meaningfully communicate: those who produce assets and those who ingest them, and all the tooling in between. | ||
|
|
||
| As a secondary effect, material variants allow multiple assets — with shared geometry but different materials — to be stored more compactly, particularly relevant for the self-contained binary format GLB. When using external URIs as references to textures, applications may (optionally) process geometry only once and lazily request texture assets only when needed for a particular variant. | ||
|
|
||
| ## Implications for Applications and APIs | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| _This section is non-normative._ | ||
|
|
||
| How does an application communicate to a glTF engine what the initial variant state should be? How does it submit a runtime request for a different configuration? It's out of scope for this extension to constrain or mandate an engine's public API, but a useful implementation will require something of the sort. | ||
|
|
||
| ## Examples | ||
|
|
||
| _This section is non-normative._ | ||
|
|
||
| For reference, we provide several simple examples of variants, both represented as distinct constituent GLB files without the extension and as multi-variant GLB files leveraging this extension. We also include the respective net size of the individual variant GLB files and the size of the single combined multi-variant GLB, for comparison. | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| | Model | Screenshot | Description | Net Size (MB) | Combined Size (MB) | | ||
| |---------------------------|------------------------------------|---------------------------------------------------------------------------------------------------------------|---------------|--------------------| | ||
| | [Shoes](examples/shoes) |  | A simple variant commerce example with a single mesh primitive | 15 | 7.5 | | ||
| | [Chair](examples/chair) |  | A more complex commerce example, involving multi-dimensional variants - flattened into four distinct variants | 7.0 | 1.7 | | ||
| | [Helmet](examples/helmet) |  | Gaming example, with wet and dry variants of a helmet | 8.8 | 5.0 | | ||
11 changes: 11 additions & 0 deletions
11
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Oval tufted chair | ||
|
|
||
| ## Screenshot | ||
|
|
||
|  | ||
|
|
||
| ## Description | ||
|
|
||
| ## License Information | ||
| Copyright 2020 Eric Chadwick | ||
| CC BY 4.0 https://creativecommons.org/licenses/by/4.0/ |
Binary file added
BIN
+1.75 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/chairs.glb
Binary file not shown.
Binary file added
BIN
+246 KB
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/chairs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.74 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/red_fabric_oak_legs.glb
Binary file not shown.
Binary file added
BIN
+1.74 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/red_fabric_walnut_legs.glb
Binary file not shown.
Binary file added
BIN
+1.74 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/white_fabric_oak_legs.glb
Binary file not shown.
Binary file added
BIN
+1.74 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/chair/white_fabric_walnut_legs.glb
Binary file not shown.
11 changes: 11 additions & 0 deletions
11
extensions/2.0/Khronos/KHR_materials_variants/examples/helmet/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Sci Fi Helmet | ||
| ## Screenshot | ||
|
|
||
|  | ||
|
|
||
|
|
||
| ## License Information | ||
|
|
||
| ["Sci Fi Helmet" by Michael Pavlovic](http://quixel.se/usermanual/quixelsuite/doku.php?id=ddo_samples) | ||
|
|
||
| Converted by Norbert Nopper for glTF testing. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.97 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/helmet/helmet.glb
Binary file not shown.
Binary file added
BIN
+4.97 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/helmet/helmet_combined.glb
Binary file not shown.
Binary file added
BIN
+3.85 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/helmet/helmet_wet.glb
Binary file not shown.
Binary file added
BIN
+603 KB
extensions/2.0/Khronos/KHR_materials_variants/examples/helmet/helmets.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.69 KB
extensions/2.0/Khronos/KHR_materials_variants/examples/helmet/screenshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
extensions/2.0/Khronos/KHR_materials_variants/examples/shoes/README.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Beach, Midnight, Street shoes | ||
|
|
||
| ## Screenshot | ||
|
|
||
|  | ||
|
|
||
| ## Description | ||
|
|
||
| ## License Information | ||
| Copyright 2020 Shopify, Inc. | ||
| CC BY 4.0 https://creativecommons.org/licenses/by/4.0/ |
Binary file added
BIN
+5.13 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/shoes/beach.glb
Binary file not shown.
Binary file added
BIN
+5.13 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/shoes/midnight.glb
Binary file not shown.
Binary file added
BIN
+833 KB
extensions/2.0/Khronos/KHR_materials_variants/examples/shoes/photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.47 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/shoes/shoes.glb
Binary file not shown.
Binary file added
BIN
+5.08 MB
extensions/2.0/Khronos/KHR_materials_variants/examples/shoes/street.glb
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
extensions/2.0/Khronos/KHR_materials_variants/schema/glTF.KHR_materials_variants.schema.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema", | ||
| "title": "KHR_materials_variants glTF extension", | ||
| "type": "object", | ||
| "description": "glTF extension that defines a material variations for mesh primivites", | ||
| "allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
| "properties": { | ||
| "variants": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "description": "An object defining a valid material variant", | ||
| "gltf_detailedDescription": "An object defining a valid material variant", | ||
| "properties": { | ||
| "name": { | ||
| "type": "string", | ||
| "description": "The name of the material variant", | ||
| "gltf_detailedDescription": "The name of the material variant." | ||
| }, | ||
| "extras": { } | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
.../KHR_materials_variants/schema/mesh.primitive.KHR_materials_variants.mappings.schema.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema", | ||
| "title": "KHR_materials_variants mesh primitive extension", | ||
| "type": "object", | ||
| "allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
| "properties": { | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "variants": { | ||
emackey marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "type": "array", | ||
| "description": "An array of variant index values.", | ||
| "items": { | ||
| "allOf": [ {"$ref": "glTFid.schema.json" } ] | ||
| }, | ||
| "minItems": 1, | ||
| "gltf_detailedDescription": "An array of index values that reference variants defined in the glTF root's extension object." | ||
| }, | ||
| "material": { | ||
| "allOf": [ { "$ref": "glTFid.schema.json" } ], | ||
| "description": "The material associated with the set of variants.", | ||
| "gltf_detailedDescription": "A reference to the material associated with the given array of variants." | ||
| }, | ||
| "name": { | ||
| "type": "string", | ||
| "description": "The user-defined name of this variant material mapping.", | ||
| "gltf_detailedDescription": "The optional user-defined name of this variant material mapping. This is not necessarily unique." | ||
| }, | ||
| "extras": { }, | ||
| "extensions": { } | ||
| }, | ||
| "required": [ | ||
| "variants", | ||
| "material" | ||
| ] | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.