bevy
bevy copied to clipboard
Add support for environment map transformation
Objective
- Fixes: https://github.com/bevyengine/bevy/issues/14036
Solution
- Add a world space transformation for the environment sample direction.
Testing
- I have tested the newly added
transform
field using theclearcoat
example. - By combining with the Add support for skybox transformation, we can rotate both the skybox and the environment light map to achieve the correct rendering effect.
/// Spawns a camera with associated skybox and environment map.
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
+ let environment_rotation = Quat::from_rotation_y(PI * 0.125);
+
commands
.spawn(Camera3dBundle {
camera: Camera {
@@ -224,11 +226,13 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
.insert(Skybox {
brightness: 5000.0,
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
+ rotation: environment_rotation,
})
.insert(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: 2000.0,
+ rotation: environment_rotation,
});
}
Original
Rotate by 22.5 degrees around the Y-axis
Migration Guide
- Since we have added a new filed to the
EnvironmentMapLight
struct, users will need to include..Default::default()
or some rotation value in their initialization code.