From a8c689a9f11badbdd10748d247e60ec47725dc36 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 11 Jan 2025 13:28:44 +0100 Subject: add normal map bind group --- client/src/scene_prepare.rs | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'client/src/scene_prepare.rs') diff --git a/client/src/scene_prepare.rs b/client/src/scene_prepare.rs index b5ac2cf..20c6e85 100644 --- a/client/src/scene_prepare.rs +++ b/client/src/scene_prepare.rs @@ -91,10 +91,11 @@ pub struct RPrefab(pub Vec<(Affine3A, Arc)>); pub struct RMeshPart { pub index_count: u32, pub index: Arc, - pub position: Arc, - pub normal: Arc, - pub texcoord: Arc, - pub texture: Arc, + pub va_position: Arc, + pub va_normal: Arc, + pub va_texcoord: Arc, + pub tex_albedo: Arc, + pub tex_normal: Arc, } impl ScenePreparer { @@ -220,23 +221,35 @@ impl ScenePreparer { .flatten() }; - let mut texture = None; + let mut tex_albedo = None; if let Some(albedores) = part.tex_albedo { if let Some((_tex, bg)) = self.textures.try_get(albedores) { - texture = Some(bg) + tex_albedo = Some(bg) } } else { if let Some((_tex, bg)) = self.placeholder_textures.try_get(()) { - texture = Some(bg) + tex_albedo = Some(bg) + } + } + let mut tex_normal = None; + if let Some(albedores) = part.tex_normal { + if let Some((_tex, bg)) = self.textures.try_get(albedores) { + tex_normal = Some(bg) + } + } else { + if let Some((_tex, bg)) = self.placeholder_textures.try_get(()) { + tex_normal = Some(bg) } } if let ( - Some(normal), + Some(va_normal), Some((index, index_count)), - Some(texcoord), - Some((position, _)), - ) = (normal, index, texcoord, position) + Some(va_texcoord), + Some((va_position, _)), + Some(tex_normal), + Some(tex_albedo), + ) = (normal, index, texcoord, position, tex_normal, tex_albedo) { debug!("part created ({pres})"); self.mesh_parts.insert( @@ -244,10 +257,11 @@ impl ScenePreparer { Arc::new(RMeshPart { index_count, index, - texcoord, - normal, - position, - texture: texture.unwrap(), + va_normal, + va_position, + va_texcoord, + tex_albedo, + tex_normal, }), ); } -- cgit v1.2.3-70-g09d2