Skip to content

Commit 054d272

Browse files
committed
utils from noise exported
1 parent ba7ff1e commit 054d272

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

packages/typegpu-noise/src/generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import tgpu, { d, type TgpuFnShell, type TgpuSlot } from 'typegpu';
22
import { cos, dot, fract } from 'typegpu/std';
3-
import { hash, u32To01Float } from './utils.ts';
3+
import { hash, u32To01F32 } from './utils.ts';
44

55
export interface StatefulGenerator {
66
seed?: (seed: number) => void;
@@ -83,7 +83,7 @@ export const XOROSHIRO64STARSTAR: StatefulGenerator = (() => {
8383
sample: randomGeneratorShell(() => {
8484
'use gpu';
8585
const r = next();
86-
return u32To01Float(r);
86+
return u32To01F32(r);
8787
}).$name('sample'),
8888
};
8989
})();
@@ -102,7 +102,7 @@ export const LCG32: StatefulGenerator = (() => {
102102
sample: randomGeneratorShell(() => {
103103
'use gpu';
104104
seed.$ = seed.$ * 1664525 + 1013904223; // % 2 ^ 32
105-
return u32To01Float(seed.$);
105+
return u32To01F32(seed.$);
106106
}).$name('sample'),
107107
};
108108
})();
@@ -121,7 +121,7 @@ export const LCG64: StatefulGenerator = (() => {
121121
sample: randomGeneratorShell(() => {
122122
'use gpu';
123123
seed.$ = seed.$ * 1664525 + 1013904223; // % 2 ^ 32
124-
return u32To01Float(seed.$);
124+
return u32To01F32(seed.$);
125125
}).$name('sample'),
126126
};
127127
})();

packages/typegpu-noise/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,11 @@ export {
154154
type StatefulGenerator,
155155
} from './generator.ts';
156156

157+
export {
158+
// utils
159+
hash,
160+
u32To01F32,
161+
} from './utils.ts';
162+
157163
export * as perlin2d from './perlin-2d/index.ts';
158164
export * as perlin3d from './perlin-3d/index.ts';

packages/typegpu-noise/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function quinticDerivative(t: d.vecBase): d.vecBase {
3232
/*
3333
* Converts u32 to f32 value in the range [0.0, 1.0).
3434
*/
35-
export const u32To01Float = tgpu.fn(
35+
export const u32To01F32 = tgpu.fn(
3636
[d.u32],
3737
d.f32,
3838
)((value) => {

0 commit comments

Comments
 (0)