bevy
bevy copied to clipboard
Quality of spot light shadows is worse after Bevy 0.10
Bevy version
0.10, main
Relevant system information
AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
SystemInfo { os: "MacOS 13.1 ", kernel: "22.2.0", cpu: "Apple M1 Max", core_count: "10", memory: "64.0 GiB" }
What you did
Replace the PointLight
in 3d_scene
with a SpotLight
pointed towards the cube.
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
}
/// set up a simple 3D scene
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// plane
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Plane::from_size(5.0).into()),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..default()
});
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
// light
commands.spawn(SpotLightBundle {
spot_light: SpotLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
// camera
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
}
What went wrong
left: Bevy 0.10, right: Bevy 0.9
Additional information
Spot lights use the same texture array as directional lights.
The default DirectionalLightShadowMap
size was ~~reduced to 1024
from 2048
~~ halved when cascade shadow maps were added.
The default DirectionalLightShadowMap size was reduced to 1024 from 2048 when cascade shadow maps were added.
Seems to be 2048
still:
https://github.com/bevyengine/bevy/tree/latest/crates/bevy_pbr/src/light.rs#L227-L231
Seems to be
2048
still: https://github.com/bevyengine/bevy/tree/latest/crates/bevy_pbr/src/light.rs#L227-L231
My bad, I meant to say 2048
and 4096
.
We just need to swap that number back presumably?
Probably not. That change was intentional to keep the total shadow map size the same.
4096^2 = 2048^2 * 4 cascades.
It just seems like an oversight that spot lights are using the same texture array and got "downgraded." I'm assuming that's done to conserve bind groups. I'm not very confident about that and have no idea what to do regardless.
Improved shadow filtering is coming that will probably make this mostly irrelevant. We could put spotlight shadows into a separate array texture though to be able to control their resolution independently. @robtfm just poking to make you aware of this comment.
yes this was done to conserve bindgroup entries. pcf shadows will help, but if the current directional quality is acceptable then when pcf lands we may want to reduce that texture size again ...
my immediate feeling is since it's configurable it's not a big issue that they share the array. if the bad initial experience is a problem we could just increase the default size?
I was thinking that if it's not a problem with number of texture bindings in the main pass, we could split them to make them independently configurable. Or I suppose we could use a viewport to render spotlights to a subset of the layer. Or we could render shadow maps to an atlas instead, which for point and spot lights is something I think is interesting to do.