diff options
Diffstat (limited to 'world')
-rw-r--r-- | world/src/main.rs | 8 | ||||
-rw-r--r-- | world/src/mesh.rs | 19 |
2 files changed, 20 insertions, 7 deletions
diff --git a/world/src/main.rs b/world/src/main.rs index af32222..694d57b 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -78,12 +78,10 @@ fn main() -> Result<()> { Packet::Connect(random()).write(&mut sock)?; - // let (gltf, buffers, _) = gltf::import(&args.scene)?; let path_base = args.scene.parent().unwrap(); - - let gltf = Gltf::from_reader_without_validation(File::open(&args.scene)?)?; - - let buffers = import_buffers(&gltf, Some(path_base), None)?; + let mut gltf = Gltf::from_reader_without_validation(File::open(&args.scene)?)?; + let blob = gltf.blob.take(); + let buffers = import_buffers(&gltf, Some(path_base), blob)?; let mut prefab = Prefab::default(); diff --git a/world/src/mesh.rs b/world/src/mesh.rs index 1f19c28..7d17cc9 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -211,6 +211,17 @@ pub fn import_mesh( webp, )?); } + let mut tex_occlusion = None; + if let Some(tex) = p.material().occlusion_texture() { + tex_occlusion = Some(load_texture( + "occlusion", + &store, + path_base, + &buffers, + &tex.texture().source().source(), + webp, + )?); + } let mut tex_roughness = None; let mut tex_metallic = None; if let Some(tex) = p @@ -295,10 +306,12 @@ pub fn import_mesh( let g_attenuation = p.material().volume().map(|v| { let ref_dist = v.attenuation_distance(); - Vec3A::from_array(v.attenuation_color().map( + let att = Vec3A::from_array(v.attenuation_color().map( // manually derived from attenuation coefficient formula. i hope this is correct. |factor| -(factor.powf(1. / ref_dist)).ln(), - )) + )); + info!("attenuation is {att}"); + att }); let g_refractive_index = p.material().ior(); let g_thickness = p.material().volume().map(|v| v.thickness_factor()); @@ -314,6 +327,7 @@ pub fn import_mesh( .map(|e| e.contains_key("KHR_materials_unlit")) .unwrap_or(false) { + info!("unlit"); Some(()) } else { None @@ -346,6 +360,7 @@ pub fn import_mesh( tex_emission, tex_transmission, tex_thickness, + tex_occlusion, // not supported by gltf va_transmission: None, va_emission: None, |