`ImageSampler::get_or_init_descriptor` does not align with `ImagePlugin`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.15.1
## What you did
```rust
let image: Handle = asset_server.load_with_settings("image.png", |settings: &mut ImageLoaderSettings| {
let _desc = settings.sampler.get_or_init_descriptor();
});
```
## What went wrong
The act of initializing the descriptor changed the behavior of the sampling even though I did not modify any of the attributes.
The documentation of `ImageSampler::Default` implies that it will match whatever is configured in the `ImagePlugin`. However, initializing the descriptor from an enum value of `ImageSampler::Default` produces behavior that is different from the default behavior with `ImagePlugin`. The resulting initialized descriptor has all filtering fields set to `Nearest`, while the default behavior of `ImagePlugin` is to have all filtering fields set to `Linear`.
I would expect that both `ImageSampler::Default.get_or_init_descriptor()` match `ImagePlugin::default().default_sampler` and that `asset_server.load_with_setting(..)` provide a sampler configuration that matches how the `ImagePlugin` was configured at runtime.
In other words, the code below should only change the address mode. The filtering (and everything else) should match what was configured on the `ImagePlugin`.
```rust
let image: Handle = asset_server.load_with_settings("image.png", |settings: &mut ImageLoaderSettings| {
let mut desc = settings.sampler.get_or_init_descriptor();
desc.address_mode_u = ImageAddressMode::Repeat;
});
```
Contributor guide
Assessment
This issue has not been assessed yet.