bevy/crates/bevy_pbr/src/render
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
..
build_indirect_params.wgsl
clustered_forward.wgsl
fog.rs Remove Shader weak_handles from bevy_pbr (excluding meshlets). (#19365) 2025-05-27 22:32:47 +00:00
fog.wgsl
forward_io.wgsl
gpu_preprocess.rs Make render and compute pipeline descriptors defaultable. (#19903) 2025-07-02 18:47:27 +00:00
light.rs bevy_light (#19991) 2025-07-07 00:07:38 +00:00
mesh_bindings.rs
mesh_bindings.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
mesh_functions.wgsl
mesh_preprocess.wgsl
mesh_types.wgsl cleanup constants (#19831) 2025-06-27 07:02:03 +00:00
mesh_view_bindings.rs bevy_light (#19991) 2025-07-07 00:07:38 +00:00
mesh_view_bindings.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
mesh_view_types.wgsl Fix AmbientLight::affects_lightmapped_meshes not working (#20083) 2025-07-14 21:13:10 +00:00
mesh.rs Fix crash on meshes with morphs + skins + motion blur when not using storage buffers (#20076) 2025-07-11 05:00:42 +00:00
mesh.wgsl
mod.rs Expose symbols needed to replicate SetMeshBindGroup in ecosystem crates. (#18613) 2025-03-31 18:27:40 +00:00
morph.rs Expose symbols needed to replicate SetMeshBindGroup in ecosystem crates. (#18613) 2025-03-31 18:27:40 +00:00
morph.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
occlusion_culling.wgsl
parallax_mapping.wgsl
pbr_ambient.wgsl
pbr_bindings.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
pbr_fragment.wgsl Fix SSAO specular occlusion roughness bug (#20067) 2025-07-11 05:01:15 +00:00
pbr_functions.wgsl Fix AmbientLight::affects_lightmapped_meshes not working (#20083) 2025-07-14 21:13:10 +00:00
pbr_lighting.wgsl Adjust specular_multiscatter to not take LightingInput (#20068) 2025-07-11 04:54:53 +00:00
pbr_prepass_functions.wgsl Fix shader pre-pass compile failure when using AlphaMode::Blend and a Mesh without UVs (0.16.0-rc.2) (#18602) 2025-03-30 01:25:42 +00:00
pbr_prepass.wgsl
pbr_transmission.wgsl
pbr_types.wgsl cleanup constants (#19831) 2025-06-27 07:02:03 +00:00
pbr.wgsl
reset_indirect_batch_sets.wgsl
rgb9e5.wgsl
shadow_sampling.wgsl Factor out up-choice in shadow cubemap sampling orthonormalize (#20052) 2025-07-11 12:19:02 +00:00
shadows.wgsl Split out spot_light_world_from_view into a function in shadows.wgsl (#20050) 2025-07-09 06:05:45 +00:00
skin.rs Material, mesh, skin extraction optimization (#17976) 2025-07-09 06:23:44 +00:00
skinning.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
utils.wgsl
view_transformations.wgsl
wireframe.wgsl Add binned 2d/3d Wireframe render phase (#18587) 2025-04-09 21:34:53 +00:00