Skip to content

Commit d5d3d90

Browse files
committed
Using inexistent tgpu.superResolve API
1 parent 75c7744 commit d5d3d90

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ To improve performance, you can precompute the gradients using either a *Static*
131131
A static cache presumes that the domain of the noise function is fixed, and cannot change between shader invocations.
132132

133133
```ts twoslash
134-
// 2d
135134
import tgpu from 'typegpu';
136135
import * as d from 'typegpu/data';
136+
// ---cut---
137137
import { perlin3d } from '@typegpu/noise';
138138

139139
const root = await tgpu.init();
@@ -143,4 +143,30 @@ const main = tgpu['~unstable'].fn([])(() => {
143143
const value = perlin3d.sample(d.vec3f(0.5, 0, 0));
144144
const wrappedValue = perlin3d.sample(d.vec3f(10.5, 0, 0)); // the same as `value`!
145145
});
146-
```
146+
```
147+
Or in WebGPU:
148+
```ts
149+
/// <reference types="@webgpu/types" />
150+
import * as d from 'typegpu/data';
151+
152+
declare const device: GPUDevice;
153+
// ---cut---
154+
import tgpu from 'typegpu';
155+
import { perlin3d } from '@typegpu/noise';
156+
157+
const root = tgpu.initFromDevice({ device });
158+
const cache = perlin3d.staticCache({ root, size: d.vec3u(10, 10, 1) });
159+
160+
const { code, layouts, catchall } = tgpu.superResolve({
161+
template: `
162+
fn main() {
163+
let value = perlin3d.sample(vec3f(0.5, 0., 0.));
164+
let wrappedValue = perlin3d.sample(vec3f(10.5, 0., 0.)); // the same as 'value'!
165+
// ...
166+
}
167+
168+
// ...
169+
`,
170+
externals: { perlin3d },
171+
});
172+
```

0 commit comments

Comments
 (0)