@thi.ng/shader-ast-stdlib
Version:
Function collection for modular GPGPU / shader programming with @thi.ng/shader-ast
13 lines (12 loc) • 434 B
JavaScript
import { F, V2 } from "@thi.ng/shader-ast/api/types";
import { defn, ret } from "@thi.ng/shader-ast/ast/function";
import { mul, sub } from "@thi.ng/shader-ast/ast/ops";
import { $x, $y } from "@thi.ng/shader-ast/ast/swizzle";
const cross2 = defn(F, "cross2", [V2, V2], (a, b) => [
ret(sub(mul($x(a), $y(b)), mul($y(a), $x(b))))
]);
const crossC2 = (ax, ay, bx, by) => sub(mul(ax, by), mul(ay, bx));
export {
cross2,
crossC2
};