Change light defaults & fix light examples (#11581)
# Objective Fix https://github.com/bevyengine/bevy/issues/11577. ## Solution Fix the examples, add a few constants to make setting light values easier, and change the default lighting settings to be more realistic. (Now designed for an overcast day instead of an indoor environment) --- I did not include any example-related changes in here. ## Changelogs (not including breaking changes) ### bevy_pbr - Added `light_consts` module (included in prelude), which contains common lux and lumen values for lights. - Added `AmbientLight::NONE` constant, which is an ambient light with a brightness of 0. - Added non-EV100 variants for `ExposureSettings`'s EV100 constants, which allow easier construction of an `ExposureSettings` from a EV100 constant. ## Breaking changes ### bevy_pbr The several default lighting values were changed: - `PointLight`'s default `intensity` is now `2000.0` - `SpotLight`'s default `intensity` is now `2000.0` - `DirectionalLight`'s default `illuminance` is now `light_consts::lux::OVERCAST_DAY` (`1000.`) - `AmbientLight`'s default `brightness` is now `20.0`
This commit is contained in:
parent
bc98333d7c
commit
dc9b486650
@ -42,7 +42,7 @@ pub mod prelude {
|
||||
SpotLightBundle,
|
||||
},
|
||||
fog::{FogFalloff, FogSettings},
|
||||
light::{AmbientLight, DirectionalLight, PointLight, SpotLight},
|
||||
light::{light_consts, AmbientLight, DirectionalLight, PointLight, SpotLight},
|
||||
light_probe::{
|
||||
environment_map::{EnvironmentMapLight, ReflectionProbeBundle},
|
||||
LightProbe,
|
||||
|
@ -21,6 +21,61 @@ use bevy_utils::tracing::warn;
|
||||
|
||||
use crate::*;
|
||||
|
||||
/// Constants for operating with the light units: lumens, and lux.
|
||||
pub mod light_consts {
|
||||
/// Approximations for converting the wattage of lamps to lumens.
|
||||
///
|
||||
/// The **lumen** (symbol: **lm**) is the unit of [luminous flux], a measure
|
||||
/// of the total quantity of [visible light] emitted by a source per unit of
|
||||
/// time, in the [International System of Units] (SI).
|
||||
///
|
||||
/// For more information, see [wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit))
|
||||
///
|
||||
/// [luminous flux]: https://en.wikipedia.org/wiki/Luminous_flux
|
||||
/// [visible light]: https://en.wikipedia.org/wiki/Visible_light
|
||||
/// [International System of Units]: https://en.wikipedia.org/wiki/International_System_of_Units
|
||||
pub mod lumens {
|
||||
pub const LUMENS_PER_LED_WATTS: f32 = 90.0;
|
||||
pub const LUMENS_PER_INCANDESCENT_WATTS: f32 = 13.8;
|
||||
pub const LUMENS_PER_HALOGEN_WATTS: f32 = 19.8;
|
||||
}
|
||||
|
||||
/// Predefined for lux values in several locations.
|
||||
///
|
||||
/// The **lux** (symbol: **lx**) is the unit of [illuminance], or [luminous flux] per unit area,
|
||||
/// in the [International System of Units] (SI). It is equal to one lumen per square metre.
|
||||
///
|
||||
/// For more information, see [wikipedia](https://en.wikipedia.org/wiki/Lux)
|
||||
///
|
||||
/// [illuminance]: https://en.wikipedia.org/wiki/Illuminance
|
||||
/// [luminous flux]: https://en.wikipedia.org/wiki/Luminous_flux
|
||||
/// [International System of Units]: https://en.wikipedia.org/wiki/International_System_of_Units
|
||||
pub mod lux {
|
||||
/// The amount of light (lux) in a moonless, overcast night sky. (starlight)
|
||||
pub const MOONLESS_NIGHT: f32 = 0.0001;
|
||||
/// The amount of light (lux) during a full moon on a clear night.
|
||||
pub const FULL_MOON_NIGHT: f32 = 0.05;
|
||||
/// The amount of light (lux) during the dark limit of civil twilight under a clear sky.
|
||||
pub const CIVIL_TWILIGHT: f32 = 3.4;
|
||||
/// The amount of light (lux) in family living room lights.
|
||||
pub const LIVING_ROOM: f32 = 50.;
|
||||
/// The amount of light (lux) in an office building's hallway/toilet lighting.
|
||||
pub const HALLWAY: f32 = 80.;
|
||||
/// The amount of light (lux) in very dark overcast day
|
||||
pub const DARK_OVERCAST_DAY: f32 = 100.;
|
||||
/// The amount of light (lux) in an office.
|
||||
pub const OFFICE: f32 = 320.;
|
||||
/// The amount of light (lux) during sunrise or sunset on a clear day.
|
||||
pub const CLEAR_SUNRISE: f32 = 400.;
|
||||
/// The amount of light (lux) on a overcast day; typical TV studio lighting
|
||||
pub const OVERCAST_DAY: f32 = 1000.;
|
||||
/// The amount of light (lux) in full daylight (not direct sun).
|
||||
pub const FULL_DAYLIGHT: f32 = 10_000.;
|
||||
/// The amount of light (lux) in direct sunlight.
|
||||
pub const DIRECT_SUNLIGHT: f32 = 50_000.;
|
||||
}
|
||||
}
|
||||
|
||||
/// A light that emits light in all directions from a central point.
|
||||
///
|
||||
/// Real-world values for `intensity` (luminous power in lumens) based on the electrical power
|
||||
@ -58,7 +113,7 @@ impl Default for PointLight {
|
||||
fn default() -> Self {
|
||||
PointLight {
|
||||
color: Color::rgb(1.0, 1.0, 1.0),
|
||||
intensity: 800.0, // Roughly a 60W non-halogen incandescent bulb
|
||||
intensity: 2000.0, // Roughly a 20-watt LED bulb
|
||||
range: 20.0,
|
||||
radius: 0.0,
|
||||
shadows_enabled: false,
|
||||
@ -126,7 +181,7 @@ impl Default for SpotLight {
|
||||
// a quarter arc attenuating from the center
|
||||
Self {
|
||||
color: Color::rgb(1.0, 1.0, 1.0),
|
||||
intensity: 800.0, // Roughly a 60W non-halogen incandescent bulb
|
||||
intensity: 2000.0, // Roughly a 20-watt LED bulb
|
||||
range: 20.0,
|
||||
radius: 0.0,
|
||||
shadows_enabled: false,
|
||||
@ -207,7 +262,7 @@ impl Default for DirectionalLight {
|
||||
fn default() -> Self {
|
||||
DirectionalLight {
|
||||
color: Color::rgb(1.0, 1.0, 1.0),
|
||||
illuminance: 100000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: false,
|
||||
shadow_depth_bias: Self::DEFAULT_SHADOW_DEPTH_BIAS,
|
||||
shadow_normal_bias: Self::DEFAULT_SHADOW_NORMAL_BIAS,
|
||||
@ -567,7 +622,7 @@ fn calculate_cascade(
|
||||
/// # use bevy_ecs::system::ResMut;
|
||||
/// # use bevy_pbr::AmbientLight;
|
||||
/// fn setup_ambient_light(mut ambient_light: ResMut<AmbientLight>) {
|
||||
/// ambient_light.brightness = 20.0;
|
||||
/// ambient_light.brightness = 100.0;
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Resource, Clone, Debug, ExtractResource, Reflect)]
|
||||
@ -581,11 +636,17 @@ pub struct AmbientLight {
|
||||
impl Default for AmbientLight {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
color: Color::rgb(1.0, 1.0, 1.0),
|
||||
brightness: 8.0,
|
||||
color: Color::WHITE,
|
||||
brightness: 20.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl AmbientLight {
|
||||
pub const NONE: AmbientLight = AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 0.0,
|
||||
};
|
||||
}
|
||||
|
||||
/// Add this component to make a [`Mesh`](bevy_render::mesh::Mesh) not cast shadows.
|
||||
#[derive(Component, Reflect, Default)]
|
||||
|
@ -96,6 +96,16 @@ pub struct ExposureSettings {
|
||||
}
|
||||
|
||||
impl ExposureSettings {
|
||||
pub const SUNLIGHT: Self = Self {
|
||||
ev100: Self::EV100_SUNLIGHT,
|
||||
};
|
||||
pub const OVERCAST: Self = Self {
|
||||
ev100: Self::EV100_OVERCAST,
|
||||
};
|
||||
pub const INDOOR: Self = Self {
|
||||
ev100: Self::EV100_INDOOR,
|
||||
};
|
||||
|
||||
pub const EV100_SUNLIGHT: f32 = 15.0;
|
||||
pub const EV100_OVERCAST: f32 = 12.0;
|
||||
pub const EV100_INDOOR: f32 = 7.0;
|
||||
@ -116,9 +126,7 @@ impl ExposureSettings {
|
||||
|
||||
impl Default for ExposureSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
ev100: Self::EV100_INDOOR,
|
||||
}
|
||||
Self::INDOOR
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,13 +41,13 @@ fn setup(
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 250000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -30,13 +30,13 @@ fn setup(
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 250_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
@ -64,14 +64,13 @@ fn setup(
|
||||
));
|
||||
}
|
||||
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1500000.0,
|
||||
range: 100.,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(8.0, 16.0, 8.0),
|
||||
transform: Transform::from_xyz(8.0, 16.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -66,10 +66,7 @@ fn setup(
|
||||
// light
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_translation(Vec3::ONE).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 2000.0,
|
||||
..default()
|
||||
},
|
||||
directional_light: DirectionalLight::default(),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -25,7 +25,7 @@ fn setup(
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||
intensity: 1500.0,
|
||||
intensity: 1_000.0,
|
||||
},
|
||||
));
|
||||
|
||||
|
@ -289,7 +289,7 @@ fn setup(
|
||||
// Light
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 3000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -61,7 +61,7 @@ fn setup_terrain_scene(
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
color: Color::rgb(0.98, 0.95, 0.82),
|
||||
illuminance: 3000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -167,12 +167,12 @@ fn setup(
|
||||
}
|
||||
|
||||
// Light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -18,10 +18,6 @@ fn main() {
|
||||
App::new()
|
||||
.insert_resource(Msaa::Off)
|
||||
.insert_resource(DefaultOpaqueRendererMethod::deferred())
|
||||
.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 1.0 / 5.0f32,
|
||||
})
|
||||
.insert_resource(DirectionalLightShadowMap { size: 4096 })
|
||||
.add_plugins(DefaultPlugins)
|
||||
.insert_resource(Normal(None))
|
||||
@ -62,7 +58,7 @@ fn setup(
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||
intensity: 150.0,
|
||||
intensity: 250.0,
|
||||
},
|
||||
DepthPrepass,
|
||||
MotionVectorPrepass,
|
||||
@ -72,7 +68,7 @@ fn setup(
|
||||
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 4000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -17,10 +17,12 @@
|
||||
use bevy::{
|
||||
pbr::{NotShadowCaster, NotShadowReceiver},
|
||||
prelude::*,
|
||||
render::camera::ExposureSettings,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.insert_resource(AmbientLight::NONE)
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_systems(
|
||||
Startup,
|
||||
@ -41,6 +43,9 @@ fn setup_camera_fog(mut commands: Commands) {
|
||||
},
|
||||
..default()
|
||||
},
|
||||
// This is a dark scene,
|
||||
// increasing the exposure makes it easier to see
|
||||
ExposureSettings { ev100: 4.0 },
|
||||
));
|
||||
}
|
||||
|
||||
@ -114,8 +119,7 @@ fn setup_pyramid_scene(
|
||||
commands.spawn(PointLightBundle {
|
||||
transform: Transform::from_xyz(0.0, 1.0, 0.0),
|
||||
point_light: PointLight {
|
||||
intensity: 300_000.,
|
||||
range: 100.,
|
||||
intensity: 4_000.,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -57,10 +57,9 @@ fn setup(
|
||||
});
|
||||
|
||||
// Light up the scene.
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 100_000.0,
|
||||
range: 100.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
..default()
|
||||
},
|
||||
transform: camera_and_light_transform,
|
||||
|
@ -4,7 +4,7 @@
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::{
|
||||
pbr::CascadeShadowConfigBuilder,
|
||||
pbr::{light_consts, CascadeShadowConfigBuilder},
|
||||
prelude::*,
|
||||
render::camera::{ExposureSettings, PhysicalCameraParameters},
|
||||
};
|
||||
@ -14,8 +14,8 @@ fn main() {
|
||||
.add_plugins(DefaultPlugins)
|
||||
.insert_resource(Parameters(PhysicalCameraParameters {
|
||||
aperture_f_stops: 1.0,
|
||||
shutter_speed_s: 1.0 / 15.0,
|
||||
sensitivity_iso: 400.0,
|
||||
shutter_speed_s: 1.0 / 100.0,
|
||||
sensitivity_iso: 100.0,
|
||||
}))
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (update_exposure, movement, animate_light_direction))
|
||||
@ -207,7 +207,7 @@ fn setup(
|
||||
// directional 'sun' light
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 100.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -21,10 +21,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
..default()
|
||||
});
|
||||
|
||||
commands.spawn(Camera3dBundle {
|
||||
commands.spawn((Camera3dBundle {
|
||||
transform: Transform::from_xyz(-278.0, 273.0, 800.0),
|
||||
..default()
|
||||
});
|
||||
},));
|
||||
}
|
||||
|
||||
fn add_lightmaps_to_meshes(
|
||||
|
@ -25,13 +25,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||
intensity: 150.0,
|
||||
intensity: 250.0,
|
||||
},
|
||||
));
|
||||
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 2000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -59,10 +59,10 @@ fn setup(
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 8.0, 5.0),
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 8.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
|
@ -224,7 +224,7 @@ fn setup(
|
||||
.spawn(PointLightBundle {
|
||||
transform: Transform::from_xyz(1.8, 0.7, -1.1),
|
||||
point_light: PointLight {
|
||||
intensity: 50_000.0,
|
||||
intensity: 100_000.0, // Mini-sun point light
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -55,10 +55,10 @@ fn setup(
|
||||
});
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
transform: Transform::from_xyz(4.0, 5.0, -4.0),
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(4.0, 5.0, -4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! This example shows how to configure Physically Based Rendering (PBR) parameters.
|
||||
|
||||
use bevy::{asset::LoadState, prelude::*};
|
||||
use bevy::{asset::LoadState, prelude::*, render::camera::ExposureSettings};
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
@ -51,17 +51,6 @@ fn setup(
|
||||
..default()
|
||||
});
|
||||
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
transform: Transform::from_xyz(50.0, 50.0, 50.0),
|
||||
point_light: PointLight {
|
||||
intensity: 100_000_000.,
|
||||
range: 100.,
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
});
|
||||
|
||||
// labels
|
||||
commands.spawn(
|
||||
TextBundle::from_section(
|
||||
@ -132,8 +121,9 @@ fn setup(
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||
intensity: 150.0,
|
||||
intensity: 7000.0,
|
||||
},
|
||||
ExposureSettings::OVERCAST,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
use bevy::core_pipeline::Skybox;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::camera::ExposureSettings;
|
||||
|
||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||
|
||||
@ -105,14 +106,17 @@ fn spawn_scene(commands: &mut Commands, asset_server: &AssetServer) {
|
||||
|
||||
// Spawns the camera.
|
||||
fn spawn_camera(commands: &mut Commands) {
|
||||
commands.spawn(Camera3dBundle {
|
||||
camera: Camera {
|
||||
hdr: true,
|
||||
commands.spawn((
|
||||
Camera3dBundle {
|
||||
camera: Camera {
|
||||
hdr: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(-6.483, 0.325, 4.381).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(-6.483, 0.325, 4.381).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
ExposureSettings::OVERCAST,
|
||||
));
|
||||
}
|
||||
|
||||
// Creates the sphere mesh and spawns it.
|
||||
@ -150,7 +154,7 @@ fn spawn_reflection_probe(commands: &mut Commands, cubemaps: &Cubemaps) {
|
||||
environment_map: EnvironmentMapLight {
|
||||
diffuse_map: cubemaps.diffuse.clone(),
|
||||
specular_map: cubemaps.specular_reflection_probe.clone(),
|
||||
intensity: 150.0,
|
||||
intensity: 5000.0,
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -186,7 +190,7 @@ fn add_environment_map_to_camera(
|
||||
.insert(create_camera_environment_map_light(&cubemaps))
|
||||
.insert(Skybox {
|
||||
image: cubemaps.skybox.clone(),
|
||||
brightness: 150.0,
|
||||
brightness: 5000.0,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -305,7 +309,7 @@ fn create_camera_environment_map_light(cubemaps: &Cubemaps) -> EnvironmentMapLig
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: cubemaps.diffuse.clone(),
|
||||
specular_map: cubemaps.specular_environment_map.clone(),
|
||||
intensity: 150.0,
|
||||
intensity: 5000.0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,17 +89,7 @@ fn setup(
|
||||
// NOTE: we add the light to all layers so it affects both the rendered-to-texture cube, and the cube on which we display the texture
|
||||
// Setting the layer to RenderLayers::layer(0) would cause the main view to be lit, but the rendered-to-texture cube to be unlit.
|
||||
// Setting the layer to RenderLayers::layer(1) would cause the rendered-to-texture cube to be lit, but the main view to be unlit.
|
||||
commands.spawn((
|
||||
PointLightBundle {
|
||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)),
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
},
|
||||
RenderLayers::all(),
|
||||
));
|
||||
commands.spawn((DirectionalLightBundle::default(), RenderLayers::all()));
|
||||
|
||||
commands.spawn((
|
||||
Camera3dBundle {
|
||||
|
@ -3,7 +3,10 @@
|
||||
#[path = "../helpers/camera_controller.rs"]
|
||||
mod camera_controller;
|
||||
|
||||
use bevy::{pbr::ShadowFilteringMethod, prelude::*};
|
||||
use bevy::{
|
||||
pbr::{light_consts, ShadowFilteringMethod},
|
||||
prelude::*,
|
||||
};
|
||||
use camera_controller::{CameraController, CameraControllerPlugin};
|
||||
|
||||
fn main() {
|
||||
@ -68,7 +71,7 @@ fn setup(
|
||||
});
|
||||
builder.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 1500.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadow_depth_bias: 0.0,
|
||||
shadow_normal_bias: 0.0,
|
||||
shadows_enabled: true,
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use bevy::{
|
||||
pbr::{CascadeShadowConfigBuilder, NotShadowCaster, NotShadowReceiver},
|
||||
pbr::{light_consts, CascadeShadowConfigBuilder, NotShadowCaster, NotShadowReceiver},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
@ -92,7 +92,7 @@ fn setup(
|
||||
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 1500.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
@ -128,7 +128,7 @@ fn toggle_light(
|
||||
for mut light in &mut point_lights {
|
||||
light.intensity = if light.intensity == 0.0 {
|
||||
println!("Using PointLight");
|
||||
500_000.0
|
||||
1_000_000.0 // Mini-sun point light
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
@ -136,7 +136,7 @@ fn toggle_light(
|
||||
for mut light in &mut directional_lights {
|
||||
light.illuminance = if light.illuminance == 0.0 {
|
||||
println!("Using DirectionalLight");
|
||||
1500.0
|
||||
light_consts::lux::OVERCAST_DAY
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.insert_resource(AmbientLight::NONE)
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_systems(Startup, setup)
|
||||
.run();
|
||||
@ -15,10 +16,10 @@ fn setup(
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// camera
|
||||
commands.spawn(Camera3dBundle {
|
||||
commands.spawn((Camera3dBundle {
|
||||
transform: Transform::from_xyz(0.2, 1.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
},));
|
||||
|
||||
// plane
|
||||
commands.spawn(PbrBundle {
|
||||
@ -58,7 +59,7 @@ fn setup(
|
||||
.with_children(|children| {
|
||||
children.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 100_000.0,
|
||||
intensity: 4000.0,
|
||||
radius,
|
||||
color: Color::rgb(0.2, 0.2, 1.0),
|
||||
..default()
|
||||
|
@ -37,7 +37,6 @@ fn setup(
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 1500.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -2,11 +2,7 @@
|
||||
|
||||
use std::f32::consts::*;
|
||||
|
||||
use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
pbr::NotShadowCaster,
|
||||
prelude::*,
|
||||
};
|
||||
use bevy::{pbr::NotShadowCaster, prelude::*};
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
|
||||
fn main() {
|
||||
@ -15,11 +11,7 @@ fn main() {
|
||||
brightness: 4.0,
|
||||
..default()
|
||||
})
|
||||
.add_plugins((
|
||||
DefaultPlugins,
|
||||
FrameTimeDiagnosticsPlugin,
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(Update, (light_sway, movement))
|
||||
.run();
|
||||
@ -82,7 +74,7 @@ fn setup(
|
||||
transform: Transform::from_xyz(1.0 + x, 2.0, z)
|
||||
.looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X),
|
||||
spot_light: SpotLight {
|
||||
intensity: 100_000.0, // lumens
|
||||
intensity: 4000.0, // lumens
|
||||
color: Color::WHITE,
|
||||
shadows_enabled: true,
|
||||
inner_angle: PI / 4.0 * 0.85,
|
||||
@ -111,14 +103,14 @@ fn setup(
|
||||
}
|
||||
|
||||
// camera
|
||||
commands.spawn((Camera3dBundle {
|
||||
commands.spawn(Camera3dBundle {
|
||||
camera: Camera {
|
||||
hdr: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
},));
|
||||
});
|
||||
}
|
||||
|
||||
fn light_sway(time: Res<Time>, mut query: Query<(&mut Transform, &mut SpotLight)>) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
use bevy::{
|
||||
core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin},
|
||||
pbr::{
|
||||
ScreenSpaceAmbientOcclusionBundle, ScreenSpaceAmbientOcclusionQualityLevel,
|
||||
light_consts, ScreenSpaceAmbientOcclusionBundle, ScreenSpaceAmbientOcclusionQualityLevel,
|
||||
ScreenSpaceAmbientOcclusionSettings,
|
||||
},
|
||||
prelude::*,
|
||||
@ -14,7 +14,7 @@ use std::f32::consts::PI;
|
||||
fn main() {
|
||||
App::new()
|
||||
.insert_resource(AmbientLight {
|
||||
brightness: 750.0,
|
||||
brightness: light_consts::lux::OVERCAST_DAY,
|
||||
..default()
|
||||
})
|
||||
.add_plugins((DefaultPlugins, TemporalAntiAliasPlugin))
|
||||
@ -81,7 +81,7 @@ fn setup(
|
||||
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 3000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use bevy::{
|
||||
core_pipeline::tonemapping::Tonemapping,
|
||||
pbr::CascadeShadowConfigBuilder,
|
||||
pbr::{light_consts, CascadeShadowConfigBuilder},
|
||||
prelude::*,
|
||||
reflect::TypePath,
|
||||
render::{
|
||||
@ -76,7 +76,7 @@ fn setup(
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||
intensity: 150.0,
|
||||
intensity: 50.0,
|
||||
},
|
||||
));
|
||||
|
||||
@ -192,7 +192,7 @@ fn setup_basic_scene(
|
||||
DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
illuminance: 3000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_rotation(Quat::from_euler(
|
||||
|
@ -27,7 +27,7 @@ use bevy::{
|
||||
},
|
||||
pbr::{NotShadowCaster, PointLightShadowMap, TransmittedShadowReceiver},
|
||||
prelude::*,
|
||||
render::camera::TemporalJitter,
|
||||
render::camera::{ExposureSettings, TemporalJitter},
|
||||
render::view::ColorGrading,
|
||||
};
|
||||
|
||||
@ -35,7 +35,6 @@ use bevy::{
|
||||
use bevy::core_pipeline::experimental::taa::{
|
||||
TemporalAntiAliasBundle, TemporalAntiAliasPlugin, TemporalAntiAliasSettings,
|
||||
};
|
||||
|
||||
use rand::random;
|
||||
|
||||
fn main() {
|
||||
@ -311,7 +310,7 @@ fn setup(
|
||||
transform: Transform::from_xyz(-1.0, 1.7, 0.0),
|
||||
point_light: PointLight {
|
||||
color: Color::ANTIQUE_WHITE * 0.8 + Color::ORANGE_RED * 0.2,
|
||||
intensity: 60_000.0,
|
||||
intensity: 4_000.0,
|
||||
radius: 0.2,
|
||||
range: 5.0,
|
||||
shadows_enabled: true,
|
||||
@ -345,6 +344,7 @@ fn setup(
|
||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||
},
|
||||
BloomSettings::default(),
|
||||
ExposureSettings { ev100: 6.0 },
|
||||
));
|
||||
|
||||
// Controls Text
|
||||
@ -634,7 +634,7 @@ fn flicker_system(
|
||||
let c = (s * 7.0).cos() * 0.0125 + (s * 2.0).cos() * 0.025;
|
||||
let (mut light, mut light_transform) = light.single_mut();
|
||||
let mut flame_transform = flame.single_mut();
|
||||
light.intensity = 60_000.0 + 3000.0 * (a + b + c);
|
||||
light.intensity = 4_000.0 + 3000.0 * (a + b + c);
|
||||
flame_transform.translation = Vec3::new(-1.0, 1.23, 0.0);
|
||||
flame_transform.look_at(Vec3::new(-1.0 - c, 1.7 - b, 0.0 - a), Vec3::X);
|
||||
flame_transform.rotate(Quat::from_euler(EulerRot::XYZ, 0.0, 0.0, PI / 2.0));
|
||||
|
@ -18,13 +18,14 @@ fn setup(
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// opaque plane, uses `alpha_mode: Opaque` by default
|
||||
// Opaque plane, uses `alpha_mode: Opaque` by default
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Plane3d::default().mesh().size(6.0, 6.0)),
|
||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
||||
..default()
|
||||
});
|
||||
// transparent sphere, uses `alpha_mode: Mask(f32)`
|
||||
|
||||
// Transparent sphere, uses `alpha_mode: Mask(f32)`
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
||||
material: materials.add(StandardMaterial {
|
||||
@ -41,7 +42,8 @@ fn setup(
|
||||
transform: Transform::from_xyz(1.0, 0.5, -1.5),
|
||||
..default()
|
||||
});
|
||||
// transparent unlit sphere, uses `alpha_mode: Mask(f32)`
|
||||
|
||||
// Transparent unlit sphere, uses `alpha_mode: Mask(f32)`
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
||||
material: materials.add(StandardMaterial {
|
||||
@ -53,7 +55,8 @@ fn setup(
|
||||
transform: Transform::from_xyz(-1.0, 0.5, -1.5),
|
||||
..default()
|
||||
});
|
||||
// transparent cube, uses `alpha_mode: Blend`
|
||||
|
||||
// Transparent cube, uses `alpha_mode: Blend`
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::default()),
|
||||
// Notice how there is no need to set the `alpha_mode` explicitly here.
|
||||
@ -63,24 +66,27 @@ fn setup(
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
// opaque sphere
|
||||
|
||||
// Opaque sphere
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Sphere::new(0.5).mesh().ico(3).unwrap()),
|
||||
material: materials.add(Color::rgb(0.7, 0.2, 0.1)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, -1.5),
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1_000_000.0,
|
||||
|
||||
// Light
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
||||
// Camera
|
||||
commands.spawn(Camera3dBundle {
|
||||
transform: Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
|
@ -9,36 +9,39 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
/// set up a simple 3D scene
|
||||
/// Set up a simple 3D scene
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
) {
|
||||
// plane
|
||||
// Plane
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
|
||||
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
||||
..default()
|
||||
});
|
||||
// cube
|
||||
|
||||
// Cube
|
||||
commands.spawn(PbrBundle {
|
||||
mesh: meshes.add(Cuboid::default()),
|
||||
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 500_000.0,
|
||||
|
||||
// Light
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
||||
// Camera
|
||||
commands.spawn(Camera3dBundle {
|
||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
|
@ -19,7 +19,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(4.0, 25.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 2000.0,
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -42,17 +42,19 @@ fn setup(
|
||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 500_000.0,
|
||||
|
||||
// Light
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: light_consts::lux::OVERCAST_DAY,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
||||
// Camera
|
||||
commands.spawn(Camera3dBundle {
|
||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
|
@ -94,9 +94,9 @@ fn setup(
|
||||
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(0.0, 2.0, 0.0),
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
intensity: 2000.0,
|
||||
..default()
|
||||
},
|
||||
..default()
|
||||
|
@ -8,10 +8,6 @@ use bevy::{animation::RepeatAnimation, pbr::CascadeShadowConfigBuilder, prelude:
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 150.0,
|
||||
})
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -54,7 +50,6 @@ fn setup(
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 2000.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -47,14 +47,12 @@ fn setup(
|
||||
));
|
||||
|
||||
// Some light to see something
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1_500_000.,
|
||||
range: 100.,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(8., 16., 8.),
|
||||
transform: Transform::from_xyz(8., 16., 8.).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -44,11 +44,7 @@ fn setup(asset_server: Res<AssetServer>, mut commands: Commands) {
|
||||
..default()
|
||||
});
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
color: Color::WHITE,
|
||||
illuminance: 1000.0,
|
||||
..default()
|
||||
},
|
||||
directional_light: DirectionalLight::default(),
|
||||
transform: Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)),
|
||||
..default()
|
||||
});
|
||||
|
@ -79,12 +79,9 @@ fn setup(
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 5.0, 4.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight::default(),
|
||||
transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
@ -27,12 +27,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 5.0, 4.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight::default(),
|
||||
transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
@ -56,13 +56,12 @@ fn setup(
|
||||
});
|
||||
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1_000_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -7,7 +7,7 @@ fn main() {
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.insert_resource(AmbientLight {
|
||||
brightness: 0.03,
|
||||
brightness: 1.0,
|
||||
..default()
|
||||
})
|
||||
.insert_resource(ClearColor(Color::BLACK))
|
||||
@ -114,7 +114,7 @@ fn generate_bodies(
|
||||
p.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
color: Color::WHITE,
|
||||
intensity: 100_000.0,
|
||||
intensity: 500_000.0,
|
||||
range: 100.0,
|
||||
radius: star_radius,
|
||||
..default()
|
||||
|
@ -33,20 +33,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
});
|
||||
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..Default::default()
|
||||
},
|
||||
transform: Transform::from_xyz(-3.0, 2.0, -1.0),
|
||||
..Default::default()
|
||||
});
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..Default::default()
|
||||
},
|
||||
transform: Transform::from_xyz(3.0, 2.0, 1.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight::default(),
|
||||
transform: Transform::from_xyz(3.0, 2.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
@ -45,11 +45,8 @@ fn setup(
|
||||
|
||||
// light
|
||||
commands.spawn((
|
||||
PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
},
|
||||
Rotate,
|
||||
@ -66,12 +63,8 @@ fn setup(
|
||||
struct Rotate;
|
||||
|
||||
fn rotate_things(mut q: Query<&mut Transform, With<Rotate>>, time: Res<Time>) {
|
||||
for mut t in q.iter_mut() {
|
||||
t.translation = Vec3::new(
|
||||
time.elapsed_seconds().sin(),
|
||||
0.5,
|
||||
time.elapsed_seconds().cos(),
|
||||
) * 4.0;
|
||||
for mut t in &mut q {
|
||||
t.rotate_y(time.delta_seconds());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,14 +333,7 @@ fn setup(
|
||||
Rotates,
|
||||
));
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(DirectionalLightBundle::default());
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
|
@ -29,12 +29,9 @@ fn setup(
|
||||
material: standard_materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight::default(),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -123,13 +123,12 @@ fn setup(
|
||||
});
|
||||
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 300_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -190,7 +190,7 @@ fn setup(
|
||||
}
|
||||
}
|
||||
|
||||
commands.spawn(DirectionalLightBundle { ..default() });
|
||||
commands.spawn(DirectionalLightBundle::default());
|
||||
}
|
||||
|
||||
fn init_textures(args: &Args, images: &mut Assets<Image>) -> Vec<Handle<Image>> {
|
||||
|
@ -65,10 +65,6 @@ fn main() {
|
||||
moving: true,
|
||||
sync: args.sync,
|
||||
})
|
||||
.insert_resource(AmbientLight {
|
||||
color: Color::WHITE,
|
||||
brightness: 100.0,
|
||||
})
|
||||
.add_systems(Startup, setup)
|
||||
.add_systems(
|
||||
Update,
|
||||
@ -203,7 +199,6 @@ fn setup(
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 3000.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ fn setup(
|
||||
warn!(include_str!("warning_string.txt"));
|
||||
|
||||
const LIGHT_RADIUS: f32 = 0.3;
|
||||
const LIGHT_INTENSITY: f32 = 5.0;
|
||||
const LIGHT_INTENSITY: f32 = 10.0;
|
||||
const RADIUS: f32 = 50.0;
|
||||
const N_LIGHTS: usize = 100_000;
|
||||
|
||||
|
@ -149,11 +149,7 @@ fn setup_scene_after_load(
|
||||
if !scene_handle.has_light {
|
||||
info!("Spawning a directional light");
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
illuminance: 3000.0,
|
||||
shadows_enabled: false,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -41,12 +41,8 @@ fn setup(
|
||||
});
|
||||
|
||||
// Add a light source so we can see clearly.
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::ONE * 3.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
@ -57,12 +57,8 @@ fn setup(
|
||||
});
|
||||
|
||||
// Add a light source for better 3d visibility.
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::ONE * 3.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
@ -86,12 +86,8 @@ fn setup(
|
||||
});
|
||||
|
||||
// Add a light source for better 3d visibility.
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::ONE * 3.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
@ -55,12 +55,8 @@ fn setup(
|
||||
});
|
||||
|
||||
// Add a light source for better 3d visibility.
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::ONE * 3.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
@ -59,14 +59,7 @@ fn setup(
|
||||
let image_handle = images.add(image);
|
||||
|
||||
// Light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 500_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(DirectionalLightBundle::default());
|
||||
|
||||
let texture_camera = commands
|
||||
.spawn(Camera2dBundle {
|
||||
|
@ -156,13 +156,9 @@ pub(crate) mod test_setup {
|
||||
},
|
||||
Rotator,
|
||||
));
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 1_000_000.0,
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
commands.spawn(Camera3dBundle {
|
||||
|
@ -18,12 +18,8 @@ fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 150_000.0,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 5.0, 4.0),
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
|
||||
|
@ -47,13 +47,12 @@ fn setup(
|
||||
..default()
|
||||
});
|
||||
// light
|
||||
commands.spawn(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
intensity: 500_000.0,
|
||||
commands.spawn(DirectionalLightBundle {
|
||||
directional_light: DirectionalLight {
|
||||
shadows_enabled: true,
|
||||
..default()
|
||||
},
|
||||
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
||||
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
});
|
||||
// camera
|
||||
|
Loading…
Reference in New Issue
Block a user