diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-11 13:28:44 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-11 13:28:44 +0100 |
commit | a8c689a9f11badbdd10748d247e60ec47725dc36 (patch) | |
tree | 7a17933607a9cdf82be8e69dae4b0c0e3c277551 /client/src/scene_prepare.rs | |
parent | e9e5df5ff1e09356bf2ad0bcc82bbaee6a2acc0d (diff) | |
download | weareserver-a8c689a9f11badbdd10748d247e60ec47725dc36.tar weareserver-a8c689a9f11badbdd10748d247e60ec47725dc36.tar.bz2 weareserver-a8c689a9f11badbdd10748d247e60ec47725dc36.tar.zst |
add normal map bind group
Diffstat (limited to 'client/src/scene_prepare.rs')
-rw-r--r-- | client/src/scene_prepare.rs | 44 |
1 files changed, 29 insertions, 15 deletions
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<RMeshPart>)>); pub struct RMeshPart { pub index_count: u32, pub index: Arc<Buffer>, - pub position: Arc<Buffer>, - pub normal: Arc<Buffer>, - pub texcoord: Arc<Buffer>, - pub texture: Arc<BindGroup>, + pub va_position: Arc<Buffer>, + pub va_normal: Arc<Buffer>, + pub va_texcoord: Arc<Buffer>, + pub tex_albedo: Arc<BindGroup>, + pub tex_normal: Arc<BindGroup>, } 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, }), ); } |