pub(crate) static COMMON_WESL: &str = include_str!("common.wgsl");
pub(crate) static PBR_ENV_WESL: &str = include_str!("pbr_env.wgsl");
pub(crate) static ENV_DOWNSAMPLE_WESL: &str = include_str!("env_downsample.wgsl");
pub(crate) static TONEMAP_OPS_WESL: &str = include_str!("tonemap_ops.wgsl");
pub(crate) static SHADOW_DEPTH_WESL: &str = include_str!("shadow_depth.wgsl");
pub(crate) static SHADOW_TRANSMITTANCE_WESL: &str = include_str!("shadow_transmittance.wgsl");
pub(crate) fn compile_shader_with_common(modpath: &str, src: &str) -> String {
compile_wesl(
&[(modpath, src), ("package::common", COMMON_WESL)],
modpath,
&[],
)
}
pub(crate) fn compile_wesl(
modules: &[(&str, &str)],
root: &str,
features: &[(&str, bool)],
) -> String {
let mut resolver = wesl::VirtualResolver::new();
for (path, src) in modules {
resolver.add_module(
path.parse().expect("invalid WESL module path"),
(*src).into(),
);
}
let mut comp = wesl::Wesl::new("").set_custom_resolver(resolver);
comp.set_options(wesl::CompileOptions {
validate: false,
..Default::default()
});
for (name, on) in features {
comp.set_feature(name, *on);
}
comp.compile(&root.parse().expect("invalid WESL root module path"))
.unwrap_or_else(|e| panic!("WESL compilation of {} failed: {}", root, e))
.to_string()
}
pub use self::aov::{
AovKind, AovRenderer, DEPTH_AOV_FORMAT, NORMALS_AOV_FORMAT, SEGMENTATION_AOV_FORMAT,
};
pub use self::normals_material::{NormalsMaterial, NORMAL_FRAGMENT_SRC, NORMAL_VERTEX_SRC};
pub use self::object_material::{ObjectMaterial, OBJECT_FRAGMENT_SRC, OBJECT_VERTEX_SRC};
pub use self::uvs_material::{UvsMaterial, UVS_FRAGMENT_SRC, UVS_VERTEX_SRC};
pub use self::object_material2d::ObjectMaterial2d;
pub use self::shadow::{ShadowMapper, MAX_SHADOW_VIEWS};
mod aov;
pub(crate) mod clustered;
pub mod deform;
mod normals_material;
mod object_material;
mod shadow;
mod uvs_material;
mod object_material2d;