bevy/examples/3d
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
..
3d_scene.rs Migrate cameras to required components (#15641) 2024-10-05 01:59:52 +00:00
3d_shapes.rs
3d_viewport_to_world.rs
animated_material.rs
anisotropy.rs Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
anti_aliasing.rs Make TAA non-experimental, fixes (#18349) 2025-06-02 16:04:08 +00:00
atmosphere.rs
atmospheric_fog.rs Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
auto_exposure.rs
blend_modes.rs
bloom_3d.rs
camera_sub_view.rs simplify example, replace get_single to Single Query (#16187) 2024-11-01 18:25:42 +00:00
clearcoat.rs Split Camera.hdr out into a new component (#18873) 2025-05-26 19:24:45 +00:00
clustered_decals.rs Light Textures (#18031) 2025-06-30 21:56:17 +00:00
color_grading.rs
decal.rs
deferred_rendering.rs
depth_of_field.rs
edit_material_on_gltf.rs Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
fog_volumes.rs
fog.rs Explanation for the 'classic' fog example (#19196) 2025-06-23 20:55:38 +00:00
generate_custom_mesh.rs
irradiance_volumes.rs Make IrradianceVolume require LightProbe (and document this). (#19621) 2025-06-13 17:09:31 +00:00
light_textures.rs Light Textures (#18031) 2025-06-30 21:56:17 +00:00
lighting.rs Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
lightmaps.rs
lines.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
load_gltf_extras.rs
load_gltf.rs
manual_material.rs Type erased materials (#19667) 2025-06-27 22:57:24 +00:00
mesh_ray_cast.rs
meshlet.rs Meshlet BVH Culling (#19318) 2025-06-29 00:04:21 +00:00
mixed_lighting.rs Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
motion_blur.rs
occlusion_culling.rs Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
order_independent_transparency.rs
orthographic.rs
parallax_mapping.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
parenting.rs
pbr.rs Fix pbr example text rotation (#19571) 2025-06-10 16:57:57 +00:00
pcss.rs Make TAA non-experimental, fixes (#18349) 2025-06-02 16:04:08 +00:00
post_processing.rs
query_gltf_primitives.rs
reflection_probes.rs
render_to_texture.rs
rotate_environment_map.rs
scrolling_fog.rs Make TAA non-experimental, fixes (#18349) 2025-06-02 16:04:08 +00:00
shadow_biases.rs
shadow_caster_receiver.rs
skybox.rs
solari.rs bevy_solari: RIS for Direct Lighting (#19620) 2025-06-23 00:47:10 +00:00
specular_tint.rs
spherical_area_lights.rs
split_screen.rs
spotlight.rs
ssao.rs Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
ssr.rs
texture.rs
tonemapping.rs Rename JustifyText to Justify (#19522) 2025-06-09 19:59:48 +00:00
transmission.rs Make TAA non-experimental, fixes (#18349) 2025-06-02 16:04:08 +00:00
transparency_3d.rs
two_passes.rs
update_gltf_scene.rs
vertex_colors.rs
visibility_range.rs
volumetric_fog.rs
wireframe.rs