Skip to content

Commit 96a4959

Browse files
committed
[WIP] OMI_materials_blend
1 parent 1fb0084 commit 96a4959

File tree

7 files changed

+595
-10
lines changed

7 files changed

+595
-10
lines changed

extensions/2.0/OMI_audio_ogg_vorbis/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ Audio data can also be stored in a buffer, such as in the glTF Binary (.glb) for
7676
}
7777
```
7878

79-
### JSON Schema
80-
81-
[KHR_audio_emitter.source.OMI_audio_ogg_vorbis.schema.json](schema/KHR_audio_emitter.source.OMI_audio_ogg_vorbis.schema.json)
82-
83-
## Best Practices
79+
### Best Practices
8480

8581
Ogg Vorbis has similar use cases to MP3. Both are lossy audio compression formats that are widely supported. Ogg Vorbis should be preferred to MP3 when delivering audio data to clients that support loading Ogg Vorbis audio data from `OMI_audio_ogg_vorbis`.
8682

extensions/2.0/OMI_audio_opus/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ Audio data can also be stored in a buffer, such as in the glTF Binary (.glb) for
7878
}
7979
```
8080

81-
### JSON Schema
82-
83-
[KHR_audio_emitter.source.OMI_audio_opus.schema.json](schema/KHR_audio_emitter.source.OMI_audio_opus.schema.json)
84-
85-
## Best Practices
81+
### Best Practices
8682

