@thi.ng/shader-ast-stdlib
Version:
Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast
15 lines (14 loc) • 440 B
JavaScript
import { F, V2, V3 } from "@thi.ng/shader-ast/api/types";
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
import { sub } from "@thi.ng/shader-ast/ast/ops";
import { length } from "@thi.ng/shader-ast/builtin/math";
const sdfCircle = defn(F, "sdCircle", [V2, F], (p, r) => [
ret(sub(length(p), r))
]);
const sdfSphere = defn(F, "sdSphere", [V3, F], (p, r) => [
ret(sub(length(p), r))
]);
export {
sdfCircle,
sdfSphere
};