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

Changing a material handle doesn't affect how an entity is rendered #858

Closed
mvlabat opened this issue Nov 13, 2020 · 0 comments · Fixed by #877
Closed

Changing a material handle doesn't affect how an entity is rendered #858

mvlabat opened this issue Nov 13, 2020 · 0 comments · Fixed by #877
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@mvlabat
Copy link
Contributor

mvlabat commented Nov 13, 2020

An example where this can be reproduced: https://github.com/mvlabat/muddle-run/blob/b2fc5d91a6b6d81ee94029924507db0acdedc42d/bins/desktop_client/src/main.rs.

This is where I define two different materials: https://github.com/mvlabat/muddle-run/blob/b2fc5d91a6b6d81ee94029924507db0acdedc42d/bins/desktop_client/src/main.rs#L55-L70

And this is the code where I swap the handles: https://github.com/mvlabat/muddle-run/blob/b2fc5d91a6b6d81ee94029924507db0acdedc42d/bins/desktop_client/src/main.rs#L328-335

I can see the logs printed, so I'm pretty certain that those branches are executed as expected. I also tried inserting debug logging of the material handles themselves, and I could see that they are changed too and no system changes them back somewhere in the middle.

@memoryruins suggested me in the Discord that I try to edit the material itself, like so:

if let Some((material, _)) = controllable_object {
    materials.get_mut(material.clone()).unwrap().albedo = if contacting {
        Color::rgb(0.85, 0.1, 0.1)
    } else {
        Color::rgb(0.87, 0.87, 0.87)
    };
}

After applying these changes, I could see the object rendered in different colours.

My guess is that Bevy's renderer doesn't detect changes in entities' material handles, so this is probably a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants