From 2731017aa88bf6baaff787d7486d4248f9ca6ca0 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 12 Jan 2025 20:33:59 +0100 Subject: double sided mesh attribute --- doc/resources.md | 3 +++ shared/src/resources.rs | 1 + world/src/mesh.rs | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/doc/resources.md b/doc/resources.md index d3d33eb..61a5781 100644 --- a/doc/resources.md +++ b/doc/resources.md @@ -48,6 +48,7 @@ white except normals are zero. | `g_dispersion` | `Float` | | | `g_thickness` | `Float` | | | `g_unlit` | | | +| `g_double_sided` | | | | `va_position` | `Res<[Vec3]>` | | | `va_normal` | `Res<[Vec3]>` | | | `va_texcoord` | `Res<[Vec2]>` | | @@ -79,6 +80,8 @@ white except normals are zero. [KHR_materials_dispersion]. - **Unlit**: Directly transfers \*_albedo to the screen if set. No lighting shaders are applied. See [KHR_materials_unlit] +- **Double Sided**: Disable backface culling for this mesh. Equivalent to + `material.doubleSided` of glTF 2.0. ## LightPart diff --git a/shared/src/resources.rs b/shared/src/resources.rs index f9e7242..ba45284 100644 --- a/shared/src/resources.rs +++ b/shared/src/resources.rs @@ -59,6 +59,7 @@ pub struct MeshPart { pub g_attenuation: Option, pub g_dispersion: Option, pub g_unlit: Option<()>, + pub g_double_sided: Option<()>, pub va_position: Option>>, pub va_normal: Option>>, pub va_texcoord: Option>>, diff --git a/world/src/mesh.rs b/world/src/mesh.rs index f66be82..fd6b6ae 100644 --- a/world/src/mesh.rs +++ b/world/src/mesh.rs @@ -298,6 +298,13 @@ pub fn import_mesh( None }; + let g_double_sided = if p.material().double_sided() { + info!("double sided"); + Some(()) + } else { + None + }; + let mesh = store.set(&MeshPart { name, index, @@ -312,6 +319,7 @@ pub fn import_mesh( g_refractive_index, g_dispersion, g_unlit, + g_double_sided, va_position, va_normal, va_texcoord, -- cgit v1.2.3-70-g09d2