Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 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
7941dbb
feat: Inform user about type mismatches (#1988)
aleksanderkatan Dec 18, 2025
5ca5c2f
Fix renderer resizing when browser zoom
iwoplaza Dec 18, 2025
16d0188
docs: Cloth example controls (#1986)
lursz Dec 18, 2025
a861927
feat: ThreeJS 'Compute Particles' with tgpu (#1947)
cieplypolar Dec 19, 2025
48a792b
feat: ThreeJS 'Compute Geometry' with tgpu (#1948)
cieplypolar Dec 19, 2025
3eaa5db
feat: ThreeJS 'Compute Snow Particles' example in tgpu (#1972)
cieplypolar Dec 19, 2025
10e82d9
fix: @typegpu/three toTSL should have a per-stage namespace (#1994)
iwoplaza Dec 22, 2025
3ee568d
Merge branch 'main' into feat/tgpu-three
iwoplaza Dec 22, 2025
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
6 changes: 6 additions & 0 deletions apps/typegpu-docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,15 @@ export default defineConfig({
label: '@typegpu/noise',
slug: 'ecosystem/typegpu-noise',
},
{
label: '@typegpu/three',
slug: 'ecosystem/typegpu-three',
badge: { text: 'new' },
},
{
label: '@typegpu/sdf',
slug: 'ecosystem/typegpu-sdf',
badge: { text: 'new' },
},
DEV && {
label: '@typegpu/color',
Expand Down
4 changes: 3 additions & 1 deletion apps/typegpu-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"@typegpu/color": "workspace:*",
"@typegpu/geometry": "workspace:*",
"@typegpu/noise": "workspace:*",
"@typegpu/three": "workspace:*",
"@typegpu/sdf": "workspace:*",
"three": "catalog:example",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"arktype": "catalog:",
Expand Down Expand Up @@ -68,9 +70,9 @@
"@types/babel__standalone": "^7.1.9",
"@types/babel__template": "^7.4.4",
"@types/babel__traverse": "^7.20.7",
"@types/dom-mediacapture-record": "^1.0.22",
"@types/node": "^24.7.0",
"@vitejs/plugin-basic-ssl": "^2.1.0",
"@types/three": "catalog:types",
"@webgpu/types": "catalog:types",
"astro-vtbot": "^2.1.6",
"autoprefixer": "^10.4.21",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Creative Commons Licence
Infinite, 3D Head Scan by Lee Perry-Smith is licensed under a Creative Commons Attribution 3.0 Unported License.
Based on a work at www.triplegangers.com.
Permissions beyond the scope of this license may be available at http://www.ir-ltd.net/
Please remember: Do what you want with the files, but always mention where you got them from...
101 changes: 101 additions & 0 deletions apps/typegpu-docs/src/content/docs/ecosystem/typegpu-three.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
title: "@typegpu/three"
---

[TSL (Three.js Shading Language)](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language#function) is a node-based shader composition system for Three.js. Shader logic and control flow is built up by composing special functions,
with a focus on composability, intuitive sharing of logic across modules and customizability. TypeGPU fits naturally into this system thanks to the `@typegpu/three` package. You can choose to write your TSL building blocks in TypeGPU, which has a few benefits:
- Control-flow like `if` statements and `for` loops makes use of familiar JavaScript syntax instead of special functions.
- The code you write is semantically valid JavaScript, with types flowing through each expression.
- Unit-testability, since you can call these functions on the CPU

Below are a select few cases comparing TSL and TypeGPU:

import { Card, CardGrid } from '@astrojs/starlight/components';

## Node definition

TSL:
```ts
const simulate = Fn(() => {
//
// ... TSL code ...
//
});
```

TypeGPU:
```ts twoslash
import * as t3 from '@typegpu/three';
// ---cut---
const simulate = t3.toTSL(() => {
'use gpu';
//
// ... TypeGPU code ...
//
});
```

## Function definition

TSL:
```ts
const oscSine = Fn(([t = time]) => {
return t.add(0.75).mul(Math.PI * 2).sin().mul(0.5).add(0.5);
});
```

TypeGPU:
```ts twoslash
import * as std from 'typegpu/std';
// ---cut---
const oscSine = (t: number) => {
'use gpu';
return std.sin((t + 0.75) * Math.PI * 2) * 0.5 + 0.5;
};
```

## If statements

TSL:
```ts
If(instanceIndex.greaterThanEqual(uint(vertexCount)), () => {
Return();
});
```

TypeGPU:
```ts twoslash
import * as t3 from '@typegpu/three';
declare const vertexCount: number;
const some = () => {
// ---cut-before---
if (t3.instanceIndex.$ >= vertexCount) {
return;
}
// ---cut-after---
};
```

## For loops

TSL:
```ts
Loop({ start: ptrStart, end: ptrEnd, type: 'uint', condition: '<' }, ({ i }) => {
const springId = springListBuffer.element( i ).toVar( 'springId' );
const springForce = springForceBuffer.element( springId );
const springVertexIds = springVertexIdBuffer.element( springId );
const factor = select( springVertexIds.x.equal( instanceIndex ), 1.0, - 1.0 );
force.addAssign( springForce.mul( factor ) );
});
```

TypeGPU:
```ts
for (let i = ptrStart; i < ptrEnd; i++) {
const springId = springListBuffer.$[i];
const springForce = springForceBuffer.$[springId];
const springVertexIds = springVertexIdBuffer.$[springId];
const factor = std.select(-1, 1, springVertexIds.x === idx);
force = force.add(springForce.mul(d.f32(factor)));
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<canvas data-fit-to-container></canvas>
Loading