Mutating image data does have any effect #12122
-
Hi everyone! I am new to Bevy and I am am trying to achieve this: I have a constant stream of fn update_texture(
time: Res<Time>,
mut timer: ResMut<TextureUpdateTimer>,
query: Query<&View>,
mut images: ResMut<Assets<Image>>,
) {
if timer.0.tick(time.delta()).just_finished() {
for view in query.iter() {
if let Some(image) = images.get_mut(&game_view.image_handle) {
image.data = vec![255; 160 * 144 * 4];
}
}
} Unfortunately, the new image does not show. I created the image using |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I found the material which uses the image also needs to be updated (with the same pub struct CameraMaterial {
#[texture(0)]
#[sampler(1)]
source_image: Handle<Image>,
}
...
let image = images.get_mut(image_handle.clone()).unwrap();
image.data = decoded.to_vec();
let material = camera_materials.get_mut(material_handle).unwrap();
material.source_image = image_handle; |
Beta Was this translation helpful? Give feedback.
-
I was able to fix it by using a |
Beta Was this translation helpful? Give feedback.
I was able to fix it by using a
SpriteBundle
instead of aPbrBundle
. TheSpriteBundle
is sufficient for me but I don't really know why it didn't work with thePbrBundle
.