UNPKG

@thi.ng/shader-ast-stdlib

Version:

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

10 lines (9 loc) 361 B
import { uvec2 } from "@thi.ng/shader-ast/ast/lit"; import { div, madd, modi } from "@thi.ng/shader-ast/ast/ops"; import { $x, $y } from "@thi.ng/shader-ast/ast/swizzle"; const indexToCoord = (i, width) => uvec2(modi(i, width), div(i, width)); const coordToIndex = (coord, width) => madd($y(coord), width, $x(coord)); export { coordToIndex, indexToCoord };