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

Extension: Static lightmap textures #1017

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ _Draft Khronos extensions are not ratified yet._
* [KHR_materials_common](Khronos/KHR_materials_common/README.md)
* [KHR_technique_webgl](Khronos/KHR_technique_webgl/README.md)

#### Vendor extensions
* [AVR_lights_static](Vendor/AVR_lights_static/README.md)

## Extensions for glTF 1.0

#### Khronos extensions
Expand All @@ -22,7 +25,7 @@ _Draft Khronos extensions are not ratified yet._

# About glTF Extensions

glTF extensions extend the base glTF model format. Extensions can introduce new properties (including properties that reference external data, and the extension can define the format of those data), new parameter semantics, reserved IDs, and new container formats. Extensions are written against a specific version of glTF and may be promoted to core glTF in a later glTF version.
glTF extensions extend the base glTF model format. Extensions can introduce new properties (including properties that reference external data, and the extension can define the format of those data), new parameter semantics, reserved IDs, and new container formats. Extensions are written against a specific version of glTF and may be promoted to core glTF in a later glTF version.

## Extension Mechanics

Expand Down
46 changes: 46 additions & 0 deletions extensions/Vendor/AVR_lights_static/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# AVR_lights_static

## Contributors

* Steven Vergenz, AltspaceVR ([steven@altvr.com](mailto:steven@altvr.com))

## Status

Draft

## Dependencies

Written against the glTF 2.0 spec, and the draft [AVR_texture_offset_tile](../AVR_texture_offset_tile/README.md) extension.

## Overview

As a performance optimization, many game engines support computing ("baking") certain lighting information in advance, and storing it to a texture ("lightmap") for use at runtime. This has the advantage of not only reducing the computational load of rendering the scene, but it also allows the use of more accurate lighting simulations that would normally not be possible, like raytracing. In practice, this is usually used for global illumination. This is where light is virtually bounced around the scene before being recorded, producing realistic shadows and diffuse reflections that are hard to produce with standard realtime techniques.

However, this approach is not always applicable. The downside of precomputing your lighting is that changes to an object's position or material will not be reflected in the lighting on the rest of the scene. So if you move an object, the shadow it cast would stay in place. For this reason, this technique is also called "static" lighting, because it cannot change without rebaking.

This extension allows glTF materials to provide one of these precomputed textures to a consuming application, providing greater realism for a reduced computational cost. The details of how this lightmap is applied will depend on the lighting model in use by the consumer.

## glTF Schema Updates

The `AVR_lights_static` extension may be defined on `node` structures. This data is specified on the node instead of the material or texture because every node with a lightmap is going to need a separate texture from an otherwise identical but differently-placed node.

The extension object may contain the following properties:

| Name | Type | Default | Description
|--------------|-----------|------------|---------------------------------
| `index` | `glTFid` | *required* | Texture reference to a lightmap. The referenced texture contains RGB components in sRGB color space. If a fourth component (A) is present, it is ignored.
| `texCoord` | `integer` | `0` | The set index of texture's TEXCOORD attribute used for texture coordinate mapping.
| `strength` | `number` | `1.0` | The influence of the lightmap on the final output.
| `extensions` | `object` | | If desired, use the `AVR_texture_offset_tile` extension to use a texture atlas as a lightmap.

### JSON Schema

[AVR_lights_static.lightmapTextureInfo.schema.json](schema/AVR_lights_static.lightmapTextureInfo.schema.json)

## Known Implementations

* [UnityGLTF](https://github.com/AltspaceVR/UnityGLTF) (upcoming)

## Resources

* [Explanation of Unity 5's GI formula](http://www.shadercat.com/how-to-explore-unity-5s-shader-system-code-iv-global-illumination-code-overview/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "lightmapTextureInfo",
"type": "object",
"description": "This extension allows glTF materials to provide one of these precomputed textures to a consuming application, providing greater realism for a reduced computational cost. The details of how this lightmap is applied will depend on the lighting model in use by the consumer.",
"allOf": [ { "$ref": "textureInfo.schema.json" } ],
"properties": {
"strength": {
"type": "number",
"description": "A scalar multiplier controlling the amount of light applied from the lightmap.",
"default": 1.0,
"minimum": 0.0,
"maximum": 1.0
}
}
}