- Omar Shehata, Cesium, @OmarShehata
- Pascal Massimino, Google, @Skal65535
Complete, Ratified by the Khronos Group
Written against the glTF 2.0 spec.
This extension allows glTF assets to use WebP as a valid image format.
WebP is an image format developed and maintained by Google that provides superior lossless and lossy compression rates for images on the web. It is typically 26% smaller in size compared to PNGs and 25-34% smaller than comparable JPEG images.
A client implementation that does not support this extension may be able to ignore the provided WebP image if an optional fallback PNG or JPEG image is present. The best practices section describes the use cases of this extension with and without a fallback image.
The EXT_texture_webp
extension is added to the texture object and specifies a source
property that contains the index of the WebP image object.
The following glTF will load image.webp
in client implementations that support this extension, and otherwise fall back to image.png
.
"textures": [
{
"source": 0,
"extensions": {
"EXT_texture_webp": {
"source": 1
}
}
}
],
"images": [
{
"uri": "image.png"
},
{
"uri": "image.webp"
}
]
When an image is stored in a buffer and accessed via a buffer view, the WebP image object uses the mimeType
value of image/webp
.
"textures": [
{
"source": 0,
"extensions": {
"EXT_texture_webp": {
"source": 1
}
}
}
],
"images": [
{
"mimeType": "image/png",
"bufferView": 1
},
{
"mimeType": "image/webp",
"bufferView": 2
}
]
glTF.EXT_texture_webp.schema.json
It is recommended to use this extension when transmission size is a significant bottleneck. For example, in geospatial applications the total texture payload can range from gigabytes to terabytes of data. In those situations, WebP textures can be used without a fallback to improve storage and transmission.
When a fallback image is defined, this extension should not be present in extensionsRequired
. This will allow all client implementations to render the glTF asset correctly, and those that support this extension can use the WebP version of the textures.
WebP images using extended file format (RFC 9649, Section 2.7) should not contain ICCP
, ANIM
, or EXIF
chunks.
To use WebP images without a JPEG or PNG fallback, EXT_texture_webp
must be present in both extensionsUsed
and extensionsRequired
. The texture object will then have only an extensions
property as shown below.
"textures": [
{
"extensions": {
"EXT_texture_webp": {
"source": 1
}
}
}
]
CesiumJS uses it to significantly cut load times for massive models that contain gigabytes of texture data (see implementation and sample model).
Google's WebP developer page provides information about the format as well as pre-compiled and source code versions of the reference codec implementation
Sharp is a Node.js library for fast encode/decode of WebP using native modules