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

EXT_texture_webp extension proposal #1534

Merged
merged 9 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions extensions/2.0/Vendor/EXT_image_webp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# EXT_image_webp

## Contributors

* Omar Shehata, Cesium, [@OmarShehata](https://github.com/OmarShehata)
* TBA, Google
OmarShehata marked this conversation as resolved.
Show resolved Hide resolved

## Status

Draft

## Dependencies

Written against the glTF 2.0 spec.

## Overview

This extension allows glTF models to use WebP as a valid image format. A client that does not implement this extension can ignore the provided WebP image and continue to rely on the PNG and JPG textures available in the base specification. Defining a fallback texture is optional. The [best practices](#best-practices) section describes the intended use case of this extension and the expected behavior when using it without a fallback texture.

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 - [source](https://developers.google.com/speed/webp/).

## glTF Schema Updates

The `EXT_image_webp` extension is added to the `textures` node and specifies a `source` property that points to the index of the `images` node which in turn points to the WebP image.

The following glTF will load `image.webp` in clients that support this extension, and otherwise fall back to `image.png`.

```
"textures": [
{
"source": 0,
"extensions": {
"EXT_image_webp": {
"source": 1
}
}
}
],
"images": [
{
"uri": "image.png"
},
{
"uri": "image.webp"
}
]
```

When used in the glTF Binary (.glb) format the `images` node that points to the WebP image uses the `mimeType` value of `image/webp`.

```
"textures": [
{
"source": 0,
"extensions": {
"EXT_image_webp": {
"source": 1
}
}
}
],
"images": [
{
"mimeType": "image/png",
"bufferView": 1
},
{
"mimeType": "image/webp",
"bufferView": 2
}
]
```

### JSON Schema

[glTF.EXT_image_webp.schema.json](schema/glTF.EXT_image_webp.schema.json)

## Best Practices

Since WebP is not as widely supported as JPEG and PNG, it is recommended to use this extension only 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 be defined in `extensionsUsed`. This will allow all clients to render the glTF correctly, and those that support this extension can request the optimized WebP version of the textures.

### Using Without a Fallback

To use WebP images without a fallback, define `EXT_image_webp` in `extensionsRequired`. The `texture` node will then have only an `extensions` property as shown below.
OmarShehata marked this conversation as resolved.
Show resolved Hide resolved

```
"textures": [
{
"extensions": {
"EXT_image_webp": {
"source": 1
}
}
}
]
```

If a glTF contains a WebP with no fallback texture and the browser does not support WebP, the client should either display an error or decode the WebP image at runtime (see [resource](#resources) for decoding libraries).

## Known Implementations

CesiumJS uses it to significantly cut load times for massive models that contain gigabytes of texture data (see [implementation and sample model](https://github.com/AnalyticalGraphicsInc/cesium/pull/7486)).

## Resources

Google's [WebP developer page](https://developers.google.com/speed/webp/) provides information about the format as well as [pre-compiled and source code versions](https://developers.google.com/speed/webp/download) of an encoder and a decoder.

The library [libwebpjs](http://libwebpjs.appspot.com) decodes WebP images in JavaScript for browsers that do not natively support it. [Sharp](http://sharp.pixelplumbing.com/en/stable/) is a NodeJS library for fast encode/decode of WebP (built on top of Google's implementation above).
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "EXT_image_webp glTF extension",
"type": "object",
"description": "glTF extension to specify textures using the WebP image format.",
"allOf": [ { "$ref": "glTFProperty.schema.json" } ],
"properties": {
"source": {
"allOf": [ { "$ref": "glTFid.schema.json" } ],
"description": "The index of the images node which points to a WebP image."
},
"extensions": {},
"extras": {}
}
}