Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change light defaults & fix light examples #11581

Merged
merged 23 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions crates/bevy_pbr/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,29 @@ impl Default for DirectionalLight {
impl DirectionalLight {
pub const DEFAULT_SHADOW_DEPTH_BIAS: f32 = 0.02;
pub const DEFAULT_SHADOW_NORMAL_BIAS: f32 = 1.8;

/// The amount of light (lux) in a moonless, overcast night sky. (starlight)
pub const MOONLESS_NIGHT_LUX: f32 = 0.0001;
/// The amount of light (lux) in a full moon on a clear night.
pub const FULL_MOON_NIGHT_LUX: f32 = 0.05;
/// The amount of light (lux) in dark limit of civil twilight under a clear sky.
pub const CIVIL_TWILIGHT_LUX: f32 = 3.4;
/// The amount of light (lux) in a dark limit of civil twilight under a clear sky.
pub const LIVING_ROOM_LUX: f32 = 50.;
/// The amount of light (lux) in a office building hallway/toilet lighting.
pub const HALLWAY_LUX: f32 = 80.;
/// The amount of light (lux) in a family living room lights.
pub const DARK_OVERCAST_DAY_LUX: f32 = 100.;
/// The amount of light (lux) in a office.
pub const OFFICE_LUX: f32 = 320.;
/// The amount of light (lux) on Sunrise or sunset on a clear day.
pub const CLEAR_SUNRISE_LUX: f32 = 400.;
/// The amount of light (lux) on very dark overcast day.
pub const OVERCAST_DAY_LUX: 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.;
}

/// Controls the resolution of [`DirectionalLight`] shadow maps.
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/lighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -220,7 +220,7 @@ fn setup(
// directional 'sun' light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 100.0,
illuminance: DirectionalLight::OVERCAST_DAY_LUX,
shadows_enabled: true,
..default()
},
Expand Down
13 changes: 1 addition & 12 deletions examples/3d/pbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,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(
Expand Down Expand Up @@ -138,7 +127,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: 200.0,
},
));
}
Expand Down
14 changes: 8 additions & 6 deletions examples/3d/vertex_colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: DirectionalLight::OVERCAST_DAY_LUX,
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()
Expand Down
18 changes: 12 additions & 6 deletions examples/3d/wireframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use bevy::{
RenderPlugin,
},
};
use bevy_internal::render::camera::ExposureSettings;

fn main() {
App::new()
Expand Down Expand Up @@ -94,19 +95,24 @@ 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: 4000.0,
..default()
},
..default()
});

// camera
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
commands.spawn((
Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
},
ExposureSettings {
ev100: ExposureSettings::EV100_INDOOR,
},
));

// Text used to show controls
commands.spawn(
Expand Down
Loading