From a82dad99984c074136062f8cd34a91517b8c801c Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 7 Jan 2025 17:17:58 +0100 Subject: notes --- a.md | 38 +++++++++++++++++++------------------- world/src/main.rs | 28 ++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/a.md b/a.md index a320e6d..2a4669a 100644 --- a/a.md +++ b/a.md @@ -47,25 +47,25 @@ Combinations of g__, va__ and tex_* are multiplied except normal which is added. Defaults should be the identity for that operation, so default is 1 / white except normals are zero. -| Key | Value Type | -| ---------------- | ------------- | -| index | Resource | -| g_metallic | f32 | -| g_roughness | f32 | -| g_albedo | Vec3A | -| g_transmission | f32 | -| va_position | [Resource; 3] | -| va_normal | [Resource; 3] | -| va_texcoord | [Resource; 2] | -| va_roughness | Resource | -| va_metallic | Resource | -| va_albedo | [Resource; 3] | -| va_transmission | Resource | -| tex_normal | Resource | -| tex_roughness | Resource | -| tex_metallic | Resource | -| tex_albedo | Resource | -| tex_transmission | Resource | +| Key | Value Type | | +| ---------------- | ------------- | ---------------------- | +| index | Resource | | +| g_metallic | f32 | | +| g_roughness | f32 | | +| g_albedo | Vec3A | | +| g_transmission | f32 | | +| va_position | [Resource; 3] | | +| va_normal | [Resource; 3] | | +| va_texcoord | [Resource; 2] | | +| va_roughness | Resource | | +| va_metallic | Resource | | +| va_albedo | [Resource; 3] | | +| va_transmission | Resource | | +| tex_normal | Resource | | +| tex_roughness | Resource | Use only green channel | +| tex_metallic | Resource | Use only blue channel | +| tex_albedo | Resource | | +| tex_transmission | Resource | | ### Texture diff --git a/world/src/main.rs b/world/src/main.rs index 517f1e9..f0b10ff 100644 --- a/world/src/main.rs +++ b/world/src/main.rs @@ -2,7 +2,7 @@ use anyhow::{Result, bail}; use clap::Parser; use gltf::image::Source; -use log::{info, warn}; +use log::info; use rand::random; use std::{ fs::File, @@ -59,7 +59,7 @@ fn main() -> Result<()> { pos_y.push(p[1]); pos_z.push(p[2]); } - info!("vertex positions"); + info!("{} vertex positions", pos_x.len()); Ok::<_, anyhow::Error>([ store.set(&AttributeArray(pos_x).write_alloc())?, store.set(&AttributeArray(pos_y).write_alloc())?, @@ -79,7 +79,7 @@ fn main() -> Result<()> { normal_y.push(p[1]); normal_z.push(p[2]); } - info!("vertex normals"); + info!("{} vertex normals", normal_x.len()); Ok::<_, anyhow::Error>([ store.set(&AttributeArray(normal_x).write_alloc())?, store.set(&AttributeArray(normal_y).write_alloc())?, @@ -96,7 +96,7 @@ fn main() -> Result<()> { texcoord_u.push(p[0]); texcoord_v.push(p[1]); } - info!("vertex texture coordinates"); + info!("{} vertex texture coordinates", texcoord_u.len()); Ok::<_, anyhow::Error>([ store.set(&AttributeArray(texcoord_u).write_alloc())?, store.set(&AttributeArray(texcoord_v).write_alloc())?, @@ -111,6 +111,7 @@ fn main() -> Result<()> { .map(|e| e as u16) .array_chunks::<3>() .collect::>(); + info!("{} indecies", index.len() * 3); let index = Some(store.set(&IndexArray(index).write_alloc())?); let mut tex_albedo = None; @@ -133,6 +134,23 @@ fn main() -> Result<()> { &tex.texture().source().source(), )?); } + let mut tex_roughness = None; + let mut tex_metallic = None; + if let Some(tex) = p + .material() + .pbr_metallic_roughness() + .metallic_roughness_texture() + { + let r = load_texture( + "metallic+roughness", + &store, + path_base, + &buffers, + &tex.texture().source().source(), + )?; + tex_roughness = Some(r); + tex_metallic = Some(r); + } let g_metallic = Some(p.material().pbr_metallic_roughness().metallic_factor()); let g_roughness = Some(p.material().pbr_metallic_roughness().roughness_factor()); @@ -146,6 +164,8 @@ fn main() -> Result<()> { va_texcoord, tex_albedo, tex_normal, + tex_roughness, + tex_metallic, index, ..Part::default() } -- cgit v1.2.3-70-g09d2