pub mod compiled_color;
pub mod composition;
pub mod distortion;
pub mod dsl;
pub mod dsl_shader;
pub mod hatch;
pub mod motion;
pub mod noise;
pub mod outline;
pub mod palette;
pub mod rim;
#[cfg(any(feature = "glsl", feature = "hlsl", feature = "gpu"))]
pub mod scene_composer;
pub mod sdf_integration;
pub mod shader_glue;
pub mod sky;
pub mod toon;
use glam::Vec3;
#[derive(Debug, Clone, Copy)]
pub struct NprInput {
pub sdf: f32,
pub normal: Vec3,
pub view: Vec3,
pub light: Vec3,
pub position: Vec3,
}
impl NprInput {
#[inline]
#[must_use]
pub const fn new(sdf: f32, normal: Vec3, view: Vec3, light: Vec3, position: Vec3) -> Self {
Self {
sdf,
normal,
view,
light,
position,
}
}
#[inline]
#[must_use]
pub fn n_dot_l(&self) -> f32 {
self.normal.dot(self.light)
}
#[inline]
#[must_use]
pub fn n_dot_v(&self) -> f32 {
self.normal.dot(self.view)
}
}
pub type NprColor = Vec3;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn npr_input_n_dot_l_matches_manual() {
let n = Vec3::new(0.0, 1.0, 0.0);
let l = Vec3::new(0.0, 1.0, 0.0);
let input = NprInput::new(0.0, n, Vec3::Z, l, Vec3::ZERO);
assert!((input.n_dot_l() - 1.0).abs() < 1e-6);
}
#[test]
fn npr_input_n_dot_v_matches_manual() {
let n = Vec3::new(1.0, 0.0, 0.0);
let v = Vec3::new(1.0, 0.0, 0.0);
let input = NprInput::new(0.0, n, v, Vec3::Y, Vec3::ZERO);
assert!((input.n_dot_v() - 1.0).abs() < 1e-6);
}
}