I have a very basic scene containing a plane, two cubes, a directional light and a camera.
The problem is that shadow projected onto the plane is cut-off at estimately z < 0.0.
Bevy version: 0.16.1
I tried a bunch of things:
- changing light angles
- splitting the plane into multiple smaller planes
- setting
CascadeShadowConfig
But i couldn't resolve the problem with the cast shadow.
Here is the code for the scene setup:
fn test_scene(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
Mesh3d(meshes.add(Rectangle::new(100.0, 100.0))),
MeshMaterial3d(materials.add(StandardMaterial {
base_color: Color::srgb(0.2, 0.7, 0.3),
..default()
})),
Transform::from_xyz(0.0, -8.0, 0.0).with_rotation(Quat::from_rotation_x(-FRAC_PI_2)),
));
let cube = meshes.add(Cuboid::from_size(Vec3::splat(16.0)));
let quat = Quat::from_rotation_y(FRAC_PI_4);
commands.spawn((
Mesh3d(cube.clone()),
MeshMaterial3d(materials.add(StandardMaterial {
base_color: Color::srgb(0.2, 0.2, 0.8),
..default()
})),
Transform::from_xyz(-20.0, 0.0, 20.0).with_rotation(quat),
));
commands.spawn((
Mesh3d(cube),
MeshMaterial3d(materials.add(StandardMaterial {
base_color: Color::srgb(0.8, 0.2, 0.2),
..default()
})),
Transform::from_xyz(15.0, 0.0, -6.0).with_rotation(quat),
));
commands.spawn((
DirectionalLight {
illuminance: 1_000.0,
shadows_enabled: true,
..default()
},
Transform::from_rotation(Quat::from_rotation_arc(
Vec3::NEG_Z,
Vec3::new(1.0, -0.9, -0.1).normalize(),
)),
));
commands.spawn((
Camera3d::default(),
Transform::from_xyz(0.0, 100.0, 100.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}