Skip to main content

WEBGI_materials_diamond glTF Extension

Contributors

Status

Draft

Dependencies

Written against the glTF 2.0 spec.

Exclusions

  • This extension must not be used on a material that also uses KHR_materials_pbrSpecularGlossiness.
  • This extension must not be used on a material that also uses KHR_materials_unlit.
  • This extension must not be used on a material that also uses KHR_materials_volume.

Overview

This extension provides the support to set properties for DiamondMaterial and to prepare convex meshes for optimised gemstone rendering. When using this extension:

  • WEBGI_materials_diamond must be added to extensionsUsed.
  • It is optional to add WEBGI_materials_diamond in extensionsRequired. If not present, and any viewer does not support it, default material with the specified color is used, along with pbrMetallicRoughness if specified.

Schema

Extension properties interfaces

The following interfaces defines parameters available for materials and meshes:

interface DiamondMaterialParameters {
isDiamond: true;
color?: string | number;
envMapIntensity?: number;
dispersion?: number;
squashFactor?: number;
geometryFactor?: number;
gammaFactor?: number;
absorptionFactor?: number;
transmission?: number;
refractiveIndex?: number;
boostFactors?: [number, number, number];
}
interface DiamondGeometryParameters{
normalMapRes?: number,
cacheKey?: string
}

For details regarding individual properties see: Jewellery/DiamondPlugin guide

Extending materials

A DiamondMaterial is defined by adding the WEBGI_materials_diamond extension property to the material of the type: DiamondMaterialParameters & DiamondGeometryParameters This specifies the parameters for the material, and parameters for the mesh(to be used on all meshes with the diamond material, which have not been prepared before, see below for details). Example:

"materials": [
{
"extensions": {
"WEBGI_materials_diamond": {
"isDiamond": true,
"envMapIntensity": 2,
"refractiveIndex": 2.4,
...
"cacheKey": "round_diamond",
"normalMapRes": 512,
} as (DiamondMaterialParameters & DiamondGeometryParameters)
},
"color": "#ffff00",
}
]
note

color and transmission property can be specified in the material or in the extension. Both should be supported with preference given to the value in the WEBGI_materials_diamond extension.

It is also possible to specify other material models like pbrMetallicRoughness which will be used in viewers/renderers without the Diamond Material implementation.

Preparing Meshes

Meshes can be prepared before attaching a Diamond material for cases where different geometry parameters are required for meshes with the same material instance. For example when a round diamond and a pear shaped diamond must share material. In this case a unique cacheKey must be specified to each type of mesh, and none on the material. This is done by adding the WEBGI_materials_diamond extension property to the mesh of the type: DiamondGeometryParameters . For example:

"meshes": [
{
"extensions": {
"WEBGI_materials_diamond": {
"cacheKey": "round_diamond",
"normalMapRes": 512,
} as DiamondGeometryParameters
},
...
},
{
"extensions": {
"WEBGI_materials_diamond": {
"cacheKey": "square_diamond",
"normalMapRes": 256,
} as DiamondGeometryParameters
},
...
},
...
]

JSON Schema

TODO: Add link to json schema.

Known Implementations

Resources