use bevy::{
prelude::*,
render::{
extract_component::ExtractComponent, render_resource::ShaderType,
sync_world::SyncToRenderWorld,
},
};
#[derive(Component, Clone, Reflect)]
#[require(SyncToRenderWorld)]
pub struct AmbientLight2d {
pub color: Color,
pub intensity: f32,
}
impl Default for AmbientLight2d {
fn default() -> Self {
Self {
color: Color::WHITE,
intensity: 1.0,
}
}
}
#[derive(Reflect, Clone, ShaderType)]
pub struct RaymarchSettings {
pub max_steps: u32,
pub jitter_contrib: f32,
pub sharpness: f32,
}
impl Default for RaymarchSettings {
fn default() -> Self {
Self {
max_steps: 32,
jitter_contrib: 0.5,
sharpness: 5.0,
}
}
}
#[derive(Clone, ShaderType, Reflect)]
pub struct PenetrationSettings {
pub max: f32,
pub intensity: f32,
pub falloff: f32,
pub sample_directions: u32,
pub sample_steps: u32,
}
impl Default for PenetrationSettings {
fn default() -> Self {
Self {
max: 0.0,
intensity: 0.0,
falloff: 0.0,
sample_directions: 8,
sample_steps: 8,
}
}
}
#[derive(Component, Clone, Reflect, ExtractComponent)]
#[require(SyncToRenderWorld, AmbientLight2d)]
pub struct Lighting2dSettings {
pub raymarch: RaymarchSettings,
pub penetration: PenetrationSettings,
pub tint_occluders: bool,
pub scale: f32,
pub edge_intensity: f32,
pub blur: u32,
}
impl Default for Lighting2dSettings {
fn default() -> Self {
Self {
raymarch: Default::default(),
penetration: Default::default(),
tint_occluders: Default::default(),
scale: 0.5,
edge_intensity: 0.0,
blur: 0,
}
}
}