Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
raea-sys-shader-wgsl: a WGSL source read as text, split from raea-sys-shader
shinyobjectz0620a51e85b9
diff --git a/Cargo.lock b/Cargo.lockindex ce479c33..69af0cc2 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -15523,10 +15523,20 @@ dependencies = ["bevy","raea-sys-material","raea-sys-sampler",+ "raea-sys-shader-wgsl","serde_json","wgpu",]+[[package]]+name = "raea-sys-shader-wgsl"+version = "0.1.0"+dependencies = [+ "bevy",+ "raea-sys-material",+ "serde_json",+]+[[package]]name = "raea-sys-song"version = "0.1.0"diff --git a/Cargo.toml b/Cargo.tomlindex e783b4f5..d7c5ed88 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -24,6 +24,7 @@ members = ["systems/framepass","systems/compute","systems/phase",+ "systems/shader/wgsl","systems/sampler","systems/parity","systems/shader",diff --git a/systems/shader/Cargo.toml b/systems/shader/Cargo.tomlindex d6a7a2f5..d20cd6c9 100644--- a/systems/shader/Cargo.toml+++ b/systems/shader/Cargo.toml@@ -9,6 +9,7 @@ description = "Shaders written in TypeScript over the lit standard surface (docs[dependencies]raea-sys-material = { path = "../material" }raea-sys-sampler = { path = "../sampler" }+raea-sys-shader-wgsl = { path = "wgsl" }bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render", "bevy_ui", "bevy_ui_render"] }wgpu = "=30.0.1"serde_json = "1"diff --git a/systems/shader/src/lib.rs b/systems/shader/src/lib.rsindex 752759cb..ff79db2a 100644--- a/systems/shader/src/lib.rs+++ b/systems/shader/src/lib.rs@@ -28,8 +28,7 @@ use raea_sys_material::shader_material::{defs, ident, uniform, Uniform, SLOTS, Tmod ext_bind;pub mod bindings;-mod layout;-mod storage_layout;+use raea_sys_shader_wgsl::{layout, storage_layout};/// Uniforms packed in their declared types' WGSL layout (a compute's as written: raea-sys-compute written.rs).pub use layout::slots as uniform_slots;/// A storage buffer's words in its WGSL type's storage layout (a compute as written's own: raea-sys-compute slab.rs).@@ -37,7 +36,7 @@ pub use storage_layout::words as storage_words;pub mod own;pub mod own_live;pub mod ui;-mod ui_bind;+use raea_sys_shader_wgsl::ui_bind;/// The fragment shader every ShaderExt pipeline starts from, swapped in `specialize` for the material's own. It is a/// whole lit surface by itself (no hooks), so a material whose module is missing still draws as standard.diff --git a/systems/shader/wgsl/Cargo.toml b/systems/shader/wgsl/Cargo.tomlnew file mode 100644index 00000000..203c5862--- /dev/null+++ b/systems/shader/wgsl/Cargo.toml@@ -0,0 +1,12 @@+[package]+name = "raea-sys-shader-wgsl"+version = "0.1.0"+edition = "2024"+license = "FSL-1.1-ALv2"+publish = false+description = "A WGSL source read as text: own uniform structs' layout, storage buffers' words, and bindings renumbered into raea's slots (raea-sys-shader builds on it)"++[dependencies]+raea-sys-material = { path = "../../material" }+bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render"] }+serde_json = "1"diff --git a/systems/shader/src/layout.rs b/systems/shader/wgsl/src/layout.rssimilarity index 97%rename from systems/shader/src/layout.rsrename to systems/shader/wgsl/src/layout.rsindex 298e7e2a..766d2f8f 100644--- a/systems/shader/src/layout.rs+++ b/systems/shader/wgsl/src/layout.rs@@ -74,7 +74,7 @@ fn find_struct(src: &str, name: &str) -> Option<usize> {}/// A field's WGSL type as (scalar kind, components): f32, u32 or i32, alone or in a vec2/3/4-pub(crate) fn kind(t: &str) -> Option<(char, usize)> {+pub fn kind(t: &str) -> Option<(char, usize)> {let t = t.replace(' ', "");let scalar = |s: &str| match s {"f32" => Some('f'),@@ -97,7 +97,7 @@ pub(crate) fn kind(t: &str) -> Option<(char, usize)> {}/// One component's 32 bits as its kind ('f', 'u' or 'i', kind's) holds it: a u32 or i32 rounded, a u32 at least 0.-pub(crate) fn word(k: char, x: f32) -> u32 {+pub fn word(k: char, x: f32) -> u32 {match k {'f' => x.to_bits(),'u' => x.round().max(0.0) as u32,@@ -142,7 +142,7 @@ pub fn pack(fields: &[(String, String)], uniforms: &[(String, Vec4)]) -> Result</// an array or a colour and a struct from {field: value}. A value for a uniform the source doesn't declare is refused,/// as is a declared one without a value./// The first name given that isn't declared.-pub(crate) fn undeclared<'a>(given: &'a serde_json::Map<String, serde_json::Value>, declared: &[(String, String)]) -> Option<&'a String> {+pub fn undeclared<'a>(given: &'a serde_json::Map<String, serde_json::Value>, declared: &[(String, String)]) -> Option<&'a String> {given.keys().find(|k| !declared.iter().any(|(n, _)| n == *k))}diff --git a/systems/shader/wgsl/src/lib.rs b/systems/shader/wgsl/src/lib.rsnew file mode 100644index 00000000..86c8d2e5--- /dev/null+++ b/systems/shader/wgsl/src/lib.rs@@ -0,0 +1,7 @@+//! A WGSL source read as text (docs/control.feature FC2): an own uniform struct's fields and their uniform layout+//! (layout), a storage buffer's words in its type's storage layout (storage_layout), and a Material's or UI+//! material's bindings renumbered into raea's slots (ui_bind). raea-sys-shader builds its materials on them.++pub mod layout;+pub mod storage_layout;+pub mod ui_bind;diff --git a/systems/shader/src/storage_layout.rs b/systems/shader/wgsl/src/storage_layout.rssimilarity index 100%rename from systems/shader/src/storage_layout.rsrename to systems/shader/wgsl/src/storage_layout.rsdiff --git a/systems/shader/src/ui_bind.rs b/systems/shader/wgsl/src/ui_bind.rssimilarity index 99%rename from systems/shader/src/ui_bind.rsrename to systems/shader/wgsl/src/ui_bind.rsindex 471a6239..a79d6a7f 100644--- a/systems/shader/src/ui_bind.rs+++ b/systems/shader/wgsl/src/ui_bind.rs@@ -123,7 +123,7 @@ pub fn rebind_with(src: &str, groups: &[&str], what: &str, dims: bool, place: &d/// The spans of `src` under `@if(BINDLESS)`: the `{ ... }` block it opens, or the one statement it marks. raea's/// materials aren't bindless (Bevy sets BINDLESS only for one that is), so these compile out, their bindings as written.-pub(crate) fn bindless_spans(src: &str) -> Vec<std::ops::Range<usize>> {+pub fn bindless_spans(src: &str) -> Vec<std::ops::Range<usize>> {let mut out = Vec::new();for (i, m) in src.match_indices("@if(BINDLESS)") {let after = i + m.len();diff --git a/tools/layers.toml b/tools/layers.tomlindex 2afd2191..6255344c 100644--- a/tools/layers.toml+++ b/tools/layers.toml@@ -106,6 +106,7 @@ raea-sys-compute = "systems"raea-sys-phase = "systems"raea-sys-sampler = "systems"raea-sys-shader = "systems"+raea-sys-shader-wgsl = "systems"raea-sys-three-shader = "systems"raea-sys-post = "systems"raea-sys-fog = "systems"@@ -181,6 +182,8 @@ raea-sys-mesh = trueraea-sys-sampler = true# a shader's inputs, accessors and registration (surface shaders and frame passes share them)raea-sys-shader = true+# a WGSL source read as text: uniform and storage layouts, bindings renumbered (raea-sys-shader builds on it)+raea-sys-shader-wgsl = true# the pass mask (looks and the paint look read which pass drew each pixel)raea-sys-compose = true# ink outlines (the frame's look sets its camera's)