From ccf6a082ac040c42e428fde771834b2043735cb5 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Fri, 26 Apr 2024 01:23:11 -0400 Subject: Switched to asset server reference for adding threshold map texture --- Cargo.toml | 2 +- README.md | 4 ++-- src/components.rs | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7999f88..efa9ba6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "grex_dither_post_process" -version = "0.1.1" +version = "0.1.2" edition = "2021" [dependencies.bevy] diff --git a/README.md b/README.md index 7c497cd..8633dff 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The effect is implemented as a bilevel ordered dither using a Bayer matrix with ![](./doc/screenshot_plant.png) Configuration Used: ```rs -grex_dither_post_process::components::DitherPostProcessSettings::new(3, images); +grex_dither_post_process::components::DitherPostProcessSettings::new(3, &asset_server); ``` ## Compatibility @@ -47,7 +47,7 @@ When spawning a camera: ```rs commands.spawn(( // Camera3dBundle... - grex_dither_post_process::components::DitherPostProcessSettings::new(level, images); + grex_dither_post_process::components::DitherPostProcessSettings::new(level, &asset_server); )); ``` diff --git a/src/components.rs b/src/components.rs index 99bf946..d22524c 100644 --- a/src/components.rs +++ b/src/components.rs @@ -10,7 +10,10 @@ use bevy::{ pub struct DitherPostProcessSettings(Handle); impl DitherPostProcessSettings { - pub fn new(level: u32,images: &mut ResMut>) -> Self { + pub fn new( + level: u32, + asset_server: &AssetServer, + ) -> Self { let power = level + 1; let map_size: u32 = 1 << power; let mut buffer = Vec::::new(); @@ -52,7 +55,7 @@ impl DitherPostProcessSettings { image.texture_descriptor.usage = TextureUsages::COPY_DST | TextureUsages::STORAGE_BINDING | TextureUsages::TEXTURE_BINDING; - let handle = images.add(image); + let handle = asset_server.add(image); Self(handle) } -- cgit v1.2.3