@thi.ng/shader-ast-stdlib
Version:
Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast
12 lines (11 loc) • 509 B
JavaScript
import { sub } from "@thi.ng/shader-ast/ast/ops";
import { $, $x, $y, $z } from "@thi.ng/shader-ast/ast/swizzle";
import { abs, max } from "@thi.ng/shader-ast/builtin/math";
const distChebyshev2 = (a, b) => max(abs(sub($x(a), $x(b))), abs(sub($y(a), $y(b))));
const distChebyshev3 = (a, b) => max(distChebyshev2(a, b), abs(sub($z(a), $z(b))));
const distChebyshev4 = (a, b) => max(distChebyshev2(a, b), distChebyshev2($(a, "zw"), $(b, "zw")));
export {
distChebyshev2,
distChebyshev3,
distChebyshev4
};