UNPKG

@thi.ng/shader-ast-stdlib

Version:

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

19 lines (18 loc) 648 B
import { F, V2, V3, V4 } from "@thi.ng/shader-ast/api/types"; import { defn, ret } from "@thi.ng/shader-ast/ast/function"; import { FLOAT1, float } from "@thi.ng/shader-ast/ast/lit"; import { add, mul } from "@thi.ng/shader-ast/ast/ops"; import { mod } from "@thi.ng/shader-ast/builtin/math"; const __permute = (type, suffix = "") => defn(type, `permute${suffix}`, [type], (v) => [ ret(mod(mul(v, add(mul(v, float(34)), FLOAT1)), float(289))) ]); const permute = __permute(F); const permute2 = __permute(V2, "2"); const permute3 = __permute(V3, "3"); const permute4 = __permute(V4, "4"); export { permute, permute2, permute3, permute4 };