8783
Opus codec audio is a superior format to MP3 and Ogg Vorbis for their intended use cases, and it is suitable for many use cases traditionally suitable to WAV audio. Opus is a lossy audio codec that is more efficient than MP3 and Ogg Vorbis, with a higher quality for the same file size, or a smaller file size for the same quality.
8884

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# OMI_materials_blend
2+
3+
## Contributors
4+
5+
- Aaron Franke, Godot Engine.
6+
- Andy Baker, Icosa Foundation.
7+
8+
## Status
9+
10+
Open Metaverse Interoperability Group Draft Proposal
11+
12+
## Dependencies
13+
14+
Written against the glTF 2.0 spec.
15+
16+
## Overview
17+
18+
This extension allows glTF materials to have more alpha blending modes, which can control the transparency and background composability of the material. The `OMI_materials_blend` extension may be used alongside the base glTF PBR materials, or materials defined in glTF extensions. When combined with other materials and techniques, blending may be used to achieve effects like fire, steam, or holograms.
19+
20+
A client that does not implement this extension can ignore the provided material blending settings and use the base glTF material blending settings. When the base glTF alpha blend mode is an acceptable fallback, this extension should not be present in `extensionsRequired`. This will allow clients that do not `OMI_materials_blend` to display the model with the base glTF transparency settings.
21+
22+
## glTF Schema Updates
23+
24+
The `OMI_materials_blend` extension can be added to the extensions of an object in the glTF document-level `"materials"` array.
25+
26+
The following example defines a fire material using the `"ADD"` alpha blend mode. It has a fallback of `"MASK"` so that clients without support for `OMI_materials_blend` will see a cutout instead.
27+
28+
```json
29+
{
30+
"materials": [
31+
{
32+
"alphaMode": "MASK",
33+
"alphaCutoff": 0.25,
34+
"doubleSided": true,
35+
"extensions": {
36+
"OMI_materials_blend": {
37+
"alphaMode": "ADD"
38+
}
39+
},
40+
"name": "Fire"
41+
}
42+
]
43+
}
44+
```
45+
46+
### Property Summary
47+
48+
| | Type | Description | Default value |
49+
| ------------------- | --------- | ---------------------------------------------------------------------- | ------------------------------- |
50+
| **alphaMode** | `string` | The alpha blend mode to use. Override for the base glTF `"alphaMode"`. | Use glTF material `"alphaMode"` |
51+
| **alwaysUseCutoff** | `boolean` | If true, always use the glTF `"alphaCutoff"` as a clip mask. | false |
52+
53+
### Alpha Mode
54+
55+
The `"alphaMode"` property is a lowercase string that defines how the material should be blended with the background. This value must be specified, there is no default value. This overrides the base glTF material's `"alphaMode"` property.
56+
57+
The following values are allowed: `"BLEND"`, `"HASH"`, `"PREMULT"`, `"MULTIPLY"`, `"ADD"`, `"SUBTRACT"`, `"REV_SUBTRACT"`, `"MAX"`, `"MIN"`.
58+
59+
- The `"BLEND"` mode is the same as the base glTF `"BLEND"` mode, which exists to allow for using the `"alwaysUseCutoff"` property with `"BLEND"`. Meaning, if this extension is supported, `"BLEND"` with `"alwaysUseCutoff": true` will have the behavior of base glTF `"BLEND"` and `"MASK"`, both at the same time.
60+
- The other modes are new and are not present in the base glTF specification.
61+
62+
The following table lists the alpha blend modes added by this extension along with the base glTF alpha blend modes and the corresponding modes in various engines.
63+
64+
| glTF | Unity | Unreal | Godot | Blender | OpenGL | Three.JS | WebGPU |
65+
| ------------------------ | ------------------- | --------------- | ------------------------ | ----------------------- | ------------------------ | ----------------------- | ------------------ |
66+
| Base glTF "OPAQUE" | Opaque | Opaque | DISABLED | Dithered without socket | | | |
67+
| Base glTF "MASK" | Alpha Clipping | Masked | ALPHA_SCISSOR | Dithered with socket | | | |
68+
| Base glTF "BLEND" | Alpha Blend | Translucent | ALPHA_DEPTH_PRE_PASS | Blended | | | |
69+
| Extension "HASH" | Not supported | Not supported | ALPHA_HASH | | | | |
70+
| Extension "PREMULT" | Premultiplied Alpha | Alpha Composite | BLEND_MODE_PREMULT_ALPHA | | | | |
71+
| Extension "MULTIPLY" | Multiplicative | Modulate | BLEND_MODE_MUL | Multiplicative Setup | | | |
72+
| Extension "ADD" | Additive | Additive | BLEND_MODE_ADD | Additive Setup | GL_FUNC_ADD | AddEquation | "add" |
73+
| Extension "SUBTRACT" | | | BLEND_MODE_SUB | | GL_FUNC_SUBTRACT | SubtractEquation | "subtract" |
74+
| Extension "REV_SUBTRACT" | | | Not supported | | GL_FUNC_REVERSE_SUBTRACT | ReverseSubtractEquation | "reverse-subtract" |
75+
| Extension "MAX" | | | Not supported | | GL_MAX | MaxEquation | "max" |
76+
| Extension "MIN" | | | Not supported | | GL_MIN | MinEquation | "min" |
77+
78+
The behavior of each mode is as follows:
79+
80+
| Name | Description |
81+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
82+
| "OPAQUE" | Fully opaque, not transparent. The alpha value is ignored. Default and fastest to render. |
83+
| "MASK" | The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value. |
84+
| "BLEND" | The rendered output is combined with the background using the "over" operator as described by the base glTF specification. |
85+
| "HASH" | Useful for hair rendering. Cuts off all values below a spatially-deterministic threshold, the rest will remain opaque. |
86+
| "PREMULT" | Similar to "BLEND" expect the source fragment is assumed to have already been multiplied by the source alpha value. |
87+
| "MULTIPLY" | The color of the object is multiplied by the background. |
88+
| "ADD" | The color of the object is added to the background. |
89+
| "SUBTRACT" | The color of the object is subtracted from the background. |
90+
| "REV_SUBTRACT" | The color of the background is subtracted from the object. |
91+
| "MAX" | The maximum of the object color and the background color is used. |
92+
| "MIN" | The minimum of the object color and the background color is used. |
93+
94+
The most common and important new mode added by this extension, not including ones in the base glTF specification, is the `"ADD"` alpha blend mode. This mode is used for many effects, and is highly recommended to be supported by implementations, or else most `OMI_materials_blend` materials will not render correctly.
95+
96+
### Always Use Cutoff
97+
98+
The `"alwaysUseCutoff"` property is a boolean that defines whether the glTF `"alphaCutoff"` should always be used as a clip mask. This property is optional and defaults to `false`.
99+
100+
The base glTF specification uses the `"alphaCutoff"` property only when the `"alphaMode"` is set to `"MASK"`. However, there is no way to use both `"BLEND"` and a clip mask at the same time. This extension allows for using both at the same time, by setting `"alphaMode"` to `"BLEND"` and `"alwaysUseCutoff"` to `true`. The `"alwaysUseCutoff"` property MUST NOT be set when this extension's `"alphaMode"` is not set and the base glTF specification's `"alphaMode"` is `"OPAQUE"` or `"MASK"` to avoid redundancy with the way the base glTF specification handles these modes.
101+
102+
When `"alwaysUseCutoff"` is true, alpha values below the `"alphaCutoff"` value will be treated as fully transparent, and alpha values above the `"alphaCutoff"` value will be treated as the selected alpha mode (ex: `"BLEND"`, `"ADD"`, etc).
103+
104+
### glTF Object Model
105+
106+
This extension defines no properties that can be read or manipulated by the glTF Object Model.
107+
108+
### JSON Schema
109+
110+
See [schema/material.OMI_materials_blend.schema.json](schema/material.OMI_materials_blend.schema.json) for the schema.
111+
112+
## Known Implementations
113+
114+
None
115+
116+
## Resources
117+
118+
- Khronos glTF Alpha Coverage https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#alpha-coverage
119+
- Khronos OpenGL blend equations https://www.khronos.org/opengl/wiki/Blending#Blend_Equations
120+
- ICOSA UnityGLTF transparency discussion https://github.com/icosa-mirror/UnityGLTF/issues/1
121+
- Unity blend shader command https://docs.unity3d.com/Manual/SL-Blend.html
122+
- Unreal material blend modes https://dev.epicgames.com/documentation/en-us/unreal-engine/material-blend-modes-in-unreal-engine#alphaholdout
123+
- Godot BaseMaterial3D transparency https://docs.godotengine.org/en/stable/classes/class_basematerial3d.html#enum-basematerial3d-transparency
124+
- Godot BaseMaterial3D blend mode https://docs.godotengine.org/en/stable/classes/class_basematerial3d.html#enum-basematerial3d-blendmode
125+
- Three.JS blending equations https://threejs.org/docs/#api/en/constants/CustomBlendingEquations
126+
- Visual glBlendEquation tool https://www.andersriggelsen.dk/glblendfunc.php

0 commit comments

Comments
 (0)