diff options
Diffstat (limited to 'world/src')
-rw-r--r-- | world/src/main.rs | 21 |
1 files changed, 15 insertions, 6 deletions
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::<Vec<_>>(); - 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() } |