From dbfe4a779005c1f86f20a5d8d2368593e9b13f5e Mon Sep 17 00:00:00 2001 From: yuni Date: Tue, 26 Nov 2024 23:57:01 +0100 Subject: [PATCH] aurora: disable backface culling, making it more visible from the inside --- src/cmd.rs | 8 ++++---- src/load.rs | 30 ++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/cmd.rs b/src/cmd.rs index 3c8719f..91658ba 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -1277,7 +1277,9 @@ fn spawn_entities( mut meshes: ResMut>, mut materials: ResMut>, mut materials_jupiter: ResMut>, - mut materials_aurora: ResMut>, + mut materials_aurora: ResMut< + Assets>, + >, mut id2pos: ResMut, mut achievement_tracker: ResMut, mut ew_updateavatar: EventWriter, @@ -1667,9 +1669,7 @@ fn spawn_entities( world::DespawnOnPlayerDeath, MaterialMeshBundle { mesh: meshes.add(Sphere::new(radius).mesh().uv(128, 128)), - material: materials_aurora.add(load::JupitersAurora { - alpha_mode: AlphaMode::Blend, - }), + material: materials_aurora.add(load::JupitersAurora::material()), transform: Transform::from_translation(absolute_pos.as_vec3()), ..default() }, diff --git a/src/load.rs b/src/load.rs index 7fb0178..848922f 100644 --- a/src/load.rs +++ b/src/load.rs @@ -19,7 +19,9 @@ pub struct LoadPlugin; impl Plugin for LoadPlugin { fn build(&self, app: &mut App) { app.add_plugins(MaterialPlugin::::default()); - app.add_plugins(MaterialPlugin::::default()); + app.add_plugins(MaterialPlugin::< + ExtendedMaterial, + >::default()); app.add_plugins(MaterialPlugin::::default()); app.add_plugins(MaterialPlugin::< ExtendedMaterial, @@ -117,12 +119,32 @@ pub struct JupitersAurora { pub alpha_mode: AlphaMode, } -impl Material for JupitersAurora { +impl MaterialExtension for JupitersAurora { fn fragment_shader() -> ShaderRef { "shaders/aurora.wgsl".into() } - fn alpha_mode(&self) -> AlphaMode { - self.alpha_mode +} + +impl Default for JupitersAurora { + fn default() -> Self { + Self { + alpha_mode: AlphaMode::default(), + } + } +} + +impl JupitersAurora { + pub fn material() -> ExtendedMaterial { + ExtendedMaterial { + base: StandardMaterial { + perceptual_roughness: 1.0, + alpha_mode: AlphaMode::Blend, + opaque_render_method: OpaqueRendererMethod::Auto, + cull_mode: None, + ..default() + }, + extension: Self::default(), + } } }