Galactica/crates/render/src/shaderprocessor.rs

28 lines
610 B
Rust
Raw Normal View History

2024-01-10 17:53:27 -08:00
use crate::globaluniform::GlobalUniform;
2024-01-21 12:41:31 -08:00
// TODO: build script?
2024-01-10 17:53:27 -08:00
/// Basic wgsl preprocesser
pub(crate) fn preprocess_shader(
shader: &str,
global_uniform: &GlobalUniform,
global_uniform_group: u32,
) -> String {
// Insert dynamically-generated global definitions
let shader = shader.replace(
"// INCLUDE: global uniform header",
&global_uniform.shader_header(global_uniform_group),
);
// Insert common functions
let shader = shader.replace(
"// INCLUDE: anchor.wgsl",
&include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/shaders/include/",
"anchor.wgsl"
)),
);
return shader;
}