add dummy material_asteroid.wgsl and shading::AsteroidSurface

This commit is contained in:
yuni 2024-04-16 16:41:15 +02:00
parent babbef279a
commit f56521e49f
4 changed files with 20 additions and 8 deletions

View file

@ -0,0 +1,9 @@
#import bevy_pbr::{
mesh_view_bindings::globals,
forward_io::VertexOutput,
}
@fragment
fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.4, 0.0, 1.0);
}

View file

@ -61,6 +61,7 @@ impl Plugin for OutFlyPlugin {
commands::CommandsPlugin, commands::CommandsPlugin,
effects::EffectsPlugin, effects::EffectsPlugin,
hud::HudPlugin, hud::HudPlugin,
shading::ShadingPlugin,
world::WorldPlugin, world::WorldPlugin,
)); ));
} }
@ -101,7 +102,7 @@ fn debug(
settings: Res<var::Settings>, settings: Res<var::Settings>,
keyboard_input: Res<ButtonInput<KeyCode>>, keyboard_input: Res<ButtonInput<KeyCode>>,
mut commands: Commands, mut commands: Commands,
mut materials_custom: ResMut<Assets<shading::JupitersRing>>, mut materials_custom: ResMut<Assets<shading::AsteroidSurface>>,
materials: Query<(Entity, &Name, &Handle<StandardMaterial>)>, materials: Query<(Entity, &Name, &Handle<StandardMaterial>)>,
) { ) {
if settings.dev_mode && keyboard_input.pressed(KeyCode::KeyP) { if settings.dev_mode && keyboard_input.pressed(KeyCode::KeyP) {
@ -110,12 +111,7 @@ fn debug(
dbg!(mat); dbg!(mat);
let mut entity = commands.entity(entity); let mut entity = commands.entity(entity);
entity.remove::<Handle<StandardMaterial>>(); entity.remove::<Handle<StandardMaterial>>();
let ring_radius = 229_000_000.0; let material = materials_custom.add(shading::AsteroidSurface {
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,
}); });
entity.insert(material); entity.insert(material);
} }

View file

@ -1,6 +1,14 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy::render::render_resource::{AsBindGroup, ShaderRef}; use bevy::render::render_resource::{AsBindGroup, ShaderRef};
pub struct ShadingPlugin;
impl Plugin for ShadingPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(MaterialPlugin::<JupitersRing>::default());
app.add_plugins(MaterialPlugin::<AsteroidSurface>::default());
}
}
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)] #[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
pub struct JupitersRing { pub struct JupitersRing {
pub alpha_mode: AlphaMode, pub alpha_mode: AlphaMode,

View file

@ -51,7 +51,6 @@ impl Plugin for WorldPlugin {
app.add_systems(PostUpdate, handle_despawn); app.add_systems(PostUpdate, handle_despawn);
app.add_systems(Update, spawn_despawn_asteroids); app.add_systems(Update, spawn_despawn_asteroids);
app.add_plugins(PhysicsPlugins::default()); app.add_plugins(PhysicsPlugins::default());
app.add_plugins(MaterialPlugin::<shading::JupitersRing>::default());
//app.add_plugins(PhysicsDebugPlugin::default()); //app.add_plugins(PhysicsDebugPlugin::default());
app.insert_resource(Gravity(DVec3::splat(0.0))); app.insert_resource(Gravity(DVec3::splat(0.0)));
app.insert_resource(AsteroidUpdateTimer( app.insert_resource(AsteroidUpdateTimer(