bevy/crates
Martin Lysell b91a233acf
Fix AmbientLight::affects_lightmapped_meshes not working (#20083)
# Objective

Fix lightmapped materials not respecting the
AmbientLight::affects_lightmapped_meshes setting.

NOTE: This only makes the setting work on the forward renderer. Making
it work on the deferred renderer would probably require encoding more
information in the g-buffer or similar. Please advise if I missed some
obvious way to get it working on deferred.

## Solution

- Make ambient light conditionally applied depending on the
affects_lightmapped_meshes setting when material mesh i lightmapped
- Remove what looks to be leftover `Lights` (wgsl) members:
`environment_map_smallest_specular_mip_level`,
`environment_map_intensity`. (These where not present in the rust
equivalent `GpuLights` and was not used in the wgsl code)

## Open Questions
- Ambient light is also blended into the transmitted light if
`DIFFUSE_TRANSMISSION` is enabled on the material. Should that also be
guarded by the same conditional as the indirect contribution?

## Testing

Ran a modified version of the lightmaps example, where there is a bright
red ambient light added and the small cube do not have a lightmap added
(To be able to see ambient light applied to meshes without lightmaps)

---

## Showcase
### Main: Lightmap example with bright red ambient, small box have no
lightmap
<img width="613" height="601" alt="Main"
src="https://github.com/user-attachments/assets/a3f206d7-5a1e-4590-8c40-69d5c6e06ce0"
/>

(All meshes get ambient light even when `affects_lightmapped_meshes =
false`)

### This PR: Lightmap example with bright red ambient, small box have no
lightmap
<img width="612" height="602" alt="With fix"
src="https://github.com/user-attachments/assets/d1a149a5-8994-4572-909f-8788ba2c38fc"
/>

(Only the small box get ambient light when `affects_lightmapped_meshes =
false`)
2025-07-14 21:13:10 +00:00
..
bevy_a11y
bevy_animation remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_anti_aliasing Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
bevy_app Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
bevy_asset Fix a NestedLoader code path that failed to use its meta transform (#19117) 2025-07-14 20:15:47 +00:00
bevy_audio remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_camera consistently dont use smallvec default features (#19972) 2025-07-06 04:25:26 +00:00
bevy_color Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_core_pipeline Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
bevy_core_widgets Fix core widgets unconditionally enabling bevy_ui_picking_backend (#20055) 2025-07-14 20:55:42 +00:00
bevy_derive
bevy_dev_tools Add frame_time graph to fps_overlay v2 (#19277) 2025-07-09 16:59:21 +00:00
bevy_diagnostic Add max_history_length to EntityCountDiagnosticsPlugin (#20085) 2025-07-12 23:00:38 +00:00
bevy_dylib
bevy_ecs Prevent TOCTOU bugs in ComponentsQueuedRegistrator (#20016) 2025-07-14 20:41:18 +00:00
bevy_encase_derive
bevy_feathers Changing the notification protocol for core_widgets. (#20086) 2025-07-13 17:25:11 +00:00
bevy_gilrs remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_gizmos remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_gltf Fix glTF light orientation (#20122) 2025-07-14 13:20:18 +00:00
bevy_image Add zstd release note (#20053) 2025-07-14 20:53:26 +00:00
bevy_input Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
bevy_input_focus Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
bevy_internal make optional crates for mesh, camera, and light (#19997) 2025-07-07 07:35:32 +00:00
bevy_light Move IrradianceVolume to bevy_light (#20000) 2025-07-07 20:11:43 +00:00
bevy_log Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_macro_utils
bevy_math Rhombus sampling (#20082) 2025-07-14 21:05:42 +00:00
bevy_mesh remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_mikktspace
bevy_pbr Fix AmbientLight::affects_lightmapped_meshes not working (#20083) 2025-07-14 21:13:10 +00:00
bevy_picking Bump typos to 1.34.0 (#20013) 2025-07-07 20:15:06 +00:00
bevy_platform bevy_platform: clippy without default features (#19860) 2025-06-29 17:12:57 +00:00
bevy_ptr
bevy_reflect bevy_reflect: Use active_types instead of active_fields where appropriate (#19922) 2025-07-14 20:24:46 +00:00
bevy_remote formatting fix in bevy_remote cargo.toml (#20033) 2025-07-08 17:02:02 +00:00
bevy_render GpuReadbackPlugin: Allow reading only a part of a buffer (#20133) 2025-07-14 21:01:16 +00:00
bevy_scene Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_solari Fix visibility (re)use in Solari DI (#20113) 2025-07-13 19:33:09 +00:00
bevy_sprite Material, mesh, skin extraction optimization (#17976) 2025-07-09 06:23:44 +00:00
bevy_state Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
bevy_tasks
bevy_text consistently dont use smallvec default features (#19972) 2025-07-06 04:25:26 +00:00
bevy_time Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00
bevy_transform
bevy_ui FIX - RelativeCursorPosition Changed<> query filter (#20102) 2025-07-13 19:44:40 +00:00
bevy_ui_render UI gradients long hue paths fix (#20010) 2025-07-07 22:19:24 +00:00
bevy_utils Make Parallel<T> more T: !Default accessible (#17943) 2025-07-07 20:22:20 +00:00
bevy_window remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_winit Rename send_event and similar methods to write_event (#20017) 2025-07-07 22:05:16 +00:00