Skip to content

range

const range: TgpuComptime<(end) => TgpuRange & (start, end?, step?) => TgpuRange>

Defined in: packages/typegpu/src/std/range.ts:23

Returns an array of values between start (inclusive) and end (exclusive) with the given step.

If only one argument is provided, it is interpreted as end, with start=0 and step=1.

let result = d.f32(1);
for (const i of std.range(5)) {
result *= i + 1;
}

Can also be combined with tgpu.unroll to unroll a specific number of iterations.