From 31ae23b7eb8cd0b688be07ae6cb4b5a96ee02a68 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Jan 2025 00:56:35 +0100 Subject: a --- world/src/main.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'world/src/main.rs') diff --git a/world/src/main.rs b/world/src/main.rs index 2823540..033d176 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -73,7 +73,14 @@ fn main() -> Result<()> { .array_chunks::<3>() .collect::>(); - if let Some(tex) = p.material().pbr_metallic_roughness().base_color_texture() {} + let mut albedo = None; + if let Some(tex) = p.material().pbr_metallic_roughness().base_color_texture() { + let s = tex.texture().source().source(); + if let gltf::image::Source::View { view, mime_type } = s { + let buf = &buffers[view.buffer().index()]; + albedo = Some(store.set(&buf.0)?); + } + } let part = store.set( &Part { @@ -91,11 +98,13 @@ fn main() -> Result<()> { Attribute::Vertex(store.set(&AttributeArray(uv_x).write_alloc())?), Attribute::Vertex(store.set(&AttributeArray(uv_y).write_alloc())?), ]), - va_pbr_albedo: Some([ - Attribute::Constant(0.9), - Attribute::Constant(0.1), - Attribute::Constant(0.1), - ]), + va_pbr_albedo: albedo.map(|a| { + [ + Attribute::Texture(a, 0), + Attribute::Texture(a, 1), + Attribute::Texture(a, 2), + ] + }), index: Some(store.set(&IndexArray(index).write_alloc())?), ..Part::default() } -- cgit v1.2.3-70-g09d2