Drawing each object separately spends CPU time on JavaScript calls, especially on phones. Store a transform and material per object in a set of instances. The set is a table whose are meshes from a mesh pool. Its lights and draws the live rows with one draw per mesh. Adding instances increases data without increasing draws.
Boxes and spheres in two draws, whatever the count
Try Change the count to add boxes and spheres without increasing the two draws. Positions update every frame, while live lists update only after the count changes.
Creates lighting with a sun, sky and fog. It can also read point lights from a table or a
function and cast shadows. Pipe its injection into each pipeline that uses it. Throws if
points names no source or more than one, a light function has neither count nor
candidates, a table comes with count, or candidates.ranges is anything other than a
positive integer.
@injects ― hook the shading hooks its options name: reflect, ambient, fog, sunShadow and
attenuation
@injects ― definition the sun, sky and fog, the shadows and the point lights, which shading
reads
@binds ― 1 uniform: shading.shade, the sun, sky and fog
@binds ― 2 storage, 1 uniform: shading.shade with a table of point lights
@binds ― 3 storage, 1 uniform: shading.shade with a table of lights whose positions are on the
device, the table's two parts
@binds ― 1 uniform: shading.shade with points.light or points.spot, plus what the function
binds
@binds ― 0 storage: shading.shade with points.candidates, plus what their functions bind, 2
storage for a neighbour grid's range and slot
@binds ― 1 uniform: shading.shade with a shadow, the sun's light space and cascades, beside the
depth array and its comparison sampler
@binds ― 1 uniform: shading.shade with pointShadow, each shadow's light, layers and views,
beside their depth array and the comparison sampler
@owns ― 1 to 3 buffers, a sampler, targets, a cameras.layered, passes: the sun, sky and fog; with a
shadow, its light space, the views of its cascades, a comparison sampler, the depth array and
the passes that draw it; with pointShadow, the same for the lights' faces
@records ― shadow.record and pointShadow.record with what was added to them, before the passes
that shade
@param ― options.shadow the sun's shadow, with a depth pass per cascade
@param ― options.pointShadow shadows from pointShadow.define that cast gives to lights of
points.table, with a depth pass per face
@param ― options.points point lights from a table or a 'use gpu' function. Every lit point visits
each slot up to the table's highest live one, or count with a function, unless candidates
names the slots that may reach it
@returns ― lighting you destroy
create(
constroot:TgpuRoot
root,{
settings:{
readonly sunDirection:[0.4,1,0.3];
}&(Partial<d.InferInput<d.WgslStruct<{
sunDirection:d.Vec3f;
sunIntensity:d.F32;
sunColor:d.Vec3f;
skyIntensity:d.F32;
skyTop:d.Vec3f;
fogDensity:d.F32;
skyBottom:d.Vec3f;
fogFalloff:d.F32;
fogColor:d.Vec3f;
skyReflection:d.F32;
fogStart:d.F32;
}>>>|undefined)
Sets initial sun, sky and fog values over defaults. Default defaults, which has no fog.
Describes the targets and outputs for scene passes. With a surface such as the canvas, writes
only each renderer's colour. With a target set, writes colour into the target marked color,
depth into the target marked depth, and other outputs into their named targets. Multisampled
targets resolve according to resolve. Targets with layers draw one pass per layer, and every
target the description draws into needs the same layers. add builds a renderer's drawing.
begin starts a pass. pipe supplies fills such as a camera.
@param ― screen the surface, or the targets, which give the formats; each one the description
names is drawn into
@param ― writes what fills each target, by its key in screen
@returns ― a description you destroy, which holds the pipelines it builds
create(
constroot:TgpuRoot
root,
constscreen:targets.Targets<Specs<{
readonly hdr:{
readonly format:"rgba16float";
};
readonly depth:{
readonly format:"depth24plus";
};
}>>
screen,{
hdr:typeofpasses.color
hdr:
import passes
passes.
constcolor:typeofpasses.color
Marks the target that receives each renderer's colour.
Adds fill after existing fills and returns a description of the same passes. Piped fills
take precedence over a drawing's own. For example, passes.create(…).pipe(view.inject()) uses
the camera from view.
pipe(
constview:cameras.OrbitCamera
view.
CameraBase.inject(): Inject
Fills cameras.current for the pipelines created from the configuration it is piped into.
Adds fill after the fills given to earlier beneath calls and returns a description of the
same passes. A drawing's own fills take precedence over these, and piped fills over both, so
beneath supplies defaults such as a lighting. A compound drawing that passes its own from
to pipeline gets them by starting from with inject().
beneath(
constlight:lighting.Lighting
light.
Lighting.inject(): Inject
Fills the shading hooks and resources for pipelines created from the configuration you pipe
it into.
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
create(
constroot:TgpuRoot
root,
constpool:meshPool.MeshPool<{}>
pool,{
Options<K extends AnyKind = Plain>.capacity: number
Limits the number of rows. A mesh instance uses one row; a model instance uses one row per
mesh.
Builds a pipeline for drawing that writes every described output and returns its draw
methods. If the drawing cannot supply the fields an output reads, type checking fails with
that target's name and those fields. Use without to leave it out or instead to replace
it.
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
Adds an instance of a mesh, model or group of meshes from the pool. Each mesh uses a row,
and all rows move and change together under one id. values may be a function of each mesh,
to give a model's meshes values of their own. Throws if a mesh belongs to another pool, the
group is empty, a posed kind receives a mesh without joints or the set is full. When values
or a write throws, it adds no row and rethrows.
Adds an instance of a mesh, model or group of meshes from the pool. Each mesh uses a row,
and all rows move and change together under one id. values may be a function of each mesh,
to give a model's meshes values of their own. Throws if a mesh belongs to another pool, the
group is empty, a posed kind receives a mesh without joints or the set is full. When values
or a write throws, it adds no row and rethrows.
add(
constball:meshPool.Mesh
ball,{
scale?: number |d.InferInput<d.Vec3f>| ArrayLike<number>|undefined
Sets one scale factor for all axes or a separate factor per axis.
scale:0.5,...
import materials
materials.
constglow:(color:d.v3f,strength:number)=>{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
Creates an emissive material that gives off strength times color and reflects almost
nothing.
glow(
import d
d.
constvec3f:d.Vec3f
(x:number,y:number,z:number)=>d.v3f(+5 overloads)
vec3f(1,0.85,0.6),2)});
const
constorbit:HostField<d.Vec3f,Plain>
orbit=
constthings:instances.Instances<Plain>
things.
Instances<Plain>.fields: instances.Fields<Plain>
Provides one handle per field, which writes without allocating. Keep a handle outside a loop
instead of reading fields.x inside it.
Uploads changed rows. When instances are added or removed, it also uploads live rows per
mesh and updates draw counts. Call this once per frame before drawing. HistoryInstances
take the frame or its encoder and throw without one.
Begins a pass, draws drawn or each drawing in a list in order, then ends the pass. Reuse the
list to avoid allocating each frame. Call begin yourself when you need to choose drawings
per frame. Records nothing while enabled is false.
Runs the loop on each scheduled frame. Time advances by at most maxDt per frame, never steps
back, and stops while the surface is paused. Destroying the animation keeps the loop alive.
Another animation on the same loop continues from its recorded time. A frame error, or a run
that returns false because the loop was destroyed, stops the animation.
@param ― loop the loop to run on each unpaused frame. Continues from its seconds if it ran before
@returns ― an animation you destroy to stop the frames
animate(
constloop:frames.Frames
loop);
things.renderer() returns a drawing, lit by the lighting its gives through beneath. things.renderer().pipe(other.inject()) lights one renderer with another lighting. scene.add builds pipelines for its pass description and returns the draw commands. Each mesh uses a direct draw. Meshes with matching side, mask and texture settings share a pipeline. Direct draws need no optional device feature. A finished look for model scenes draws one set of glTF models with shadows, ambient occlusion, TAA and bloom.
Adds an instance of a mesh, model or group of meshes from the pool. Each mesh uses a row,
and all rows move and change together under one id. values may be a function of each mesh,
to give a model's meshes values of their own. Throws if a mesh belongs to another pool, the
group is empty, a posed kind receives a mesh without joints or the set is full. When values
or a write throws, it adds no row and rethrows.
A row starts with its mesh’s material. Shapes default to white chalk. Models use the file’s factors, multiplied by textures. Supplied values and the set’s defaults replace factors. To tint relative to the file, start with mesh.material.
Spread a materials preset into the values, for example { position, ...materials.glossy(color, 0.3), opacity: 0.2 }.
write changes only supplied fields. undefined leaves a field unchanged. write and remove take effect at the next flush. Removal invalidates the id, and has(id) checks whether it is live.
In shaders, instances.rotate(q, v) rotates v by a unit quaternion. instances.toward(direction) turns +z toward direction with +y up. toward also runs on the CPU.
The set is a table of its kind, and everything a offers works on it. Field handles write without allocating, live() spreads into a picker, neighbour grid or live lists, and idAt names the instance at a the GPU found:
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
create(
constroot:TgpuRoot
root,
constpool:meshPool.MeshPool<{}>
pool,{
Options<K extends AnyKind = Plain>.capacity: number
Limits the number of rows. A mesh instance uses one row; a model instance uses one row per
mesh.
capacity:1024,
Options<Plain>.defaults?:{
readonly position?: FieldInput<Vec3f>;
readonly rotation?: FieldInput<Vec4f>;
readonly scale?: number | FieldInput<Vec3f>;
readonly color?: FieldInput<Vec3f>;
readonly roughness?: number;
readonly metallic?: number;
readonly emission?: FieldInput<Vec3f>;
readonly opacity?: number;
}|undefined
Sets values for fields that add omits. They replace the mesh's material factors. Default
none: the identity transform, the mesh's material and zero for custom fields.
Adds an instance of a mesh, model or group of meshes from the pool. Each mesh uses a row,
and all rows move and change together under one id. values may be a function of each mesh,
to give a model's meshes values of their own. Throws if a mesh belongs to another pool, the
group is empty, a posed kind receives a mesh without joints or the set is full. When values
or a write throws, it adds no row and rethrows.
add(
constbox:meshPool.Mesh
box);
const
constspin:HostField<Vec4f,Plain>
spin=
constcrates:instances.Instances<Plain>
crates.
Instances<Plain>.fields: instances.Fields<Plain>
Provides one handle per field, which writes without allocating. Keep a handle outside a loop
instead of reading fields.x inside it.
Finds a candidate under a screen point on the GPU. Projects every candidate with the camera and
keeps the one within reach with the best rank. Throws unless capacity is an integer from 1 to
2^24 whose threads, 64 to a workgroup, fit the device's maxComputeWorkgroupsPerDimension.
@injects ― member found and ray, for shaders that act on the pick in the same frame; ray
also reads cameras.current
@binds ― 1 storage: found, the pick's key
@binds ― 1 uniform: ray, the pick's point
@owns ― 3 buffers, a pipeline, a readback: the pick's key, the pointer and the settings; the
readback brings the key to the CPU
@records ― pick once in a frame that picks, in a compute pass after whatever moves the
candidates; result.capture(frame) after that pass, which copies what a pick found.
@param ― camera the camera the candidates are drawn with
@param ― options.position where each candidate is; it, radius, alive and rank carry the fills
of what they read, such as Star.position.pipe(stars.inject())
@returns ― a picker you destroy
create(
constroot:TgpuRoot
root,
constview:cameras.OrbitCamera
view,{
...
constcrates:instances.Instances<Plain>
crates.
functionlive():Live
Returns the capacity and live test for live lists, a grid, a picker or state machines. Use
liveLists.create(root, { ...coins.live(), draws }).
live(),// the capacity and the live test
Options.size: SizeSource
Supplies the view size at each pick, such as the canvas surface. pixelRatio scales reach from
screen points to pixels. Without it, one point equals one pixel.
size,
Options.position: (i:number)=> v3f
Returns the candidate center in world space.
@gpu
position:
constcrates:instances.Instances<Plain>
crates.
gpu: GpuMembers<Plain>
Provides the definition's shader members bound to this table, such as reds.gpu.position(i)
and reds.gpu.device.$[i]. A shader reads several tables of one definition through their
gpu members, with nothing piped.
gpu.
position: Getter<Vec3f>
Holds the position in world space.
position,
});
// Once a pick is read back
const
constslot:number|null|undefined
slot=
consthits:picker.Picker
hits.
Picker.result: Readback<number |null>
Reads the picked candidate index to the CPU, or null if nothing was found. Capture after the
picker pass, then call take() or await next(). Without hz, each pick requests a copy for the
next capture.
result.
Readback<number |null>.take(): number |null|undefined
Returns latest once per completed copy, then undefined until the next copy completes. Each
value goes to one caller. Callers sharing a readback split the values between them.
No kind A set without a kind stores instances.Instance rows, whose getters its shaders read.
Table membersbuffers, slotOf(id) and clear() also work as on a table. count counts instances, while capacity and span count rows.
Modelsthings.add(model) adds one row per mesh under one id. write, field handles and remove act on every row of the model. idAt gives the model’s id for any of its slots, and count counts it once. A field handle’s get reads the model’s first mesh.
Groups Use things.add({ meshes }) to group any pool meshes, including a character and held items.
Per-mesh values Pass a function of each mesh to give a model’s meshes values of their own, such as a coat colour per part: things.add(horse, (mesh, i) => ({ color: coats[i] })). If it throws, add adds no row.
Defaultsdefaults sets values for fields add omits, including a kind’s own fields.
Flush Call things.flush() to upload changed rows. When instances are added or removed, it also uploads per-mesh . A set with history is typed HistoryInstances, whose flush takes the .
Cull Call renderer.cull(pass) in a compute pass for a culling renderer.
Shadow For a shadow, call light.shadow.record(frame, [cast]). Create cast = light.shadow.add(renderer) while loading.
Draw Call drawn.draw(pass) in the scene pass or use scene.record(frame, drawn). Direct rendering uses one drawIndexed per mesh with instances. Culling uses one drawIndexedIndirect per mesh the set has used. Meshes sharing a pipeline and textures draw consecutively with the pipeline and groups set once.
Compile renderer pipelines while loading with pipelines.compile([scene, light]). List the description and the lighting, whose initAsync compiles its shadows. Otherwise each pipeline compiles on its first draw. The GPU debug panel names pipelines by kind, with qualifiers such as cast, cover for a prepass, two-sided or masked.
Some , such as the motion that antialiasing over time reads, run the renderer’s vertex code a second time with last frame’s rows. Create the set with history: true to keep them, as a table does. Each instance then moves in the motion output, whether write or a kernel moved it:
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
Selects a kind from instances.define. Default a plain kind with a transform and material.
kind:
constFish:instances.Kind<"Fish",{},{
velocity:d.Vec3f;
},"device">
Fish,
Options<K extends AnyKind = Plain>.capacity: number
Limits the number of rows. A mesh instance uses one row; a model instance uses one row per
mesh.
capacity:1024,
history:true
Keeps last frame's rows, as a table's history does, so motion follows every instance that
moves, whether the CPU or a kernel moves it. create then returns HistoryInstances, whose
flush takes the frame. Default false.
Uploads changed rows, as Instances.flush does, and records into target, a frame or an
encoder, the copies that keep last frame's rows. Call this once per frame before drawing.
flush(
frame:frames.Frame
frame);// keeps last frame's rows, then uploads
// ... kernels that move the school, then the passes
});
Without history, the motion output sees only the camera move.
things.renderer(options) draws the set. Add it to multiple pass descriptions to build pipelines for each. Multiple renderers can draw the same set. drawn.destroy() removes from its description and frees its resources.
Option
Default
blend
'opaque'
'translucent' covers what is drawn by each instance’s opacity and writes no depth; 'clear' is glass
transmit
none
Under 'clear', the share of each colour behind that shows through: a tint
textured
true
false ignores mesh textures and masks, drawing textured meshes with their factors alone
specularAntialiasing
true
false keeps sharp highlights on flat-shaded faces
cull
false
true draws into each description only what its camera may see
from
0
Draws only the instances at least this far from eye; a number or a 'use gpu' function of the row’s slot
to
every distance
Draws only the instances nearer than this to eye, as from
fade
0
Metres around from and to across which it hands its samples over
eye
none
The camera from and to measure from; a renderer with either needs it
shade
shading.shade
Computes outgoing light from the material. Supply unlit, toon or debug shading. A blend: 'clear' renderer always uses shadeClear
prepass
false
true draws an opaque renderer’s depth first, with coverage and masks alone, then shades where the depth is equal
With cull: true, each pass draws only instances its camera may see. The scene uses view, and the shadow uses the sun. Record renderer.cull(pass) after things.flush() and movement kernels, before shadow and scene passes:
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
renderer({
RendererOptions.cull?: boolean |undefined
Enables GPU culling against each pass camera using spheres around mesh boxes. Call cull
each frame to list visible instances in set order. Throws if the kind has deform without
bounds. Default false.
Builds a pipeline for drawing that writes every described output and returns its draw
methods. If the drawing cannot supply the fields an output reads, type checking fails with
that target's name and those fields. Use without to leave it out or instead to replace
it.
Provides the sun shadow when enabled in the options.
shadow.
ShadowPasses.add<{
color:v4f;
},{
position:v4f;
world:v3f;
normal:v3f;
uv:v2f;
uv1:v2f;
row:number;
}>(drawing:passes.Compound<{
color:v4f;
},{
position:v4f;
world:v3f;
normal:v3f;
uv:v2f;
uv1:v2f;
row:number;
}>):passes.Drawn(+1overload)
Builds a caster's depth pipeline with the shadow's bias and returns its draw methods.
add(
constrenderer:instances.Renderer
renderer);// each keeps a list of its own
// After things.flush() each frame
const
constculling:TgpuComputePass
culling=
constframe:Frame
frame.
Frame.encoder: TgpuCommandEncoder
Records commands for submission after the recorder returns. submit() replaces this encoder.
Read it at each call instead of keeping it, and let the frame submit it.
Records visible-instance lists for each enabled description that contains this renderer, for
the layers it reports active, such as those a shadow's prepare picked. Call this after
flush() and any kernels that move instances, before drawing. Throws unless the renderer has
cull: true.
Clears the map in a depth pass per cascade that redraw picks and draws the casters built by
add. Call this while recording each frame, before drawing shaded surfaces. When disabled, it
draws nothing and makes every point sunlit. A frame that draws no cascade writes a timer's
timestamps from an empty compute pass.
Begins a pass, draws drawn or each drawing in a list in order, then ends the pass. Reuse the
list to avoid allocating each frame. Call begin yourself when you need to choose drawings
per frame. Records nothing while enabled is false.
record(
constframe:Frame
frame,
constdrawn:passes.Drawn
drawn);
Culling reads draw counts written by GPU kernels and uses . Request indirect-first-instance with tgpu.init({ device: { optionalFeatures: ['indirect-first-instance'] } }) to share pipelines across meshes without a group per mesh. Without the feature, each indirect draw binds a group that holds its mesh, and its pipeline reads the mesh from there. Where a pipeline has no to spare, each mesh gets a pipeline with its mesh compiled in.
The test Test each row with the sphere around its mesh box, scaled and transformed by the row. Model meshes and held items each use their own boxes.
Order Visible rows retain set order across frames so blended objects do not flicker.
Kernelscull two kernels over live rows per active pass description. It skips shadow work while shadows are off. Multiple renderers can share a compute pass.
Layers In a description with layers, each layer keeps a list of its own, seen through its view. Each of the two kernels dispatches once for all active layers. The work grows with rows times layers, and the dispatch count stays the same. Each layer’s pass draws its own list. A shadow’s prepare leaves out the layers it won’t draw.
Deformed meshes If deform moves vertices beyond the mesh box, supply a bounds sphere.
In your shaders Use cameras.sees(cameras.current.$, center, radius) for the same visibility test in your shaders, such as a live listsalive callback.
Nearby trees draw as spheres, distant ones as boxes
fade
Try Change the fade around 7 m from the bright eye marker. One renderer draws nearby spheres and another draws distant boxes, splitting pixels across the fade and culling from the view above.
Use less detail for distant objects. A culling renderer with from and to draws instances at least from and less than to metres from eye. Split a set between renderers, or use separate sets for near meshes and distant impostors:
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
renderer({
RendererOptions.cull?: boolean |undefined
Enables GPU culling against each pass camera using spheres around mesh boxes. Call cull
each frame to list visible instances in set order. Throws if the kind has deform without
bounds. Default false.
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
renderer({
RendererOptions.cull?: boolean |undefined
Enables GPU culling against each pass camera using spheres around mesh boxes. Call cull
each frame to list visible instances in set order. Throws if the kind has deform without
bounds. Default false.
cull:true,...
constfar:{
from:number;
fade:number;
eye:cameras.OrbitCamera;
}
far}).
Renderer.pipe(fill: Inject): instances.Renderer
Returns this renderer with fill applied to every pipeline and kernel it builds. The fill
runs after lighting and before the pass camera. Use it for resources read by kind callbacks,
as in school.renderer().pipe(water.inject()).
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Builds a pipeline for drawing that writes every described output and returns its draw
methods. If the drawing cannot supply the fields an output reads, type checking fails with
that target's name and those fields. Use without to leave it out or instead to replace
it.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Provides the sun shadow when enabled in the options.
shadow.
ShadowPasses.add<{
color:v4f;
},{
position:v4f;
world:v3f;
normal:v3f;
uv:v2f;
uv1:v2f;
row:number;
}>(drawing:passes.Compound<{
color:v4f;
},{
position:v4f;
world:v3f;
normal:v3f;
uv:v2f;
uv1:v2f;
row:number;
}>):passes.Drawn(+1overload)
Builds a caster's depth pipeline with the shadow's bias and returns its draw methods.
add(
renderer:instances.Renderer
renderer));
Distance Measure distance from eye to each row’s position. The same distance applies in every pass description, including shadows.
Thresholdsfrom and to can be shader callbacks taking the row slot, with their dependencies filled. Read uniforms to change thresholds without recompiling. Keep from below to for every row.
Fading Across fade metres around a threshold, the renderer draws a share of each instance that falls with its distance. Give the adjoining renderer the same fade to draw the rest. With multisampling, an instance keeps whole samples, the same ones in every pixel. The two renderers then blend evenly across it in steps of one sample. Without multisampling, they split pixels in a 4 × 4 pattern, which shows as a screen door where the two look different. Shadows switch without fading.
Cost Fading discards pixels or masks samples in the shader. That can make early depth rejection less effective and increase shading work.
With blend: 'translucent', instances draw translucent from premultiplied colour and their opacity. In a description with translucency they need no order; elsewhere they blend over in draw order. They write no depth and cast no shadows. The renderer accepts only pass descriptions with colour. Put blended objects in a separate set and draw them after opaque objects:
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
create(
constroot:TgpuRoot
root,
constpool:meshPool.MeshPool<{}>
pool,{
Options<K extends AnyKind = Plain>.capacity: number
Limits the number of rows. A mesh instance uses one row; a model instance uses one row per
mesh.
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
create(
constroot:TgpuRoot
root,
constpool:meshPool.MeshPool<{}>
pool,{
Options<K extends AnyKind = Plain>.capacity: number
Limits the number of rows. A mesh instance uses one row; a model instance uses one row per
mesh.
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
renderer();
// Drawn in this order, the ghosts over the blocks
Builds a pipeline for drawing that writes every described output and returns its draw
methods. If the drawing cannot supply the fields an output reads, type checking fails with
that target's name and those fields. Use without to leave it out or instead to replace
it.
Builds a pipeline for drawing that writes every described output and returns its draw
methods. If the drawing cannot supply the fields an output reads, type checking fails with
that target's name and those fields. Use without to leave it out or instead to replace
it.
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
Selects how instances write colour and depth. 'opaque' writes depth. 'translucent' draws
from premultiplied opacity, as a drawing with translucent: true does: in any order into a
description with translucency targets, over in draw order elsewhere. It leaves depth unchanged
and draws only in colour passes, after the opaque renderers. 'clear' draws in the same way
but adds reflections at full strength through shading.shadeClear, so glass and clear
plastic retain highlights at any opacity. With transmit, it blends over in draw order.
Default 'opaque'.
blend: 'clear' draws as 'translucent' does, with shading.shadeClear. Highlights and sky reflections stay bright at any opacity. Opacity scales diffuse light and emission. On metals, it fades only fog.
Use transmit to tint the background through glass. { blend: 'clear', transmit: [0.88, 0.92, 0.94] } transmits those fractions of each channel at any opacity. Opacity controls the milky appearance. The tint belongs to the renderer, which sets it as the pass’s blend constant at each draw. A transmit renderer therefore blends over in draw order.
The renderer supplies an instances.Corner at each vertex and an instances.Lit at each pixel. Outputs use these values, including motion for antialiasing over time. See Passes for target outputs.
A kind adds row fields and replaces shader functions with your own 'use gpu' functions. The fish tank’s fish keep velocity, beat their tails and have pale bellies:
Defines an instance kind with custom fields, transform ownership and callbacks for vertex
motion or materials. Each kind uses colour and shadow pipelines per renderer. name brands
set ids, as in Id<typeof Fish>, and labels the table and WGSL. Throws if both material and
surface are supplied, or a custom field duplicates a built-in or reserved name.
@param ― name a label for ids and WGSL
@returns ― a kind to give instances.create as kind
readonly rotation?:"is a field of every instance"|undefined;
readonly position?:"is a field of every instance"|undefined;
readonly scale?:"is a field of every instance"|undefined;
readonly color?:"is a field of every instance"|undefined;
readonly roughness?:"is a field of every instance"|undefined;
readonly emission?:"is a field of every instance"|undefined;
readonly metallic?:"is a field of every instance"|undefined;
readonly mesh?:"is a field of every instance"|undefined;
readonly opacity?:"is a field of every instance"|undefined;
}&{
...;
})|undefined
Adds fields written by GPU kernels. Default none.
device:{
velocity:d.Vec3f
velocity:
import d
d.
constvec3f:d.Vec3f
vec3f},
transform:"device"
Stores position, rotation and scale in device fields when set to 'device', so kernels can
write them. A kind typed as moved on the device requires it. Default 'host'.
Moves a vertex in object space before the instance transform. Colour and shadow passes both
apply this function. The shadow pass must then read the whole vertex instead of its position
alone. Normals remain as the mesh or pose supplies them. Default none, which uses the mesh
or posed position.
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
Adds an instance of a mesh, model or group of meshes from the pool. Each mesh uses a row,
and all rows move and change together under one id. values may be a function of each mesh,
to give a model's meshes values of their own. Throws if a mesh belongs to another pool, the
group is empty, a posed kind receives a mesh without joints or the set is full. When values
or a write throws, it adds no row and rethrows.
Call instances.define without a root. Pass the result to create as kind.
The kind brands set ids, such as instances.Id<typeof Fish>, and the name labels the WGSL.
Supply custom fields alongside built-in fields in add and write. Reusing a built-in name such as color or a reserved table name such as host, device, row, alive, span or slotOf is a type error. define also throws.
All functions are optional. The instance parameter is the whole row. material, surface and coverage take a pixel instead, which holds pixel.point on the mesh, pixel.instance and pixel.carried. Functions can read uniforms and buffers, such as time.$ above:
Function
Takes and returns
What it replaces
place
(instance) => instances.Placement
Where the instance is, from data of your own, in every pass, in culling and for from and to. The row’s own transform goes unread.
visible
(instance) => bool
Whether it draws, in every renderer and pass. A culling renderer leaves it out of its lists; one that doesn’t cull collapses its triangles.
pose
(instance) => u32, a pose’s id
The mesh’s bind pose. Vertex positions follow the pose’s joints in every pass. Full-vertex draws skin normals too. Skinning runs before deform. Poses come from the poses piped into the renderer.
deform
(vertex: instances.Vertex, instance) => vec3f
Where the vertex is, in object space, in every pass. The normal stays the mesh’s, or the pose’s.
Replaces the mesh surface with a shading point and material, as impostors do.
coverage
(pixel: instances.Pixel) => f32
How much of the pixel the instance covers, from 0 to 1, in every pass, shadows included: holes such as lace, or the leaves on a card.
Shadow vertices With deform, the shadow pass reads 20 bytes per vertex rather than 12, or 28 rather than 20 with a pose. Set deformShadow: false for deformations too small to see in shadows, such as tail motion.
Culling A culling renderer of a kind with a deform needs bounds.
Material or surface Supply either material or surface. A custom surface shades at mesh depth and writes its supplied point depth to shadows.
Coveragecoverage runs before material or surface and reads no material, so it samples only what it reads itself. With multisampling, it selects the share of samples covered. Without multisampling, pixels below half coverage are left out. Blended renderers scale opacity by it. A kind without coverage keeps early depth testing, so each mesh draws once and hidden pixels go unshaded.
Prepass Give prepass: true to an opaque renderer whose meshes overlap and run a heavy material or surface, such as a forest of cards. The renderer first draws depth using coverage, any mesh masks and any fade. The colour draw then shades where depth matches. It costs a second pass over the vertices and needs a description with depth.
Pipelines Each kind compiles a colour pipeline per pass description and a depth pipeline for shadows. Put per-instance differences in row fields to avoid extra pipelines.
Parameter types A parameter typed Instances takes a set of any kind. Instances<typeof Fish> takes a set of that kind, with its fields. Only create given kind: Fish returns one. Only define given transform: 'device' returns a kind whose transform kernels write, even with explicit type arguments.
With transform: 'device', the transform joins the kind’s device fields. A kernel reads through the set’s gpu getters and writes school.gpu.device.$[i]. Dispatch it over school.span after school.flush(), skipping free slots:
Provides the definition's shader members bound to this table, such as reds.gpu.position(i)
and reds.gpu.device.$[i]. A shader reads several tables of one definition through their
gpu members, with nothing piped.
If a simulation has its own position buffer, read it in place instead of copying positions to rows every frame. Fill the dependency through the renderer’s pipe:
Defines an instance kind with custom fields, transform ownership and callbacks for vertex
motion or materials. Each kind uses colour and shadow pipelines per renderer. name brands
set ids, as in Id<typeof Fish>, and labels the table and WGSL. Throws if both material and
surface are supplied, or a custom field duplicates a built-in or reserved name.
@param ― name a label for ids and WGSL
@returns ― a kind to give instances.create as kind
Returns the instance transform from custom data, such as a simulation buffer. All passes use
it, including culling and distance limits from from and to. It runs for each vertex in
every pass; when it does heavy work, a kernel that writes device rows once a frame costs less.
Attach its fills with pipe or the renderer pipe method. Default the instance position,
rotation and scale.
@gpu
place:(
horse:{
rotation:d.v4f;
position:d.v3f;
scale:d.v3f;
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
mesh: number;
opacity: number;
body: number;
fallen: number;
}
horse)=>{
'use gpu';
const
constbody:d.v4f
body=
constbodies:TgpuAccessor<d.WgslArray<d.Vec4f>>
bodies.
TgpuAccessor<WgslArray<Vec4f>>.$: d.v4f[]
$[
horse:{
rotation:d.v4f;
position:d.v3f;
scale:d.v3f;
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
mesh: number;
opacity: number;
body: number;
fallen: number;
}
horse.
body: number
body];
return
import instances
instances.
functionPlacement(props?:{
rotation:d.v4f;
position:d.v3f;
scale:d.v3f;
}|undefined):{
rotation:d.v4f;
position:d.v3f;
scale:d.v3f;
}
export Placement
This schema holds a unit quaternion, position and scale per axis. Instance transforms use
world space; joint transforms use parent space.
Controls visibility in every renderer and pass, including shadows, without removing the
instance. Culling renderers omit hidden instances from their lists. Other renderers collapse
their triangles. Default always.
Creates a set of mesh instances with transforms, materials and optional custom fields. Each
instance uses a row, and renderers draw one list of live rows per mesh.
@param ― pool the mesh pool whose meshes it draws
@param ― options.kind a kind from instances.define
@returns ― a set of instances you flush every frame and destroy
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
renderer().
Renderer.pipe(fill: Inject): instances.Renderer
Returns this renderer with fill applied to every pipeline and kernel it builds. The fill
runs after lighting and before the pass camera. Use it for resources read by kind callbacks,
as in school.renderer().pipe(water.inject()).
add and write still accept row position, rotation and scale, but place ignores them. place runs for each vertex in every pass. When it does heavy work, a kernel that writes the rows once a frame costs less.
Fill dependencies read by kind functions through the renderer’s pipe. For example, the fish tank reads a noise cache. See shader dependencies:
const
constnoise:StaticPerlin3DCache
noise=
(alias)namespaceperlin3d
import perlin3d
perlin3d.
index.staticCache(options: {
root: TgpuRoot;
size: d.v3u;
}): StaticPerlin3DCache
exportindex.staticCache
A statically-sized cache for perlin noise generation, which reduces the amount of redundant calculations
if sampling is done more than once. If you'd like to change the size of the cache at runtime, see perlin3d.dynamicCacheConfig.
Creates a renderer for colour and shadow pass descriptions, lit by the lighting each
description gives through beneath. Use pipe to fill resources read by kind callbacks, or
another lighting.
renderer().
Renderer.pipe(fill: Inject): instances.Renderer
Returns this renderer with fill applied to every pipeline and kernel it builds. The fill
runs after lighting and before the pass camera. Use it for resources read by kind callbacks,
as in school.renderer().pipe(water.inject()).
Builds a pipeline for drawing that writes every described output and returns its draw
methods. If the drawing cannot supply the fields an output reads, type checking fails with
that target's name and those fields. Use without to leave it out or instead to replace
it.
add(
constrenderer:instances.Renderer
renderer);
A custom fill takes a configuration, for example .pipe((cfg) => cfg.with(clock, time)).
Defines an instance kind with custom fields, transform ownership and callbacks for vertex
motion or materials. Each kind uses colour and shadow pipelines per renderer. name brands
set ids, as in Id<typeof Fish>, and labels the table and WGSL. Throws if both material and
surface are supplied, or a custom field duplicates a built-in or reserved name.
@param ― name a label for ids and WGSL
@returns ― a kind to give instances.create as kind
define('House',{
KindOptions<{ glow:F32;},{},"host">.host?:({
glow:d.F32;
}&{
readonly rotation?:"is a field of every instance"|undefined;
readonly position?:"is a field of every instance"|undefined;
readonly scale?:"is a field of every instance"|undefined;
readonly color?:"is a field of every instance"|undefined;
readonly roughness?:"is a field of every instance"|undefined;
readonly emission?:"is a field of every instance"|undefined;
readonly metallic?:"is a field of every instance"|undefined;
readonly mesh?:"is a field of every instance"|undefined;
readonly opacity?:"is a field of every instance"|undefined;
}&{
...;
})|undefined
Adds fields written on the CPU, as in table.define. Default none.
host:{
glow:d.F32
glow:
import d
d.
constf32:d.F32
export f32
A schema that represents a 32-bit float value. (equivalent to f32 in WGSL)
Holds the transform, material and custom fields of the instance.
instance.
glow: number
glow*
constnight:TgpuAccessor<d.F32>
night.
TgpuAccessor<F32>.$: number
$,
constpane:boolean
pane);
const
constglowing:{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
glowing=
import shading
shading.
constMaterial:d.WgslStruct
(props?:{
color:d.v3f;
roughness: number;
emission: d.v3f;
metallic: number;
occlusion: number;
}|undefined)=>{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
This schema describes a surface with the glTF metallic-roughness model. New fields are only
appended, each off at zero. Make one with a materials preset or copy one with Material(m),
then assign the fields you set: a struct literal stops compiling when a field is added.
Material(
base:{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
base);
constglowing:{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
glowing.
emission:d.v3f
Sets the emitted light in linear colour space. Shading adds it after lighting.
emission=
base:{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
base.
emission:d.v3f
Sets the emitted light in linear colour space. Shading adds it after lighting.
emission+
constWARM:d.v3f
WARM*
constlit:number
lit;
return
constglowing:{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
glowing;
},
});
materials.textured(material, point) textures a material made another way, such as a preset, in a fragment shader.
Use carry to read per-vertex data, such as a mesh-pool extra attribute. material, surface and coverage read the interpolated value as pixel.carried. Here the kind reads vertex colours:
const
constpool:meshPool.MeshPool<{
color:d.Vec4f;
}>
pool=
import meshPool
meshPool.
functioncreate<{
color:d.Vec4f;
}>(root:TgpuRoot,options:meshPool.Options<{
color:d.Vec4f;
}>):meshPool.MeshPool<{
color:d.Vec4f;
}>
Creates shared vertex storage and an index buffer, with bounds and textures per mesh. One
pipeline can draw any mesh. Each vertex uses 12 bytes for position and 8 for normal and UV
coordinates, and 8 for a second uv set with uvs1. Skinned models add 8 bytes for joints and
weights. Extras add the size of their struct per vertex.
@unstable
@injects ― definition the vertices vertexAt, positionAt and uv1At read, the joints and
weights influencesAt reads, and the boxes boundsOf reads
@injects ― member the extras pool.extra reads
@binds ― 1 storage: positionAt, the positions
@binds ― 2 storage: vertexAt, the positions and the normals and uvs
@binds ― 1 storage: uv1At, the second uvs, in a pool made with uvs1
@binds ― 1 storage: influencesAt, the joints and weights
@binds ― 1 storage: boundsOf, every mesh's box
@binds ― 1 storage: pool.extra, every vertex's extras
@binds ― 1 uniform: pool.texturesOf(index) for materials, beside its textures and sampler, in
the fragment stage
@submits ― setup a shape added without an encoder bakes in a compute pass of its own, submitted at
once, and a model's images generate their mips as they decode
@owns ― 5 to 7 buffers, a uniform per way of reading textures, a uniform per shape added, a
pipeline per pair of shape functions, textures, samplers, bind groups, what images makes:
positions, normals and uvs, indices and boxes, second uvs with uvs1, joints and weights once a
skinned model comes, and the extras when extra names any; a bake per vertexAt and indexAt
it bakes, and per shape added the uniform of its ranges and their group; each image decoded once
per format it is read in, and a group per set of a mesh's textures
@returns ― a pool you add meshes and models to and destroy
create(
constroot:TgpuRoot
root,{
Options<E extends Extras ={}>.capacity: number
Limits the number of meshes to at most 256.
capacity:16,
Options<{ color: Vec4f;}>.extra?:{
color:d.Vec4f;
}|undefined
Declares custom vertex attributes, for example { tint: d.vec4f }. Model meshes supply
their data in extra; shaders read it through pool.extra.tint(i). These attributes use a
separate buffer with one struct per vertex. Shapes read as zero. Default none.
Defines an instance kind with custom fields, transform ownership and callbacks for vertex
motion or materials. Each kind uses colour and shadow pipelines per renderer. name brands
set ids, as in Id<typeof Fish>, and labels the table and WGSL. Throws if both material and
surface are supplied, or a custom field duplicates a built-in or reserved name.
@param ― name a label for ids and WGSL
@returns ― a kind to give instances.create as kind
Returns four values to interpolate between vertices and hand to the fragment hooks as
pixel.carried. For example, read an extra attribute with pool.extra.tint(vertexIndex).
vertexIndex indexes the pool, as in meshPool.vertexAt. Default none, which omits four
floats per vertex and sets carried to zero.
Returns the material at a pixel. base combines the instance material fields with the mesh
textures, as materials.textured does. Default base.
@gpu
material:(
pixel:instances.Pixel<{
rotation:d.v4f;
position:d.v3f;
scale:d.v3f;
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
mesh:number;
opacity:number;
}>
pixel,
base:{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
base)=>{
'use gpu';
const
constpainted:{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
painted=
import shading
shading.
constMaterial:d.WgslStruct
(props?:{
color:d.v3f;
roughness: number;
emission: d.v3f;
metallic: number;
occlusion: number;
}|undefined)=>{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
This schema describes a surface with the glTF metallic-roughness model. New fields are only
appended, each off at zero. Make one with a materials preset or copy one with Material(m),
then assign the fields you set: a struct literal stops compiling when a field is added.
Material(
base:{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
base);
constpainted:{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
painted.
color:d.v3f
Sets the diffuse colour of a dielectric or the reflection colour of a metal, in linear
colour space.
color=
base:{
color:d.v3f;
roughness: number;
emission:d.v3f;
metallic: number;
occlusion: number;
}
base.
color:d.v3f
Sets the diffuse colour of a dielectric or the reflection colour of a metal, in linear
colour space.
color*
pixel:instances.Pixel<{
rotation:d.v4f;
position:d.v3f;
scale:d.v3f;
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
mesh:number;
opacity:number;
}>
pixel.
Pixel<I>.carried: d.v4f
Holds the values interpolated from carry, or zero without it.
carried.
rgb:d.v3f
rgb;
return
constpainted:{
color:d.v3f;
roughness:number;
emission:d.v3f;
metallic:number;
occlusion:number;
}
painted;
},
});
vertexIndex uses pool indices, as meshPool.vertexAt does. Without carry, carried is zero and vertices pass four fewer floats.
pool.extra belongs to one pool. Define kinds that read it after creating that pool, and use them only with its meshes.
Pipelines per set Two sets of one kind with the same renderer options compile a pipeline pair each.
Mesh combinations Renderers compile a pipeline for each combination of doubleSided, masked and textured present in the pool, including unused meshes. initAsync compiles combinations present at that time. Adding a mesh with a new combination, such as an impostor card, compiles new pipelines on its first draw.
Blend materials A renderer draws an alpha: 'blend' material as opaque; blending is the renderer’s blend option.
Blend constant Render bundles cannot set a blend constant. For a transmit renderer in a bundle, set it on the enclosing pass with pass.setBlendConstant([...transmit, 1]).
Bundles A bundle draws the meshes that had instances when it was recorded. Record it again after a mesh without instances gains one, and once a model’s ready resolves.
Back faces Back-face lighting uses the interpolated normal relative to the eye. A front face can therefore receive back lighting near an edge where that normal turns away.
Masks A kind with a surface ignores the mesh masks, except in a depth prepass. Its surface decides what it covers.
Deformdeform can’t bend the normal or move the uv.
Facing Straight-up and straight-down directions leave the yaw of instances.toward dependent on the GPU’s atan2(0, 0) result. Rotate models that do not face +z when reading them with rotation.
rowA row is one object's values in a buffer, such as one enemy, one particle or one light.Objects are rows in buffers →
rendererA renderer draws one sort of thing, such as instances or particles, by handing a pass description a drawing.Every renderer is a drawing →
pass descriptionA pass description says once which textures a pass draws into and what each holds, and builds the pipeline for every drawing added to it.Scenes and passes →
tableA table is a buffer of rows with named fields, some written by the CPU and the others by kernels.Rows →
slotA slot is a row's place in its buffers, which a new row can take once the first is removed.Row ids →
live listA live list is a list of the live rows of one group, made on the GPU each frame so that a draw covers only them.Only what is alive →
frameA frame is one turn of the loop, and the object your function gets for it, which holds the encoder, the time and the time since the last frame.You own the frame →
kernelA kernel is a compute function that the GPU runs many times at once, each run on its own thread.A frame in plain TypeGPU →
outputAn output is a value every drawing writes at each pixel beside its colour, such as motion or an id.Outputs every drawing writes →
drawingA drawing is what a renderer hands to a pass description: what each vertex carries to its pixels, what a pixel looks like and the draw call.Every renderer is a drawing →
indirect drawAn indirect draw reads how much to draw from a buffer, so a kernel can decide the count and the CPU never reads it.Indirect draws →
bind groupA bind group is a set of buffers, textures and samplers that a pipeline reads, and a pipeline has room for four.Words →
dispatchA dispatch runs a kernel once over a number of threads, inside a compute pass.Words →
impostorAn impostor draws a distant model as one card that faces the camera, textured with pictures of the model taken in advance.Impostors →
atlasAn atlas is one texture that holds many small pictures side by side, such as every glyph of a font or every view of a model.Words →
memberA member is a function or accessor on what a factory returns that reads that instance's own resources, so a pipeline that uses it needs no fill.Members and placeholders →
placeholderA placeholder is an accessor with no resource of its own, which each pipeline fills through the inject() of the module it reads.Members and placeholders →
hookA hook is a placeholder that each pipeline fills with its own choice, such as the camera it draws through.Members and placeholders →
Set to false to ignore mesh textures: textured meshes then draw with their untextured factors and without alpha masks, and a custom material function receives those factors as base.Default true, which reads textures on meshes whose textured is set.
Provides the camera for measuring distance for from and to in every pass, including shadows.Default none, which throws if the renderer uses from or to.
Draws an opaque renderer twice: first its depth, running only coverage and the mesh masks, then its colour where the depth is equal, so each pixel shades once.Default false, which draws once.
Returns four values to interpolate between vertices and hand to the fragment hooks as pixel.carried.Default none, which omits four floats per vertex and sets carried to zero.
Returns how much of the pixel the instance covers, from 0 to 1, to cut holes in its shape, such as lace, or leaves on a card.Default none: the instance covers every pixel it rasterises, and opaque renderers keep early depth testing.
What each description built of a renderer, in its pass; flush() once a frame, before them, uploads what changed; a culling renderer's cull in a compute pass after the flush.
a table ·2 buffers ·culling buffers ·culling pipelines ·bind groups
The rows, the live ones per mesh and, once a render bundle draws them, their draws; with culling, a uniform of how many rows it lists from; without indirect-first-instance, a uniform and a bind group per mesh with instances; and a culling renderer's 3 buffers and 2 kernels for each description it is added to, which own its pipelines, colour, with a depth pipeline before it for a kind with a surface, or depth alone.
cull: true, and a render bundle, draw indirectly; without it, each indirect draw binds a group holding its mesh, or draws through a pipeline per mesh where the pipeline has no group left. A renderer drawn into a pass without cull draws directly and needs none.