outfly/src/shading.rs

41 lines
949 B
Rust
Raw Normal View History

2024-04-16 14:27:17 +00:00
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::<JupitersRing>::default());
app.add_plugins(MaterialPlugin::<AsteroidSurface>::default());
}
}
2024-04-16 14:27:17 +00:00
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
pub struct JupitersRing {
pub alpha_mode: AlphaMode,
#[uniform(0)]
pub ring_radius: f32,
#[uniform(1)]
pub jupiter_radius: f32,
}
impl Material for JupitersRing {
fn fragment_shader() -> ShaderRef {
"shaders/jupiters_rings.wgsl".into()
}
fn alpha_mode(&self) -> AlphaMode {
self.alpha_mode
}
}
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
pub struct AsteroidSurface {
}
impl Material for AsteroidSurface {
fn fragment_shader() -> ShaderRef {
"shaders/material_asteroid.wgsl".into()
}
}