bevyengine / bevyengine/bevy

Changes to textures does not propagate to materials

Open
#15,595 1 comment 0 reactions 0 assignees View on GitHub
A-Assets A-Rendering C-Bug D-Modest S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version
0.14.2

## What you did

I have a system that updates a texture from the cpu:

```Rust
pub fn update_visibility_texture(
visibility_grid: Res,
visiblity_texture: Res,
mut images: ResMut>,
) {
let handle = visiblity_texture.handle.clone();

if let Some(image) = images.get_mut(&handle) {
image.data.copy_from_slice(&visibility_grid.grid[..]);
}
}
```

## What went wrong

I expect the new texture data to be used when rendering. By any material that uses the same texture handle.

Instead the old texture is used when rendering.

## Additional information

I have a workaround where i manually cause the materials that use the texture to be marked as changed in the asset system.

```Rust
pub fn update_materials(
mut ground: ResMut>>,
mut trees: ResMut>>,
mut grass: ResMut>,
) {
for _ in ground.iter_mut() {}
for _ in grass.iter_mut() {}
for _ in trees.iter_mut() {}
}
```

My guess is that there is noting that connects the material asset to the texture assets that it depends on. If this is by design then feel free to close this !

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.