Skip to content

Commit

Permalink
Add MSFT_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sbtron committed Mar 1, 2018
1 parent 5723e6f commit 834af32
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 0 deletions.
118 changes: 118 additions & 0 deletions extensions/2.0/Vendor/MSFT_lod/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# MSFT\_lod

## Contributors

* Saurabh Bhatia, Microsoft
* Gary Hsu, Microsoft
* Adam Gritt, Microsoft
* John Copic, Microsoft
* Marc Appelsmeier, Microsoft
* Dag Frommhold, Microsoft

## Status

Complete

## Dependencies

Written against the glTF 2.0 spec.

## Overview

This extension adds the ability to specify various Levels of Detail (LOD) to a glTF asset. An implementation of this extension can use the LODs for various scenarios like rendering a different LOD based upon the distance of the object or progressively loading the glTF asset starting with the lowest LOD.

This extension allows an LOD to be defined at the geometry `node` or the `material` level. The `node` LODs can specify different geometry and materials across various levels whereas `material` LODs can specify different materials for the same geometry.

The `MSFT_lod` extension is added to the highest LOD level. The extensions defines an `ids` property which is an array containing the indices of the lower LOD levels. Each value in the array points to a LOD level that is lower in quality than the previous level. For example, if the extension is defined at the `node` level then the `node` object with the extension is the highest LOD level. Every value specified in the `ids` array of the extension points to the index of another `node` object which should be used as the lower LOD level.

An implementation of this extension can parse through the `ids` array to create the list of LOD levels available for an asset. If an asset containing this extension is loaded in a client that doesnt implement the extension, then the highest LOD level will be loaded and all lower LODs will be ignored.

The following example shows how the `MSFT_lod` extension can be specified at the `node` level to create three LOD levels:
```json
"nodes": [
{
"name": "High_LOD",
"mesh": 0,
"extensions": {
"MSFT_lod": {
"ids": [ 1, 2 ]
}
},
"extras": {
"MSFT_screencoverage": [ 0.5, 0.2 , 0.01]
}
},
{
"name": "Medium_LOD",
"mesh": 1
},
{
"name": "Low_LOD",
"mesh": 2
}
]
```
Since the `MSFT_lod` extension is specified in `node[0]`, it becomes the highest LOD. The first element in the `ids` array is *1*, making `node[1]` the next lower LOD (or the *Medium_LOD*). The second element in the `ids` array is *2*, making `node[2]` the lowest LOD for this sample.

The `MSFT_screencoverage` metadata values specified in `extras` can be used along with the `MSFT_lod` extension as a hint to determine the switching threshold for the various LODs.

In the example above the screen coverage values can be used as follows:

- LOD0 Rendered from 1.0 to 0.5
- LOD1 Rendered from 0.5 to 0.2
- LOD2 Rendered from 0.2 to 0.01
- Nothing rendered from 0.01 – 0

A similar pattern can be followed to create `material` LODs:
```json
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
}
},
"normalTexture": {
"index": 1
},
"extensions": {
"MSFT_lod": {
"ids": [1,2]
}
}
},
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 2
}
},
"normalTexture": {
"index": 3
},
},
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 4
}
},
"normalTexture": {
"index": 5
},
}
]
```
If both node level and material level LODs are specified then the material level LODs only apply to the specific node LOD that they were defined for.

## glTF Schema Updates

* **JSON schema**: [glTF.MSFT_lod.schema.json](schema/glTF.MSFT_lod.schema.json)

## Known Implementations

* [glTF-Toolkit](https://github.com/Microsoft/glTF-Toolkit) can take three individual glTF files as input LODs and merge them into a single glTF file which uses the `MSFT_lod` extension.
* [BabylonJS](https://github.com/BabylonJS/Babylon.js/tree/master/loaders/src/glTF) has support for `MSFT_lod` extension defined at the material or node level. The current implementation progressively loads each LOD to improve the initial load time of the asset.
* Windows Mixed Reality Home and 3D Launchers for Windows Mixed Reality use `MSFT_lod` at the `node` level to support switching LODs based on the render distance.


19 changes: 19 additions & 0 deletions extensions/2.0/Vendor/MSFT_lod/schema/glTF.MSFT_lod.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "MSFT_lod glTF extension",
"type": "object",
"description": "glTF extension for specifying Levels of Detail.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer"
},
"description": "Array containing the indices of progressively lower LOD nodes.",
"minItems": 1
},
"extensions": { },
"extras": { }
}
}
117 changes: 117 additions & 0 deletions extensions/2.0/Vendor/MSFT_packing_normalRoughnessMetallic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# MSFT_packing_normalRoughnessMetallic

