@thi.ng/shader-ast-stdlib
Version:
Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast
15 lines (14 loc) • 498 B
JavaScript
import { V2, V3 } from "@thi.ng/shader-ast/api/types";
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
import { FLOAT05 } from "@thi.ng/shader-ast/ast/lit";
import { mul, sub } from "@thi.ng/shader-ast/ast/ops";
import { mod } from "@thi.ng/shader-ast/builtin/math";
const $ = (n, type) => defn(type, `sdTxRepeat${n}`, [type, type], (p, c) => [
ret(sub(mod(p, c), mul(c, FLOAT05)))
]);
const sdfRepeat2 = $(2, V2);
const sdfRepeat3 = $(3, V3);
export {
sdfRepeat2,
sdfRepeat3
};