#load-image #configuration #bevy #config-file #texture #loading #bevy-plugin

bevy_image_config

Bevy plugin that automatically configures image assets when they load

2 unstable releases

0.2.0 Oct 12, 2022
0.1.0 Oct 11, 2022

#2302 in Game dev

MIT/Apache

24KB
211 lines

bevy_image_config

crates.io MIT/Apache 2.0 crates.io

Bevy plugin that automatically loads and applies image sampler settings for image assets from an accompanying configuration file.

Usage

Add the dependency to Cargo.toml:

bevy_image_config = "0.2"

Add the plugin to your app:

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(bevy_image_config::ImageConfigPlugin)
        // ..rest of app
        .run()
}

If you have an image file "image_file_name.img_ext" and a configuration file "image_file_name.img_cfg" in the same directory, the plugin will automatically load and apply the settings from "image_file_name.img_cfg.ron" when you load "image_file_name.img_ext".

The available settings are:

  • address_mode_u, address_mode_v, address_mode_w:
    ClampToEdge | Repeat | MirrorRepeat | ClampToBorder
    
  • min_filter, mag_filter, mipmap_filter:
    Nearest | Linear 
    
  • lod_min_clamp: f32,
  • lod_max_clamp: f32,
  • compare:
    Option of Never | Less | Equal | LessEqual | Greater | NotEqual | GreaterEqual | Always
    
  • anisotropy_clamp: Option<NonZeroU8>,
  • border_color:
    Option of TransparentBlack | OpaqueBlack | OpaqueWhite | Zero
    

Examples

cargo run --example example

Dependencies

~20–36MB
~562K SLoC