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 Split out the IndirectParametersMetadata into CPU-populated and GPU-populated buffers. (#17863) 2025-02-18 00:53:44 +00:00
clustered_forward.wgsl Implement basic clustered decal projectors. (#17315) 2025-01-26 20:13:39 +00:00
fog.rs Remove Shader weak_handles from bevy_pbr (excluding meshlets). (#19365) 2025-05-27 22:32:47 +00:00
fog.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
forward_io.wgsl Add UV channel selection to StandardMaterial (#13200) 2024-05-13 18:23:09 +00:00
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 Allow clippy::too_many_arguments to lint without warnings (#17249) 2025-01-09 07:26:15 +00:00
mesh_bindings.wgsl Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
mesh_functions.wgsl Helper function for getting inverse model matrix in WGSL shaders (#10462) 2025-03-06 16:43:22 +00:00
mesh_preprocess.wgsl Fix false positive GPU frustum culling (#17939) 2025-02-20 05:35:21 +00:00
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 Batch skinned meshes on platforms where storage buffers are available. (#16599) 2024-12-10 17:50:03 +00:00
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 Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
parallax_mapping.wgsl Use global binding arrays for bindless resources. (#17898) 2025-02-21 05:55:36 +00:00
pbr_ambient.wgsl Revert "Replace Ambient Lights with Environment Map Lights (#17482)" (#18167) 2025-03-05 23:08:46 +00:00
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 Add missing bindless imports in pbr_prepass.wgsl. (#18110) 2025-03-02 09:12:18 +00:00
pbr_transmission.wgsl Update typos (#17126) 2025-01-03 17:44:26 +00:00
pbr_types.wgsl cleanup constants (#19831) 2025-06-27 07:02:03 +00:00
pbr.wgsl Implement basic clustered decal projectors. (#17315) 2025-01-26 20:13:39 +00:00
reset_indirect_batch_sets.wgsl Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
rgb9e5.wgsl Deferred Renderer (#9258) 2023-10-12 22:10:38 +00:00
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 Per-meshlet compressed vertex data (#15643) 2024-10-08 18:42:55 +00:00
view_transformations.wgsl Implement experimental GPU two-phase occlusion culling for the standard 3D mesh pipeline. (#17413) 2025-01-27 05:02:46 +00:00
wireframe.wgsl Add binned 2d/3d Wireframe render phase (#18587) 2025-04-09 21:34:53 +00:00