summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-09 03:01:52 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-09 03:01:52 +0100
commitc80016a9ef91da2362d6874c130941efcf36ac00 (patch)
tree715481f2b15fbcbaa13fd09d56064a4265faa9dd
parent524f5d27020ca63d21cd5eca1120a1c71443e240 (diff)
downloadweareserver-c80016a9ef91da2362d6874c130941efcf36ac00.tar
weareserver-c80016a9ef91da2362d6874c130941efcf36ac00.tar.bz2
weareserver-c80016a9ef91da2362d6874c130941efcf36ac00.tar.zst
add more gltf extensions
-rw-r--r--doc/resources.md76
-rw-r--r--shared/src/resources.rs5
-rw-r--r--world/Cargo.toml3
-rw-r--r--world/src/mesh.rs13
4 files changed, 68 insertions, 29 deletions
diff --git a/doc/resources.md b/doc/resources.md
index a6b885b..4931f51 100644
--- a/doc/resources.md
+++ b/doc/resources.md
@@ -27,38 +27,62 @@
## MeshPart
-Combinations 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.
+Combinations 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 | f32 | |
-| g_roughness | f32 | |
-| g_albedo | Vec3 | |
-| g_transmission | f32 | |
-| g_emission | Vec3 | |
-| va_position | [Resource; 3] | |
-| va_normal | [Resource; 3] | |
-| va_texcoord | [Resource; 2] | |
-| va_roughness | Resource | |
-| va_metallic | Resource | |
-| va_albedo | [Resource; 3] | |
-| 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_transmission | Resource | Use alpha channel |
-| tex_emission | Resource | Use color channels |
+| 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 | | |
+| 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].
+
+[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
## LightPart
| Key | Value Type |
| -------- | ---------- |
-| radius | f32 |
+| radius | Float |
| emission | Vec3 |
## EnvironmentPart
diff --git a/shared/src/resources.rs b/shared/src/resources.rs
index 628fa1e..08fb6f5 100644
--- a/shared/src/resources.rs
+++ b/shared/src/resources.rs
@@ -51,6 +51,10 @@ pub struct MeshPart {
pub g_transmission: Option<f32>,
pub g_alpha: Option<f32>,
pub g_emission: Option<Vec3A>,
+ pub g_thickness: Option<f32>,
+ pub g_refractive_index: Option<f32>,
+ pub g_attenuation: Option<Vec3A>,
+ pub g_dispersion: Option<f32>,
pub va_position: Option<[Resource<AttributeArray>; 3]>,
pub va_normal: Option<[Resource<AttributeArray>; 3]>,
pub va_texcoord: Option<[Resource<AttributeArray>; 2]>,
@@ -67,6 +71,7 @@ pub struct MeshPart {
pub tex_transmission: Option<Resource<Image>>,
pub tex_alpha: Option<Resource<Image>>,
pub tex_emission: Option<Resource<Image>>,
+ pub tex_thickness: Option<Resource<Image>>,
}
#[derive(Debug, Default, Clone)]
diff --git a/world/Cargo.toml b/world/Cargo.toml
index 11272ed..51437d5 100644
--- a/world/Cargo.toml
+++ b/world/Cargo.toml
@@ -12,6 +12,9 @@ gltf = { version = "1.4.1", features = [
"names",
"KHR_lights_punctual",
"KHR_materials_transmission",
+ "KHR_materials_ior",
+ "KHR_materials_volume",
+ "KHR_materials_emissive_strength",
] }
log = "0.4.22"
weareshared = { path = "../shared" }
diff --git a/world/src/mesh.rs b/world/src/mesh.rs
index 3190c28..216f8f3 100644
--- a/world/src/mesh.rs
+++ b/world/src/mesh.rs
@@ -283,10 +283,17 @@ pub fn import_mesh(
tex_emission,
tex_transmission,
index,
+ // not yet implemented
+ g_attenuation: None,
+ g_dispersion: None,
+ g_refractive_index: None,
+ g_thickness: None,
+ tex_thickness: None,
+ // not supported by gltf
va_transmission: None,
- va_emission: None, // not supported by gltf
- va_metallic: None, // not supported by gltf
- va_roughness: None, // not supported by gltf
+ va_emission: None,
+ va_metallic: None,
+ va_roughness: None,
})?;
let mat = node.transform().matrix();
let aff = Affine3A::from_cols_array_2d(&[