bevyengine / bevyengine/bevy

Images loaded in RenderApp ignores ImageSettings

Open
#5,744 3 comments 1 reaction 0 assignees View on GitHub
A-Rendering C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

Bevy version 0.8
There's a texture I want to have FilterMode::Nearest.
I've tried to insert_resource(ImageSettings::default_nearest()) but I believe due to the circumstance when it get's loaded, the ImageSettings seems to be ignored.
the sampler get's set to FilterMode::Linear despite the ImageSetting.

The code:
```rs
pub struct ChunkTexture(pub Handle);

impl FromWorld for ChunkTexture {
fn from_world(world: &mut World) -> Self {
let asset_server = world.resource_mut::();
ChunkTexture(asset_server.load("textures/block_atlas.png"))
}
}
```
loading occurs here:

```rs
// no effect
app.insert_resource(ImageSettings::default_nearest())

app.sub_app_mut(RenderApp)
// no effect
.insert_resource(ImageSettings::default_nearest())
.init_resource::()
```
I'm currently getting around this by hacking together this (added the "core/main" app):
Which has the side effect of forcing all images to be nearest.
```rs
fn set_texture_filters_to_nearest(
mut texture_events: EventReader>,
mut textures: ResMut>,
) {
for event in texture_events.iter() {
if let AssetEvent::Created { handle } = event {
if let Some(mut texture) = textures.get_mut(handle) {
texture.sampler_descriptor = ImageSampler::nearest();
}
}
}
}
```

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.