add directional light, disable ambient light

This commit is contained in:
yuni 2024-03-16 23:37:18 +01:00
parent ec1f7cf96c
commit f337a6024c

View file

@ -3,6 +3,8 @@ use bevy::prelude::*;
use bevy::core_pipeline::Skybox;
use bevy::asset::LoadState;
use bevy::render::render_resource::{TextureViewDescriptor, TextureViewDimension};
use bevy::pbr::CascadeShadowConfigBuilder;
use std::f32::consts::PI;
#[derive(Resource)]
pub struct Cubemap {
@ -16,6 +18,7 @@ pub fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut ambient_light: ResMut<AmbientLight>,
asset_server: Res<AssetServer>,
) {
// Add skybox
@ -37,10 +40,10 @@ pub fn setup(
});
// Add spheres
let sphere_radius = 0.25;
let sphere_radius = 1.0;
let sphere_handle = meshes.add(Sphere::new(sphere_radius));
let white_handle = materials.add(StandardMaterial {
base_color: Color::WHITE,
base_color: Color::GRAY,
perceptual_roughness: 1.0,
..default()
});
@ -54,6 +57,43 @@ pub fn setup(
),
..default()
});
// Space is DARK
ambient_light.brightness = 0.0;
// Add Light
commands.spawn(PointLightBundle {
transform: Transform::from_xyz(5.0, 5.0, 0.0),
point_light: PointLight {
intensity: 0.0,
range: 500.0,
color: Color::WHITE,
shadows_enabled: true,
..default()
},
..default()
});
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: light_consts::lux::OVERCAST_DAY,
shadows_enabled: true,
..default()
},
transform: Transform::from_rotation(Quat::from_euler(
EulerRot::ZYX,
0.0,
PI / 2.,
-PI / 4.,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
first_cascade_far_bound: 7.0,
maximum_distance: 25.0,
..default()
}
.into(),
..default()
});
}
pub fn load_cubemap_asset(