 fcd7c0fc3d
			
		
	
	
		fcd7c0fc3d
		
			
		
	
	
	
	
		
			
			Rebased and finished version of https://github.com/bevyengine/bevy/pull/8407. Huge thanks to @GitGhillie for adjusting all the examples, and the many other people who helped write this PR (@superdump , @coreh , among others) :) Fixes https://github.com/bevyengine/bevy/issues/8369 --- ## Changelog - Added a `brightness` control to `Skybox`. - Added an `intensity` control to `EnvironmentMapLight`. - Added `ExposureSettings` and `PhysicalCameraParameters` for controlling exposure of 3D cameras. - Removed the baked-in `DirectionalLight` exposure Bevy previously hardcoded internally. ## Migration Guide - If using a `Skybox` or `EnvironmentMapLight`, use the new `brightness` and `intensity` controls to adjust their strength. - All 3D scene will now have different apparent brightnesses due to Bevy implementing proper exposure controls. You will have to adjust the intensity of your lights and/or your camera exposure via the new `ExposureSettings` component to compensate. --------- Co-authored-by: Robert Swain <robert.swain@gmail.com> Co-authored-by: GitGhillie <jillisnoordhoek@gmail.com> Co-authored-by: Marco Buono <thecoreh@gmail.com> Co-authored-by: vero <email@atlasdostal.com> Co-authored-by: atlas dostal <rodol@rivalrebels.com>
		
			
				
	
	
		
			69 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! Loads and renders a glTF file as a scene.
 | |
| 
 | |
| use bevy::{
 | |
|     pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap},
 | |
|     prelude::*,
 | |
| };
 | |
| use std::f32::consts::*;
 | |
| 
 | |
| fn main() {
 | |
|     App::new()
 | |
|         .insert_resource(DirectionalLightShadowMap { size: 4096 })
 | |
|         .add_plugins(DefaultPlugins)
 | |
|         .add_systems(Startup, setup)
 | |
|         .add_systems(Update, animate_light_direction)
 | |
|         .run();
 | |
| }
 | |
| 
 | |
| fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
 | |
|     commands.spawn((
 | |
|         Camera3dBundle {
 | |
|             transform: Transform::from_xyz(0.7, 0.7, 1.0)
 | |
|                 .looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
 | |
|             ..default()
 | |
|         },
 | |
|         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,
 | |
|         },
 | |
|     ));
 | |
| 
 | |
|     commands.spawn(DirectionalLightBundle {
 | |
|         directional_light: DirectionalLight {
 | |
|             illuminance: 2000.0,
 | |
|             shadows_enabled: true,
 | |
|             ..default()
 | |
|         },
 | |
|         // This is a relatively small scene, so use tighter shadow
 | |
|         // cascade bounds than the default for better quality.
 | |
|         // We also adjusted the shadow map to be larger since we're
 | |
|         // only using a single cascade.
 | |
|         cascade_shadow_config: CascadeShadowConfigBuilder {
 | |
|             num_cascades: 1,
 | |
|             maximum_distance: 1.6,
 | |
|             ..default()
 | |
|         }
 | |
|         .into(),
 | |
|         ..default()
 | |
|     });
 | |
|     commands.spawn(SceneBundle {
 | |
|         scene: asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0"),
 | |
|         ..default()
 | |
|     });
 | |
| }
 | |
| 
 | |
| fn animate_light_direction(
 | |
|     time: Res<Time>,
 | |
|     mut query: Query<&mut Transform, With<DirectionalLight>>,
 | |
| ) {
 | |
|     for mut transform in &mut query {
 | |
|         transform.rotation = Quat::from_euler(
 | |
|             EulerRot::ZYX,
 | |
|             0.0,
 | |
|             time.elapsed_seconds() * PI / 5.0,
 | |
|             -FRAC_PI_4,
 | |
|         );
 | |
|     }
 | |
| }
 |