Skip to content

Commit ea2fd1b

Browse files
committed
docs update
1 parent 92c8c50 commit ea2fd1b

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

apps/typegpu-docs/src/content/docs/ecosystem/typegpu-noise.mdx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,21 +290,17 @@ import {
290290
type StatefulGenerator,
291291
} from '@typegpu/noise';
292292

293-
export const LCG: StatefulGenerator = (() => {
293+
const LCG: StatefulGenerator = (() => {
294294
const seed = tgpu.privateVar(d.u32);
295295

296-
const u32To01Float = tgpu.fn([d.u32], d.f32)`(val){
297-
let exponent: u32 = 0x3f800000;
298-
let mantissa: u32 = 0x007fffff & val;
299-
var ufloat: u32 = (exponent | mantissa);
300-
return bitcast<f32>(ufloat) - 1f;
301-
}`;
296+
const u32To01Float = tgpu.fn([d.u32], d.f32)((value) => {
297+
const mantissa = value >> 9;
298+
const bits = 0x3F800000 | mantissa;
299+
const f = std.bitcastU32toF32(bits);
300+
return f - 1;
301+
});
302302

303303
return {
304-
seed: (value: number) => {
305-
'use gpu';
306-
seed.$ = d.u32(value * std.pow(32, 3));
307-
},
308304
seed2: (value: d.v2f) => {
309305
'use gpu';
310306
seed.$ = d.u32(value.x * std.pow(32, 3) + value.y * std.pow(32, 2));

apps/typegpu-docs/src/examples/tests/uniformity/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ export const controls = {
9696
.createPipeline(),
9797
], { names: namespace })
9898
)
99-
.map((r) => {
100-
root.device.createShaderModule({ code: r });
101-
});
99+
.map((r) => root.device.createShaderModule({ code: r }));
102100
},
103101
},
104102
};

packages/typegpu-noise/src/generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import tgpu, { type TgpuFn, type TgpuFnShell, type TgpuSlot } from 'typegpu';
1+
import tgpu, { type TgpuFnShell, type TgpuSlot } from 'typegpu';
22
import * as d from 'typegpu/data';
33
import { add, cos, dot, fract } from 'typegpu/std';
44

packages/typegpu-noise/src/random.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as d from 'typegpu/data';
33
import {
44
cos,
55
dot,
6-
length,
76
log,
87
mul,
98
normalize,
@@ -31,7 +30,7 @@ export const randSeed: TgpuFn<(seed: d.F32) => d.Void> = (() => {
3130

3231
return tgpu.fn([d.f32])((seed) => {
3332
if (seedSlotNotEmpty.$) {
34-
// @ts-ignore trust me
33+
// @ts-expect-error trust me
3534
randomGeneratorSlot.$.seed(seed);
3635
}
3736
});
@@ -48,7 +47,7 @@ export const randSeed2: TgpuFn<(seed: d.Vec2f) => d.Void> = (() => {
4847

4948
return tgpu.fn([d.vec2f])((seed) => {
5049
if (seedSlotNotEmpty.$) {
51-
// @ts-ignore trust me
50+
// @ts-expect-error trust me
5251
randomGeneratorSlot.$.seed2(seed);
5352
}
5453
});
@@ -65,7 +64,7 @@ export const randSeed3: TgpuFn<(seed: d.Vec3f) => d.Void> = (() => {
6564

6665
return tgpu.fn([d.vec3f])((seed) => {
6766
if (seedSlotNotEmpty.$) {
68-
// @ts-ignore trust me
67+
// @ts-expect-error trust me
6968
randomGeneratorSlot.$.seed3(seed);
7069
}
7170
});
@@ -82,7 +81,7 @@ export const randSeed4: TgpuFn<(seed: d.Vec4f) => d.Void> = (() => {
8281

8382
return tgpu.fn([d.vec4f])((seed) => {
8483
if (seedSlotNotEmpty.$) {
85-
// @ts-ignore trust me
84+
// @ts-expect-error trust me
8685
randomGeneratorSlot.$.seed4(seed);
8786
}
8887
});

0 commit comments

Comments
 (0)