UNPKG

@thi.ng/shader-ast-stdlib

Version:

Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast

9 lines (8 loc) 330 B
import { vec4 } from "@thi.ng/shader-ast/ast/lit"; import { mul } from "@thi.ng/shader-ast/ast/ops"; import { $xyz } from "@thi.ng/shader-ast/ast/swizzle"; import { normalize } from "@thi.ng/shader-ast/builtin/math"; const surfaceNormal = (n, normalMat) => normalize($xyz(mul(normalMat, vec4(n, 0)))); export { surfaceNormal };