Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
c3c3953
feat: tgpu.comptime, tgpu.rawCodeSnippet and `this` allowed in TypeGPU
iwoplaza Nov 15, 2025
a10f989
Fix tests
iwoplaza Nov 15, 2025
34212f4
Better docs for rawCodeSnippet
iwoplaza Nov 15, 2025
f9bcd96
Docs for comptime
iwoplaza Nov 15, 2025
e07faa9
- Namable comptime - Turned `extensionEnabled` into a comptime function
iwoplaza Nov 20, 2025
9ff9990
Merge branch 'main' into feat/comptime-and-raw-code-snippet
iwoplaza Nov 20, 2025
9d9c2fe
Fixes
iwoplaza Nov 20, 2025
f294e3e
Add @typegpu/three package and Three.js integration example (very WIP)
iwoplaza Nov 20, 2025
6597b02
Update tgpuThree.ts
reczkok Jul 7, 2025
bd8f89a
Three.js types for example code view
iwoplaza Jul 22, 2025
8eebe1d
More tweaks and experiments
iwoplaza Jul 23, 2025
645bd4b
More work
iwoplaza Nov 20, 2025
3403392
A bit more work
iwoplaza Sep 11, 2025
f36ab45
More work
iwoplaza Nov 20, 2025
5b47386
Using @typegpu/noise in Three.js
iwoplaza Sep 19, 2025
14b4a2a
Add a new example
iwoplaza Sep 19, 2025
dd85138
Testing compute in Three.js
iwoplaza Nov 20, 2025
1d0e61e
Update examples
iwoplaza Nov 11, 2025
d03625c
Update typegpu-material.ts
iwoplaza Nov 11, 2025
d195d71
Update index.ts
iwoplaza Nov 20, 2025
12d554f
Some more work
iwoplaza Nov 12, 2025
473749a
Works again
iwoplaza Nov 12, 2025
f96ec92
TypeGPU compute shaders in TSL!
iwoplaza Nov 12, 2025
e74c1d4
A bit of a refactor of the cloth example
iwoplaza Nov 13, 2025
feb121b
Cleanup 🧹
iwoplaza Nov 13, 2025
62b58e2
Comparing Three and TypeGPU output
iwoplaza Nov 13, 2025
edb9c3e
triNoise3D in TypeGPU
iwoplaza Nov 13, 2025
8b5c1cd
comptime
iwoplaza Nov 20, 2025
f055ea8
Support for 'this' in TypeGPU shader functions
iwoplaza Nov 13, 2025
fe5cda4
Update verlet.ts
iwoplaza Nov 20, 2025
bdee185
feat: Attractors example (#1949)
aleksanderkatan Dec 3, 2025
e994076
Merge branch 'main' into feat/tgpu-three
iwoplaza Dec 10, 2025
d9e0446
Tweaks
iwoplaza Dec 10, 2025
2076be6
feat: Tweaks to feat/tgpu-three (#1954)
iwoplaza Dec 10, 2025
4ffd930
Some review fixes
iwoplaza Dec 10, 2025
0be03fb
Thumbnails and tags
iwoplaza Dec 10, 2025
4402f83
Comptime fromTSL
iwoplaza Dec 10, 2025
dac09e9
Update shellless.test.ts
iwoplaza Dec 10, 2025
0de6b04
fix: Calling `toTSL` multiple times (#1974)
aleksanderkatan Dec 16, 2025
70b2bd0
init
lursz Dec 17, 2025
e32f466
getting some errors
lursz Dec 17, 2025
2cff28a
pool works
lursz Dec 17, 2025
ac5e215
can see ducks
lursz Dec 17, 2025
7a6b5f5
clean up your room
lursz Dec 18, 2025
2cb8348
moved fns out
lursz Dec 18, 2025
7941dbb
feat: Inform user about type mismatches (#1988)
aleksanderkatan Dec 18, 2025
b399827
init not in index
lursz Dec 18, 2025
69f1db3
Merge branch 'feat/tgpu-three' into docs/duck
lursz Dec 18, 2025
5ca5c2f
Fix renderer resizing when browser zoom
iwoplaza Dec 18, 2025
16d0188
docs: Cloth example controls (#1986)
lursz Dec 18, 2025
7bfd811
Merge branch 'feat/tgpu-three' into docs/duck
lursz Dec 19, 2025
b31f66d
zooming bug fix
lursz Dec 19, 2025
a4e4cca
stuff in consts
lursz Dec 19, 2025
d2b674d
ducklings location fix
lursz Dec 19, 2025
ef344de
bug na bugu bug pogania
lursz Dec 19, 2025
3cc7730
vertex fix
lursz Jan 8, 2026
1805005
merge main
lursz Jan 8, 2026
b4e30ea
example controls
lursz Jan 8, 2026
1a3a24c
cya og-3js
lursz Jan 8, 2026
ba048f3
🦕🦕🦕
lursz Jan 8, 2026
a85db60
water fix
lursz Jan 8, 2026
eda29f1
move to consts
lursz Jan 8, 2026
5dbcf8b
Merge branch 'main' into docs/duck
lursz Jan 13, 2026
95ad4ee
final touch
lursz Jan 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions apps/typegpu-docs/src/examples/threejs/ducklings/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as d from 'typegpu/data';

// water
export const WIDTH = 256;
export const BOUNDS = 6;
export const BOUNDS_HALF = BOUNDS * 0.5;
export const limit = BOUNDS_HALF - 0.2;

export const waterMaxHeight = 0.1;

// ducklings
export const SPEED = 5.0;
export const NUM_DUCKS = 100;
export const DUCK_STRIDE = 3;
export const Y_OFFSET = -0.04;
export const VERTICAL_RESPONSE_FACTOR = 0.98;
export const WATER_PUSH_FACTOR = 0.015;
export const LINEAR_DAMPING = 0.92;
export const BOUNCE_DAMPING = -0.4;

// controls
export const INITIAL_VISCOSITY = 0.96;
export const INITIAL_MOUSE_SIZE = 0.12;
export const INITIAL_MOUSE_DEEP = 0.2;

//sun
export const SUN_POSITION = [-1, 2.6, 1.4];

// STRUCTS
export const NeighborIndices = d.struct({
northIndex: d.u32,
southIndex: d.u32,
eastIndex: d.u32,
westIndex: d.u32,
});

export const Normals = d.struct({
normalX: d.f32,
normalY: d.f32,
});
75 changes: 75 additions & 0 deletions apps/typegpu-docs/src/examples/threejs/ducklings/gpuHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import type * as t3 from '@typegpu/three';
import * as d from 'typegpu/data';
import * as std from 'typegpu/std';
import type { StorageBufferNode, UniformNode } from 'three/webgpu';
import { BOUNDS, NeighborIndices, Normals, WIDTH } from './consts.ts';

export function createGpuHelpers(
heightStorageA: t3.TSLAccessor<d.WgslArray<typeof d.f32>, StorageBufferNode>,
heightStorageB: t3.TSLAccessor<d.WgslArray<typeof d.f32>, StorageBufferNode>,
readFromA: t3.TSLAccessor<typeof d.u32, UniformNode<number>>,
) {
const getNeighborIndices = (index: number) => {
'use gpu';
const width = d.u32(WIDTH);
const x = d.i32(std.mod(index, WIDTH));
const y = d.i32(std.div(index, WIDTH));

const leftX = std.max(0, std.sub(x, 1));
const rightX = std.min(std.add(x, 1), std.sub(d.i32(width), 1));
const bottomY = std.max(0, std.sub(y, 1));
const topY = std.min(std.add(y, 1), std.sub(d.i32(width), 1));

const westIndex = d.u32(std.add(std.mul(y, d.i32(width)), leftX));
const eastIndex = d.u32(std.add(std.mul(y, d.i32(width)), rightX));
const southIndex = d.u32(std.add(std.mul(bottomY, d.i32(width)), x));
const northIndex = d.u32(std.add(std.mul(topY, d.i32(width)), x));

return NeighborIndices({ northIndex, southIndex, eastIndex, westIndex });
};

const getCurrentHeight = (index: number) => {
'use gpu';
return std.select(
heightStorageB.$[index],
heightStorageA.$[index],
readFromA.$ === 1,
);
};

const getCurrentNormals = (index: number) => {
'use gpu';
const neighbors = getNeighborIndices(index);
const north = std.select(
heightStorageB.$[neighbors.northIndex],
heightStorageA.$[neighbors.northIndex],
readFromA.$ === 1,
);
const south = std.select(
heightStorageB.$[neighbors.southIndex],
heightStorageA.$[neighbors.southIndex],
readFromA.$ === 1,
);
const east = std.select(
heightStorageB.$[neighbors.eastIndex],
heightStorageA.$[neighbors.eastIndex],
readFromA.$ === 1,
);
const west = std.select(
heightStorageB.$[neighbors.westIndex],
heightStorageA.$[neighbors.westIndex],
readFromA.$ === 1,
);

const normalX = std.mul(std.sub(west, east), std.div(WIDTH, BOUNDS));
const normalY = std.mul(std.sub(south, north), std.div(WIDTH, BOUNDS));

return Normals({ normalX, normalY });
};

return {
getNeighborIndices,
getCurrentHeight,
getCurrentNormals,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<canvas></canvas>
Loading