From 0315b90767ccbaa1dcde11d450976f1dc0c928ba Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 17 Feb 2025 20:55:11 +0100 Subject: volume hint in res --- shared/src/resources.rs | 9 ++++++--- world/src/mesh.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/shared/src/resources.rs b/shared/src/resources.rs index 66ecf7a..76e52f8 100644 --- a/shared/src/resources.rs +++ b/shared/src/resources.rs @@ -86,8 +86,9 @@ pub struct MeshPart { pub tex_thickness: Option>>, pub tex_occlusion: Option>>, pub hint_mirror: Option<()>, - pub hint_static: Option<()>, pub hint_hide_first_person: Option<()>, + pub hint_static: Option<()>, + pub hint_volume: Option<()>, } #[derive(Debug, Default, Clone)] @@ -303,8 +304,9 @@ impl ReadWrite for MeshPart { write_kv_opt(w, b"tex_emission", &self.tex_emission)?; write_kv_opt(w, b"tex_occlusion", &self.tex_occlusion)?; write_kv_opt(w, b"hint_mirror", &self.hint_mirror)?; - write_kv_opt(w, b"hint_static", &self.hint_static)?; write_kv_opt(w, b"hint_hide_first_person", &self.hint_hide_first_person)?; + write_kv_opt(w, b"hint_static", &self.hint_static)?; + write_kv_opt(w, b"hint_volume", &self.hint_volume)?; Ok(()) } fn read(r: &mut dyn Read) -> Result { @@ -342,8 +344,9 @@ impl ReadWrite for MeshPart { b"tex_emission" => Ok(s.tex_emission = Some(read_slice(v)?)), b"tex_occlusion" => Ok(s.tex_occlusion = Some(read_slice(v)?)), b"hint_mirror" => Ok(s.hint_mirror = Some(read_slice(v)?)), - b"hint_static" => Ok(s.hint_static = Some(read_slice(v)?)), b"hint_hide_first_person" => Ok(s.hint_hide_first_person = Some(read_slice(v)?)), + b"hint_static" => Ok(s.hint_static = Some(read_slice(v)?)), + b"hint_volume" => Ok(s.hint_volume = Some(read_slice(v)?)), x => Ok(warn!( "unknown mesh part key: {:?}", String::from_utf8_lossy(x) diff --git a/world/src/mesh.rs b/world/src/mesh.rs index 4067fb8..c4a6372 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -328,6 +328,12 @@ pub fn import_mesh( debug!("dispersion is {d}"); } + // if node.name() == Some("fog") { + // eprintln!("{:#?}", p.material().volume().is_some()); + // eprintln!("{:#?}", p.material().ior()); + // eprintln!("{:#?}", p.material().transmission().is_some()); + // } + let g_attenuation = p.material().volume().map(|v| { let ref_dist = v.attenuation_distance(); let att = Vec3A::from_array(v.attenuation_color().map( @@ -352,6 +358,11 @@ pub fn import_mesh( let g_double_sided = bool_to_opt(p.material().double_sided(), "double sided"); + let hint_volume = bool_to_opt( + g_attenuation.is_some_and(|a| a.length() > 0.01), + "volume hint", + ); + let hint_hide_first_person = bool_to_opt( many_head_bones | vrm.hide_first_person.contains(&node.index()), "hide first person hint", @@ -399,6 +410,7 @@ pub fn import_mesh( tex_occlusion, hint_hide_first_person, hint_mirror, + hint_volume, // not supported by gltf hint_static: None, // TODO Set when instancing va_transmission: None, -- cgit v1.2.3-70-g09d2