diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-09 20:36:54 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-09 20:36:54 +0100 |
commit | 20db20d2702f7b547e1c9c0a2698b6d576cd79d8 (patch) | |
tree | 6ce4cd6e9b9b5b95969cf584cd47e9cd62439f2c | |
parent | 726f435d29d9c341fad8dc9fdcda3ffdfbb320e8 (diff) | |
download | weareserver-20db20d2702f7b547e1c9c0a2698b6d576cd79d8.tar weareserver-20db20d2702f7b547e1c9c0a2698b6d576cd79d8.tar.bz2 weareserver-20db20d2702f7b547e1c9c0a2698b6d576cd79d8.tar.zst |
implement KHR_materials_dispersion
-rw-r--r-- | doc/other.md | 9 | ||||
-rw-r--r-- | world/Cargo.toml | 1 | ||||
-rw-r--r-- | world/src/mesh.rs | 33 |
3 files changed, 28 insertions, 15 deletions
diff --git a/doc/other.md b/doc/other.md index b3f8c93..3108e78 100644 --- a/doc/other.md +++ b/doc/other.md @@ -17,7 +17,7 @@ | KHR_lights_punctual | Supported | | KHR_materials_anisotropy | Todo | | KHR_materials_clearcoat | Todo | -| KHR_materials_dispersion | Todo (2) | +| KHR_materials_dispersion | Supported | | KHR_materials_emissive_strength | Supported | | KHR_materials_ior | Supported | | KHR_materials_iridescence | Todo | @@ -31,15 +31,14 @@ | KHR_texture_basisu | Not required (3) | | KHR_texture_transform | Not required (4) | | KHR_xmp_json_ld | Todo | -| EXT_mesh_gpu_instancing | Not required (6) | +| EXT_mesh_gpu_instancing | Not required (2) | | EXT_meshopt_compression | Todo, maybe | | EXT_texture_webp | Supported | 1. We can do the same by sharing subresources. -2. The gltf rust crate does not support that extension. +2. Shared parts can be optimized to instanced drawing by the client. This would + also only be a bandwidth optimization, avoiding gigantic prefabs. 3. KTX is worse then WebP in terms of size. Transcoding on the client is possible. 4. Automatic atlas packing is also possible on the client. 5. Introduces too much complexity and interfers with our animation system. -6. Shared parts can be optimized to instanced drawing by the client. This would - also only be a bandwidth optimization, avoiding gigantic prefabs. diff --git a/world/Cargo.toml b/world/Cargo.toml index 51437d5..3a867bb 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -10,6 +10,7 @@ env_logger = "0.11.6" gltf = { version = "1.4.1", features = [ "extras", "names", + "extensions", "KHR_lights_punctual", "KHR_materials_transmission", "KHR_materials_ior", diff --git a/world/src/mesh.rs b/world/src/mesh.rs index a38980e..c5bbb7f 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -237,31 +237,31 @@ pub fn import_mesh( let g_albedo = if base_color[0] != 1. || base_color[1] != 1. || base_color[2] != 1. { info!( - "global albedo is r={},g={},b={}", + "albedo is r={},g={},b={}", base_color[0], base_color[1], base_color[2] ); Some(Vec3A::new(base_color[0], base_color[1], base_color[2])) } else { - debug!("global albedo pruned"); + debug!("albedo pruned"); None }; let g_alpha = if base_color[3] != 1. { - info!("global alpha is {}", base_color[3]); + info!("alpha is {}", base_color[3]); Some(base_color[3]) } else { - debug!("global alpha pruned"); + debug!("alpha pruned"); None }; let emission = p.material().emissive_factor(); let g_emission = if emission[0] != 0. || emission[1] != 0. || emission[2] != 0. { info!( - "global emission is r={},g={},b={}", + "emission is r={},g={},b={}", base_color[0], base_color[1], base_color[2] ); Some(Vec3A::new(emission[0], emission[1], emission[2])) } else { - debug!("global emission pruned"); + debug!("emission pruned"); None }; @@ -272,13 +272,27 @@ pub fn import_mesh( .unwrap_or(0.); let g_transmission = if transmission != 0. { - info!("global transmission is {transmission}"); + info!("transmission is {transmission}"); Some(transmission) } else { - debug!("global transmission pruned"); + debug!("transmission pruned"); None }; + let g_dispersion = p + .material() + .extensions() + .map(|e| e.get("KHR_materials_dispersion")) + .flatten() + .map(|e| e.get("dispersion")) + .flatten() + .map(|e| e.as_f64()) + .flatten() + .map(|e| e as f32); + if let Some(d) = g_dispersion { + info!("dispersion is {d}"); + } + let g_attenuation = p.material().volume().map(|v| { let ref_dist = v.attenuation_distance(); Vec3A::from_array(v.attenuation_color().map( @@ -300,6 +314,7 @@ pub fn import_mesh( g_attenuation, g_thickness, g_refractive_index, + g_dispersion, va_position, va_normal, va_texcoord, @@ -313,8 +328,6 @@ pub fn import_mesh( tex_emission, tex_transmission, tex_thickness, - // not yet implemented - g_dispersion: None, // not supported by gltf va_transmission: None, va_emission: None, |