bevy/crates/bevy_pbr/src
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
..
atmosphere Add UVec to_extents helper method (#19807) 2025-06-26 20:53:49 +00:00
cluster Light Textures (#18031) 2025-06-30 21:56:17 +00:00
decal Light Textures (#18031) 2025-06-30 21:56:17 +00:00
deferred cleanup constants (#19831) 2025-06-27 07:02:03 +00:00
light Projection Improvements (#18458) 2025-06-24 03:26:38 +00:00
light_probe rename Transform::compute_matrix to to_matrix (#19646) 2025-06-18 05:37:25 +00:00
lightmap Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
meshlet Meshlet BVH Culling (#19318) 2025-06-29 00:04:21 +00:00
prepass Use SmallVec instead of HashMap in MaterialProperties (#19846) 2025-06-28 18:43:56 +00:00
render Light Textures (#18031) 2025-06-30 21:56:17 +00:00
ssao Add UVec to_extents helper method (#19807) 2025-06-26 20:53:49 +00:00
ssr Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
volumetric_fog Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
components.rs reexport entity set collections in entity module (#18413) 2025-03-30 03:51:14 +00:00
extended_material.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
fog.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
lib.rs Meshlet BVH Culling (#19318) 2025-06-29 00:04:21 +00:00
material_bind_groups.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
material.rs Use SmallVec instead of HashMap in MaterialProperties (#19846) 2025-06-28 18:43:56 +00:00
mesh_material.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
parallax.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
pbr_material.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
wireframe.rs Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00