# 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`
		
			
				
	
	
		
			70 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! Uses two windows to visualize a 3D model from different angles.
 | |
| 
 | |
| use bevy::{prelude::*, render::camera::RenderTarget, window::WindowRef};
 | |
| 
 | |
| fn main() {
 | |
|     App::new()
 | |
|         // By default, a primary window gets spawned by `WindowPlugin`, contained in `DefaultPlugins`
 | |
|         .add_plugins(DefaultPlugins)
 | |
|         .add_systems(Startup, setup_scene)
 | |
|         .add_systems(Update, bevy::window::close_on_esc)
 | |
|         .run();
 | |
| }
 | |
| 
 | |
| fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
 | |
|     // add entities to the world
 | |
|     commands.spawn(SceneBundle {
 | |
|         scene: asset_server.load("models/torus/torus.gltf#Scene0"),
 | |
|         ..default()
 | |
|     });
 | |
|     // light
 | |
|     commands.spawn(DirectionalLightBundle {
 | |
|         transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
 | |
|         ..default()
 | |
|     });
 | |
| 
 | |
|     let first_window_camera = commands
 | |
|         .spawn(Camera3dBundle {
 | |
|             transform: Transform::from_xyz(0.0, 0.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y),
 | |
|             ..default()
 | |
|         })
 | |
|         .id();
 | |
| 
 | |
|     // Spawn a second window
 | |
|     let second_window = commands
 | |
|         .spawn(Window {
 | |
|             title: "Second window".to_owned(),
 | |
|             ..default()
 | |
|         })
 | |
|         .id();
 | |
| 
 | |
|     let second_window_camera = commands
 | |
|         .spawn(Camera3dBundle {
 | |
|             transform: Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
 | |
|             camera: Camera {
 | |
|                 target: RenderTarget::Window(WindowRef::Entity(second_window)),
 | |
|                 ..default()
 | |
|             },
 | |
|             ..default()
 | |
|         })
 | |
|         .id();
 | |
| 
 | |
|     // Since we are using multiple cameras, we need to specify which camera UI should be rendered to
 | |
|     commands
 | |
|         .spawn((NodeBundle::default(), TargetCamera(first_window_camera)))
 | |
|         .with_children(|parent| {
 | |
|             parent.spawn(TextBundle::from_section(
 | |
|                 "First window",
 | |
|                 TextStyle::default(),
 | |
|             ));
 | |
|         });
 | |
|     commands
 | |
|         .spawn((NodeBundle::default(), TargetCamera(second_window_camera)))
 | |
|         .with_children(|parent| {
 | |
|             parent.spawn(TextBundle::from_section(
 | |
|                 "Second window",
 | |
|                 TextStyle::default(),
 | |
|             ));
 | |
|         });
 | |
| }
 |