From ca040e96eca780eb934d2390ec7dab6e711e6589 Mon Sep 17 00:00:00 2001 From: Matthew Deville Date: Sun, 31 Aug 2025 15:08:00 +0200 Subject: [PATCH] wip --- Cargo.lock | 121 ------------------------------------------------ Cargo.toml | 1 - src/main.rs | 18 +------ src/material.rs | 30 ++++-------- 4 files changed, 10 insertions(+), 160 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac41390..45a3bc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -140,56 +140,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anstream" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" - -[[package]] -name = "anstyle-parse" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" -dependencies = [ - "windows-sys 0.60.2", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" -dependencies = [ - "anstyle", - "once_cell_polyfill", - "windows-sys 0.60.2", -] - [[package]] name = "approx" version = "0.5.1" @@ -1189,7 +1139,6 @@ name = "bevy_test" version = "0.1.0" dependencies = [ "bevy", - "clap", ] [[package]] @@ -1586,46 +1535,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "clap" -version = "4.5.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c5e4fcf9c21d2e544ca1ee9d8552de13019a42aa7dbf32747fa7aaf1df76e57" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fecb53a0e6fcfb055f686001bc2e2592fa527efaf38dbe81a6a9563562e57d41" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" - [[package]] name = "codespan-reporting" version = "0.11.1" @@ -1636,12 +1545,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "colorchoice" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" - [[package]] name = "combine" version = "4.6.7" @@ -2568,12 +2471,6 @@ dependencies = [ "mach2", ] -[[package]] -name = "is_terminal_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" - [[package]] name = "itertools" version = "0.13.0" @@ -3368,12 +3265,6 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" -[[package]] -name = "once_cell_polyfill" -version = "1.70.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" - [[package]] name = "orbclient" version = "0.3.48" @@ -3996,12 +3887,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - [[package]] name = "strum" version = "0.26.3" @@ -4353,12 +4238,6 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - [[package]] name = "uuid" version = "1.18.0" diff --git a/Cargo.toml b/Cargo.toml index 1d3750f..04f14a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,6 @@ [dependencies] bevy = { version = "0.16", features = ["file_watcher"] } - clap = { version = "4", features = ["derive"] } # Enable a small amount of optimization in the dev profile. [profile.dev] diff --git a/src/main.rs b/src/main.rs index 8a0db60..b171128 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,25 +2,11 @@ mod material; mod systems; -use { - bevy::{input::common_conditions::input_just_pressed, prelude::*, sprite::Material2dPlugin}, - clap::Parser, - std::path::PathBuf, -}; +use bevy::{input::common_conditions::input_just_pressed, prelude::*, sprite::Material2dPlugin}; -use material::{CustomMaterial, set_shader_path}; - -/// Simple program to compile and render a WGSL fragment shader. -#[derive(Debug, Parser)] -#[command(version, about, long_about = None)] -struct Args { - shader_path: PathBuf, -} +use material::CustomMaterial; fn main() { - let args = Args::parse(); - - set_shader_path(args.shader_path); App::new() .add_plugins(( DefaultPlugins, diff --git a/src/material.rs b/src/material.rs index 0522a72..5a1d694 100644 --- a/src/material.rs +++ b/src/material.rs @@ -1,22 +1,12 @@ -use { - bevy::{ - asset::{AssetEvent, AssetPath}, - prelude::*, - reflect::TypePath, - render::render_resource::{AsBindGroup, Shader, ShaderRef}, - sprite::{AlphaMode2d, Material2d}, - }, - std::{path::PathBuf, sync::OnceLock}, +use bevy::{ + asset::AssetEvent, + prelude::*, + reflect::TypePath, + render::render_resource::{AsBindGroup, Shader, ShaderRef}, + sprite::{AlphaMode2d, Material2d}, }; -// A runtime-configurable shader path. Set this from `main` before the Bevy App runs. -static SHADER_PATH: OnceLock = OnceLock::new(); - -/// Set the shader asset path (e.g. "shaders/my_shader.wgsl") to be used by `CustomMaterial`. -pub fn set_shader_path(path: PathBuf) { - // ignore if already set - let _ = SHADER_PATH.set(path); -} +const DEFAULT_SHADER_PATH: &str = "shaders/default.wgsl"; // This is the struct that will be passed to your shader #[derive(Asset, TypePath, AsBindGroup, Clone)] @@ -61,11 +51,7 @@ pub fn shader_hot_reload( impl Material2d for CustomMaterial { fn fragment_shader() -> ShaderRef { - if let Some(p) = SHADER_PATH.get() { - ShaderRef::from(AssetPath::from_path(p)) - } else { - ShaderRef::Default - } + DEFAULT_SHADER_PATH.into() } fn alpha_mode(&self) -> AlphaMode2d {