@thi.ng/shader-ast-stdlib
Version:
Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast
13 lines (12 loc) • 492 B
JavaScript
import { FLOAT0 } from "@thi.ng/shader-ast/ast/lit";
import { madd, mul } from "@thi.ng/shader-ast/ast/ops";
import { dot, max } from "@thi.ng/shader-ast/builtin/math";
import { fit1101 } from "../math/fit.js";
const lambert = (n, ldir) => max(dot(n, ldir), FLOAT0);
const halfLambert = (n, ldir) => fit1101(dot(n, ldir));
const diffuseLighting = (lambertian, diffuse, light, ambient) => madd(mul(light, lambertian), diffuse, ambient);
export {
diffuseLighting,
halfLambert,
lambert
};