#include #assets #shader #glsl #hlsl

macro include-shader

A macro for including shader files as string with dependencies support

2 releases

Uses new Rust 2021

0.1.1 Oct 11, 2022
0.1.0 Oct 11, 2022

#624 in Development tools

MIT/Apache

14KB
219 lines

include-shader

A Rust macro for including shader files as string with dependencies support.

Setup

Although this library works on stable, your shader files changes might not be detected because of caching. Therefore, until track_path API stabilizes, it is recommended to use nightly so your shader files are tracked.

Nightly toolchain

For the best experience (shader files tracking), nightly is required.

Add the following to your Cargo.toml manifest file:

[dependencies]
include-shader = { version = "0.1.1", features = ["nightly"] }

Stable toolchain

Add the following to your Cargo.toml manifest file:

[dependencies]
include-shader = "0.1.1"

Example

use include_shader::include_shader;

fn main() {
   // ...
   let frag_shader = compile_shader(
       &context,
       WebGl2RenderingContext::FRAGMENT_SHADER,
       include_shader!("src/shaders/fragment_shader.glsl"),
   )?;
   // ...
}

Documentation

For more details on how to use this macro, see the documentation (docs.rs).

License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1–1.3MB
~38K SLoC