bevy/crates
robtfm a2992fcffd
Light Textures (#18031)
# Objective

add support for light textures (also known as light cookies, light
functions, and light projectors)


![image](https://github.com/user-attachments/assets/afdb23e2-b35f-4bf0-bf92-f883cd7db771)

## Solution

- add components:

```rs
/// Add to a [`PointLight`] to add a light texture effect.
/// A texture mask is applied to the light source to modulate its intensity,  
/// simulating patterns like window shadows, gobo/cookie effects, or soft falloffs.
pub struct PointLightTexture {
    /// The texture image. Only the R channel is read.
    pub image: Handle<Image>,
    /// The cubemap layout. The image should be a packed cubemap in one of the formats described by the [`CubemapLayout`] enum.
    pub cubemap_layout: CubemapLayout,
}

/// Add to a [`SpotLight`] to add a light texture effect.
/// A texture mask is applied to the light source to modulate its intensity,  
/// simulating patterns like window shadows, gobo/cookie effects, or soft falloffs.
pub struct SpotLightTexture {
    /// The texture image. Only the R channel is read.
    /// Note the border of the image should be entirely black to avoid leaking light.
    pub image: Handle<Image>,
}

/// Add to a [`DirectionalLight`] to add a light texture effect.
/// A texture mask is applied to the light source to modulate its intensity,  
/// simulating patterns like window shadows, gobo/cookie effects, or soft falloffs.
pub struct DirectionalLightTexture {
    /// The texture image. Only the R channel is read.
    pub image: Handle<Image>,
    /// Whether to tile the image infinitely, or use only a single tile centered at the light's translation
    pub tiled: bool,
}
```

- store images to the `RenderClusteredDecals` buffer
- read the image and modulate the lights
- add `light_textures` example to showcase the new features

## Testing

see light_textures example
2025-06-30 21:56:17 +00:00
..
bevy_a11y Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_animation Update petgraph requirement from 0.7 to 0.8 (#19878) 2025-06-30 16:56:00 +00:00
bevy_anti_aliasing Add UVec to_extents helper method (#19807) 2025-06-26 20:53:49 +00:00
bevy_app Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_asset bevy_asset: fix clippy in wasm (#19865) 2025-06-29 20:36:53 +00:00
bevy_audio Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_color Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_core_pipeline bevy_solari ReSTIR DI (#19790) 2025-06-29 19:01:32 +00:00
bevy_core_widgets Bevy Feathers: an opinionated widget toolkit for building Bevy tooling (#19730) 2025-06-28 19:52:13 +00:00
bevy_derive Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_dev_tools Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_diagnostic updating: very very minorly (#19827) 2025-06-26 21:48:20 +00:00
bevy_dylib Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_ecs bevy_ecs: remove use of needless_return (#19859) 2025-06-29 17:12:33 +00:00
bevy_encase_derive Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_feathers Bevy Feathers: an opinionated widget toolkit for building Bevy tooling (#19730) 2025-06-28 19:52:13 +00:00
bevy_gilrs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_gizmos Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
bevy_gltf Nudge users into migrating to new default glTF coordinate conversion (#19816) 2025-06-28 18:35:41 +00:00
bevy_image optimize ktx2 level data concatenation (#19845) 2025-06-29 21:59:56 +00:00
bevy_input bevy_input: build warnings without bevy_reflect (#19862) 2025-06-29 17:13:43 +00:00
bevy_input_focus Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_internal Light Textures (#18031) 2025-06-30 21:56:17 +00:00
bevy_log Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_macro_utils Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_math Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_mesh Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_mikktspace Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_pbr Light Textures (#18031) 2025-06-30 21:56:17 +00:00
bevy_picking Upstream raycasting UVs (#19791) 2025-06-24 18:10:59 +00:00
bevy_platform bevy_platform: clippy without default features (#19860) 2025-06-29 17:12:57 +00:00
bevy_ptr Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_reflect Update petgraph requirement from 0.7 to 0.8 (#19878) 2025-06-30 16:56:00 +00:00
bevy_remote Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_render bevy_render: fix clippy on wasm (#19872) 2025-06-29 22:09:37 +00:00
bevy_scene Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_solari bevy_solari ReSTIR DI (#19790) 2025-06-29 19:01:32 +00:00
bevy_sprite Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
bevy_state Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_tasks Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_text Bevy Feathers: an opinionated widget toolkit for building Bevy tooling (#19730) 2025-06-28 19:52:13 +00:00
bevy_time Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_transform Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_ui Move TextShadow to text widget module (#19579) 2025-06-29 17:37:04 +00:00
bevy_utils bevy_utils: clippy without debug feature enabled (#19861) 2025-06-29 17:13:27 +00:00
bevy_window bevy_window: fix compilation without default features (#19870) 2025-06-30 20:51:52 +00:00
bevy_winit bevy_winit: fix compile and clippy on wasm (#19869) 2025-06-29 21:30:28 +00:00