From f56521e49f913df1b339aca3be634fee805490dc Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 16 Apr 2024 16:41:15 +0200 Subject: [PATCH] add dummy material_asteroid.wgsl and shading::AsteroidSurface --- assets/shaders/material_asteroid.wgsl | 9 +++++++++ src/main.rs | 10 +++------- src/shading.rs | 8 ++++++++ src/world.rs | 1 - 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 assets/shaders/material_asteroid.wgsl diff --git a/assets/shaders/material_asteroid.wgsl b/assets/shaders/material_asteroid.wgsl new file mode 100644 index 0000000..5a935ae --- /dev/null +++ b/assets/shaders/material_asteroid.wgsl @@ -0,0 +1,9 @@ +#import bevy_pbr::{ + mesh_view_bindings::globals, + forward_io::VertexOutput, +} + +@fragment +fn fragment(in: VertexOutput) -> @location(0) vec4 { + return vec4(0.0, 0.4, 0.0, 1.0); +} diff --git a/src/main.rs b/src/main.rs index dac160b..51864dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,7 @@ impl Plugin for OutFlyPlugin { commands::CommandsPlugin, effects::EffectsPlugin, hud::HudPlugin, + shading::ShadingPlugin, world::WorldPlugin, )); } @@ -101,7 +102,7 @@ fn debug( settings: Res, keyboard_input: Res>, mut commands: Commands, - mut materials_custom: ResMut>, + mut materials_custom: ResMut>, materials: Query<(Entity, &Name, &Handle)>, ) { if settings.dev_mode && keyboard_input.pressed(KeyCode::KeyP) { @@ -110,12 +111,7 @@ fn debug( dbg!(mat); let mut entity = commands.entity(entity); entity.remove::>(); - let ring_radius = 229_000_000.0; - let jupiter_radius = 71_492_000.0; - let material = materials_custom.add(shading::JupitersRing { - alpha_mode: AlphaMode::Blend, - ring_radius: ring_radius, - jupiter_radius: jupiter_radius, + let material = materials_custom.add(shading::AsteroidSurface { }); entity.insert(material); } diff --git a/src/shading.rs b/src/shading.rs index 85880b1..c69cb7b 100644 --- a/src/shading.rs +++ b/src/shading.rs @@ -1,6 +1,14 @@ use bevy::prelude::*; use bevy::render::render_resource::{AsBindGroup, ShaderRef}; +pub struct ShadingPlugin; +impl Plugin for ShadingPlugin { + fn build(&self, app: &mut App) { + app.add_plugins(MaterialPlugin::::default()); + app.add_plugins(MaterialPlugin::::default()); + } +} + #[derive(Asset, TypePath, AsBindGroup, Debug, Clone)] pub struct JupitersRing { pub alpha_mode: AlphaMode, diff --git a/src/world.rs b/src/world.rs index ce64583..2b77c0a 100644 --- a/src/world.rs +++ b/src/world.rs @@ -51,7 +51,6 @@ impl Plugin for WorldPlugin { app.add_systems(PostUpdate, handle_despawn); app.add_systems(Update, spawn_despawn_asteroids); app.add_plugins(PhysicsPlugins::default()); - app.add_plugins(MaterialPlugin::::default()); //app.add_plugins(PhysicsDebugPlugin::default()); app.insert_resource(Gravity(DVec3::splat(0.0))); app.insert_resource(AsteroidUpdateTimer(