Skip to content
Created by

TypeGPU Kit

Building blocks for TypeGPU.
Interchangeable by design. Use what you want and fill the gaps with your own code.

npm i @typegpu/kit

The kit draws the frame on the right. Scroll to see it built.

Take it apart

The stack is built again a module at a time, from the bottom up.

The stack is whole. Drag a number, or click a plate or a module's name to take it out.

Each code block adds a module to this flock. With WebGPU, the stack beside it shows each module's output.

1kit.tablethe birds, a row each
const birds = table.create(root, Bird, { capacity: CAPACITY });
const rows = Array.from({ length:  }, () => birds.add(bornAt()));
2who is near whom
const cells = grid.create(root, {
  ...birds.live(), low: LOW, size: AIR, sight: 1.4, item: Seen,
  position: Bird.position.pipe(birds.inject()),
  itemOf: seenOf.pipe(birds.inject()),
});
const steering = createSteering(root, birds, cells, {
  sight: , rules: { flock, orbit, huddle },
});
3the sun's shadow
const shadow = {
  size: 1024, extent: 20, filter: 4, enabled: () => has('shadow'),
} as const;
const sunDirection = degreesUp();
4a sun, and a lamp in one bird of eight
const lamps = createLamps(root, birds, {
  range: , intensity: ,
});
const light = lighting.create(root, {
  settings: { ...LIT, sunDirection },
  shadow,
  points: { light: lamps.light, candidates: cells.candidates() },
});
5kit.passeslit colour, normals and depth
const scene = passes
  .create(root, screen, { hdr: passes.color, normals, depth: passes.depth }, {
    clear: [0.01, 0.011, 0.013, 1], label: 'scene',
  })
  .pipe(view.inject())
  .pipe(light.inject());
const chevrons = birdsDrawing(root, birds, lamps, { length:  });
const shown = [scene.add(groundDrawing(30)), scene.add(chevrons)];
const cast = [light.shadow.add(chevrons)];
6the lamps' glow
const glow = bloom.create(root, {
  source: () => screen.textures.hdr, levels: 5, bright: lampGlow,
  settings: { threshold: , knee: 0.4 },
});
7kit.finishthe graded frame
const print = dither(root, { cell: , levels:  });
const final = finish.create(root, {
  format: 'rgba8unorm', source: () => screen.textures.hdr,
  glow,
  grade: print.grade,
  settings: { glowIntensity: , vignette: 0.25, dither: 0 },
});

TypeGPU Kit provides GPU modules in one package, @typegpu/kit. It uses TypeGPU in WebGPU browsers and React Native. Each module borrows your root and records into the passes you give it. You own the loop, frame and canvas. How the kit works sets it beside plain WebGPU and TypeGPU.

A rule of your own

The steering takes a 'use gpu' function that computes force from a bird and its neighbours. Pick a rule and drag its number.Pick one to read it.

// Separate from nearby birds, align and move towards the flock
const flock = (me: Seen, near: Near) => {
  'use gpu';
  const along = near.heading - me.velocity;
  const toward = near.centre * ;
  return near.away * 1.1 + along + toward + airAt(me) * 1.6;
};
const steering = createSteering(root, birds, cells, { rules: { flock } });

Point at a module to see the modules it takes and the modules that take it. A dotted line means the taken module also fills accessors in the taker's shaders.

  • ao takes cameras, which fills accessors in its shaders
  • dof takes cameras, which fills accessors in its shaders
  • environment takes passes, which fills accessors in its shaders
  • finish takes exposure, which fills accessors in its shaders
  • impostors takes meshPool, which fills accessors in its shaders
  • impostors takes poses, which fills accessors in its shaders
  • instances takes cameras, which fills accessors in its shaders
  • instances takes lighting, which fills accessors in its shaders
  • instances takes meshPool, which fills accessors in its shaders
  • particles takes cameras, which fills accessors in its shaders
  • passes takes bindings, which fills accessors in its shaders
  • picker takes cameras, which fills accessors in its shaders
  • taa takes cameras, which fills accessors in its shaders
  • text takes cameras, which fills accessors in its shaders
  • text takes font

Jelly world

A ray-marched jelly slider on a tray, until a critter pulls the lever and a candy world grows around it.

  • dynamicResolution
  • profiler
  • baker
  • font

Classroom

Blender's Classroom, its daylight and lamps baked on a second uv set, sunbeams through its dust.

  • history
  • images
  • taa
  • bindings

Falling sand

Sand, water and lava falling cell by cell through a cave lit by its own glow.

  • events
  • inject
  • particles
  • tone

Ocean

A near gale at dusk: FFT waves, foam on the crests and a low sun under the deck.

  • mipmaps
  • exposure
  • history
  • memo

Censer

Incense smoke curls from a swinging censer, simulated and lit on the GPU.

  • memo
  • materials
  • meshes
  • lighting

Every example opens full-screen and includes a GPU debug panel.

We are Software Mansion

A software company built around improving developer experience and bringing the innovative ideas of our clients to life. Do you have a software project we can help you with?

Hire us