summaryrefslogtreecommitdiff
path: root/doc/resources.md
blob: ba1ce720574481a6c1ce8db47ee7ae99648b1b9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Resource formats

## Dictionary format

```
[kkkk vvvv KK... VV...]...
 ^    ^    ^     ^
 |    |    |     | value
 |    |    | key
 |    | 16-bit kalue length
 | 16-bit key length
```

## PrefabIndex

| Key      | Value Type |
| -------- | ---------- |
| \<Name\> | Resource   |

## Prefab

| Key         | Value Type                   |           |
| ----------- | ---------------------------- | --------- |
| mesh        | Matrix3, Vec3, Res<MeshPart> | Multi key |
| light       | Vec3, Res<LightPart>         | Multi key |
| environment | Res<EnvironmentPart>         |           |

## MeshPart

Vertex attribute arrays (va_\*) are resources that contain a packed float32
array. ombinations of g_\*, va_\* and tex_\* are multiplied except normal which
is added. Defaults should be the identity for that operation, so default is 1 /
white except normals are zero.

| Key                | Value Type    |                    |
| ------------------ | ------------- | ------------------ |
| index              | Resource      |                    |
| g_metallic         | Float         |                    |
| g_roughness        | Float         |                    |
| g_albedo           | Vec3          |                    |
| g_alpha            | Float         |                    |
| g_transmission     | Float         |                    |
| g_emission         | Vec3          |                    |
| g_refractive_index | Float         |                    |
| g_attenuation      | Vec3          |                    |
| g_dispersion       | Float         |                    |
| g_thickness        | Float         |                    |
| g_unlit            |               |                    |
| va_position        | [Resource; 3] |                    |
| va_normal          | [Resource; 3] |                    |
| va_texcoord        | [Resource; 2] |                    |
| va_roughness       | Resource      |                    |
| va_metallic        | Resource      |                    |
| va_albedo          | [Resource; 3] |                    |
| va_alpha           | Resource      |                    |
| va_transmission    | Resource      |                    |
| va_emission        | Resource      |                    |
| tex_normal         | Resource      | Use color channels |
| tex_roughness      | Resource      | Use green channel  |
| tex_metallic       | Resource      | Use blue channel   |
| tex_albedo         | Resource      | Use color channels |
| tex_alpha          | Resource      | Use alpha channel  |
| tex_transmission   | Resource      | Use red channel    |
| tex_emission       | Resource      | Use color channels |
| tex_thickness      | Resource      | Use green channels |

- **Attenuation**: Attenuation coefficient for each color channel due to
  scattering within the material volume expressed as e-folding distance (m^-1).
  See [KHR_materials_volume].
- **Transmission**: Equivalent to `transmissionFactor` and `transmissionTexture`
  of [KHR_materials_transmission].
- **Refractive Index**: Equivalent to `ior` of [KHR_materials_ior]
- **Thickness**: Equivalent to `thicknessFactor` and `thicknessTexture` of
  [KHR_materials_volume].
- **Dispersion**: 20 / Abbe Number. Equivalent to `dispersion` of
  [KHR_materials_dispersion].
- **Unlit**: Directly transfers \*_albedo to the screen if set. No lighting
  shaders are applied.

## LightPart

| Key      | Value Type         |
| -------- | ------------------ |
| radius   | Float              |
| emission | Vec3               |
| spot     | Vec3, Float, Float |

- **Emission**: Luminous intensity in candela per channel. Equivalent of `color`
  multiplied with `intensity` of [KHR_lights_punctual].
- **Radius**: Radius for soft shadow calculation. If set, the light source can
  be modelled to be a light emitting sphere of that radius. Not suported by
  glTF.
- **Spot**: Normalized direction vector, inner and outer cone radius like
  `innerConeAngle` and `outerConeAngle` in [KHR_lights_punctual].

## EnvironmentPart

| Key    | Value Type |                  |
| ------ | ---------- | ---------------- |
| skybox | Resource   |                  |
| sun    | Vec3, Vec3 | Direction, Color |

## Texture

WebP

[KHR_materials_transmission]: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_transmission
[KHR_materials_ior]: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_ior
[KHR_materials_volume]: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_volume
[KHR_materials_dispersion]: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
[KHR_lights_punctual]: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_lights_punctual