## Contributors

* Saurabh Bhatia, Microsoft
* Gary Hsu, Microsoft
* Marc Appelsmeier, Microsoft
* Dag Frommhold, Microsoft
* John Copic, Microsoft

## Status

Complete

## Dependencies

Written against the glTF 2.0 spec.

## Overview

This extension adds support for alternate texture packing and is meant to be used for Windows Mixed Reality Home and 3D Launchers for Windows Mixed Reality.

This extension defines an additional property for `normalRoughnessMetallicTexture`. This property specifies the index of a texture with the packing Normal (RG), Roughness (B), Metallic (A). This specialized packing is meant to provide an optimized alternative to the one specified in the core glTF 2.0 specification.

The extension should only be used when creating glTF assets for engines that support this packing and is not meant to be a general purpose packing extension. Any client that does not support this extension can safely ignore these additional packed texture and rely on the default packing in glTF 2.0. This extension can also be used along with other extensions like [MSFT_texture_dds](../MSFT_texture_dds/README.md) to store the packed textures in DDS files.

The example below shows how this extension can be used along with the MSFT_texture_dds extension in a glTF Binary (.glb) file:

```json
{
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0
},
"roughnessMetallicTexture": {
"index": 1
}
},
"normalTexture": {
"index": 2
},
"extensions": {
"MSFT_packing_normalRoughnessMetallic": {
"normalRoughnessMetallicTexture": {
"index": 3
}
}
}
}
],
"textures": [
{
"name":"baseColorTexture",
"source":0,
"extensions": {
"MSFT_texture_dds": {
"source": 3
}
}
},
{
"name":"roughnessMetallicTexture",
"source":1
},
{
"name":"normalTexture",
"source":2
},
{
"name":"normalRoughnessMetallic",
"extensions": {
"MSFT_texture_dds": {
"source": 4
}
}
},
],
"images": [
{
"name":"baseColorTexture.png",
"mimeType": "image/png",
"bufferView": 0
},
{
"name":"roughnessMetallicTexture.png",
"mimeType": "image/png",
"bufferView": 1
},
{
"name":"normalTexture.png",
"mimeType": "image/png",
"bufferView": 2
},
{
"name":"baseColorTexture.dds",
"mimeType": "image/vnd-ms.dds",
"bufferView": 3
},
{
"name":"normalRoughnessMetallic.dds",
"mimeType": "image/vnd-ms.dds",
"bufferView": 4
}
]
}
```

## glTF Schema Updates

* **JSON schema**: [glTF.MSFT_packing_normalRoughnessMetallic.schema.json](schema/glTF.MSFT_packing_normalRoughnessMetallic.schema.json)


## Known Implementations

This extension is used by Windows Mixed Reality Home and 3D Launchers for Windows Mixed Reality to improve performance by using the specially packed textures. [glTF-Toolkit](https://github.com/Microsoft/glTF-Toolkit) can be used to generate files that use this extension.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "MSFT_packing_normalRoughnessMetallic extension",
"type": "object",
"description": "glTF extension the specifies a packing of normalRoughnessMetallic in a single texture.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"normalRoughnessMetallicTexture": {
"type": "object",
"description": "A texture with the packing Normal (RG), Roughness (B), Metallic (A).",
"properties": {
"index": {
"allOf": [ { "$ref": "glTFid.schema.json" } ],
"description": "The index of the texture."
}
}
},
"extensions": {},
"extras": {}
}
}
Loading

0 comments on commit 834af32

Please sign in to comment.