Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to textures does not propagate to materials #15595

Open
JoNil opened this issue Oct 2, 2024 · 1 comment
Open

Changes to textures does not propagate to materials #15595

JoNil opened this issue Oct 2, 2024 · 1 comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@JoNil
Copy link
Contributor

JoNil commented Oct 2, 2024

Bevy version

0.14.2

What you did

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 !

@JoNil JoNil added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Oct 2, 2024
@kristoff3r
Copy link
Contributor

This is a known / general issue described in #5069 (and other linked issues). It would be awesome to have a general solution for it.

@LiamGallagher737 LiamGallagher737 added A-Rendering Drawing game state to the screen A-Assets Load files from disk to use for things like images, models, and sounds and removed S-Needs-Triage This issue needs to be labelled labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Assets Load files from disk to use for things like images, models, and sounds A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

No branches or pull requests

3 participants