I have a system that updates a texture from the cpu:
pub fn update_visibility_texture(
visibility_grid: Res<VisibilityGrid>,
visiblity_texture: Res<VisibilityTexture>,
mut images: ResMut<Assets<Image>>,
) {
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.
pub fn update_materials(
mut ground: ResMut<Assets<ExtendedMaterial<StandardMaterial, GroundMaterialExtension>>>,
mut trees: ResMut<Assets<ExtendedMaterial<StandardMaterial, TreeMaterialExtension>>>,
mut grass: ResMut<Assets<GrassMaterial>>,
) {
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 !
Bevy version
0.14.2
What you did
I have a system that updates a texture from the cpu:
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.
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 !