With one sample per pixel, angled edges form steps, and thin lines shimmer as they move. MSAA takes multiple samples in each drawing pass, and FXAA smooths the finished picture. TAA distributes samples across . Each frame offsets the scene by a fraction of a pixel. The resolve blends it with the previous image using motion to find each surface’s previous position.
latticeThin beams and rising embers, smoothed over time with TAA.
Hold the pointer over distant beams and turn TAA off. The loupe shows thin beams stepping and shimmering as they turn. Lower the render scale, then turn upscaling off and on to compare the smaller picture stretched with TAA resolving it up.
One edge, sampled at a new spot in every pixel each frame and blended over the cycle
Try Move the edge, or drag it sideways. It writes no motion here, so the pixels in coral find old samples that no longer match their neighbours and throw them out. Draw at two thirds to see the resolve rebuild the same edge from fewer pixels.
Every scene pass must jitter, and that move must write motion. Use pass descriptions for those passes:
Creates render targets that follow a size. Replaces the whole set when the size changes. Put
targets needed only sometimes in their own set and create that set when needed. Throws for
transient targets with sampling, storage or mip levels, for multisampled targets with storage or
mip levels, and for layered targets that are multisampled, mipped or have more layers than the
device allows.
@param ― source the size it follows, such as a surface
@param ― specs a format and options per target, by name
@param ― options.resolution the fraction of each side drawn, which changes without allocating
@returns ― a set of targets you fit every frame and destroy
Creates temporal antialiasing from subpixel-jittered frames. The resolve blends each frame
with history sampled where motion, or depth and camera movement, place the preceding pixel.
Without either, it samples history at the same pixel. It clamps history colour to
the local colour spread to reduce trails and weights by brightness to reduce bright-pixel
flicker. With size, it resolves a smaller source up to that size: each output pixel rebuilds
the current frame from the nine source pixels around it with Lanczos-2 weights placed by this
frame's jitter, and blends less of it where those weights add up to less. Record its single
pass after scene passes and before the final pass reads output.
@allocates ― on resize: targets for the new size and the bind groups of its passes; so does a new
source, motion, depth or reactive texture
@owns ― targets, 4 buffers, a sampler, a pipeline, 2 to 4 bind groups: two histories, each frame
written into one from the other, the settings, the region and whether to blend, the jitter and
its sequence, a group each for the frames that read either history with the source and
motion, one for depth and one for reactive
@binds ― 1 uniform: jitter, this frame's offset
@records ― record after the passes that draw the source and the motion, before what reads
output.
@param ― options.source this frame's picture, drawn through jitter, read at every record
@param ― options.motion how far each pixel's surface moved since last frame, read at every
record; without it, pixels move only with the camera
@param ― options.depth the scene's depth, for the motion of the nearest surface around each pixel
and for motion from the camera, or null
@returns ― a resolve you record every frame and destroy
create(
constroot:TgpuRoot
root,{
Options.source: Source
Provides the current linear-colour picture, drawn through jitter: a function returning a
texture, such as () => screen.textures.hdr, or a rendered picture. record reads it on
every call.
Returns the motion texture written by motion. Each vector is the preceding UV position
minus the current UV position. record reads it on every call. Default none, which moves
every pixel as camera moves depth, or keeps it in place without both.
Provides the current textures. A size change replaces them.
textures.
motion:targets.Target<{
readonly format:"rg16float";
readonly sampled:true;
}>
motion,
Options.depth: (()=>targets.Depth)|null
Returns sampled scene depth without stencil, or null for a picture drawn without depth.
Motion then follows the nearest surrounding surface to avoid smearing moving edges over the
background. record reads it on every call. Unused without motion or camera. With null,
motion is read at each pixel.
Provides the current textures. A size change replaces them.
textures.
depth:targets.Target<{
readonly format:"depth24plus";
readonly sampled:true;
}>
depth,
Options.camera?:cameras.CameraBase|undefined
Supplies the scene camera with its preceding view, such as cameras.orbit. With depth,
pixels without renderer-written motion reconstruct motion from depth and camera movement.
Without both, these pixels stay in place. Default none.
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 sampled:true;
};
readonly motion:{
readonly format:"rg16float";
readonly sampled:true;
};
readonly depth:{
readonly format:"depth24plus";
readonly sampled:true;
};
}>>
screen,
{
hdr:typeofpasses.color
hdr:
import passes
passes.
constcolor:typeofpasses.color
Marks the target that receives each renderer's colour.
color,
motion:passes.Output<unknown,{
position:d.v4f;
}>
motion:
import taa
taa.
constmotion:passes.Output<unknown,{
position:d.v4f;
}>
This output writes surface motion into an rg16float target. It stores preceding UV position
minus current UV position. It computes the preceding position by compiling renderer vertex
code with history.previously, which reads the preceding camera and values of other
temporal fills.
motion,
depth:typeofpasses.depth
depth:
import passes
passes.
constdepth:typeofpasses.depth
Marks the depth target.
depth},
{
Options.jitter?: Position |undefined
Moves clip positions for rasterisation. Outputs read the original vertex positions. Use for a
sub-pixel offset in temporal antialiasing. Default none.
@gpu
jitter:
constaa:taa.Taa
aa.
Taa.jitter: (position:d.v4f)=>d.v4f
Offsets vertices by a different fraction of a source pixel each frame so frames sample the
whole pixel together: 8 offsets in turn, or at size 8 for each output pixel a source pixel
covers, 18 at 1.5 times per side. Supply this as jitter in passes.create.
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.
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 the final pass of a frame. It reads the source, adds glow, tone maps, grades, applies
the vignette, encodes and dithers. It draws one triangle into the caller pass.
@allocates ― on resize: a bind group for a new source or glow
@owns ― 2 buffers, a sampler, a pipeline, 2 bind groups: the settings, the regions it reads, a
group for the glow and one for each texture the source returns
@records ― record into a pass of its own on the view you give, usually the canvas's, or draw
into the caller's pass, after the bloom's record.
@param ― options.source the picture, rendered or a texture, read at every draw
@param ― options.region the part of the source that holds the picture, read at every draw
@param ― options.glow a bloom, or a glow of your own, added before tone mapping
@param ― options.exposure an adapted exposure, read on the GPU
@returns ― a final pass you draw every frame
create(
constroot:TgpuRoot
root,{
Options.format: GPUTextureFormat
Sets the output format, such as the canvas format.
format:
constsurface:web.Surface
surface.
Surface.format: GPUTextureFormat
Reports the format of its textures, which pipelines that draw into it target.
format,
Options.source: Source
Provides the picture at any size: a rendered picture, such as aa or blur, or a function
returning a texture, such as () => screen.textures.hdr. draw reads it on every call, so
the texture can be rebuilt.
Rebuilds all textures if the source size changed, destroying the old textures first. Updates
regions for the current resolution. Returns true after a rebuild so callers can update bind
groups that hold old textures. Call before recording passes that use the targets. A rebuild
that throws destroys what it made and leaves the set unfitted, so the next call rebuilds it.
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.
Records the resolve after source and motion passes, then sets jitter for the next frame.
Records nothing while disabled. Optional timer writes measure the resolve. Given a frame, a
resolve that never submits leaves the history as it was.
Opens a pass on view, such as surface.view(frame), draws into it and ends it. A
viewport draws the picture into that rectangle and clears the rest, transparent with
alpha: 'premultiplied' and black otherwise. Optional timer writes measure the pass.
record(
constframe:Frame
frame,
constsurface:web.Surface
surface.
Surface.view(frame: Frame): GPUTextureView
Returns a view of the current canvas texture, created once per texture. Applies pending size
changes first, which a pass using context would skip.
view(
constframe:Frame
frame));
Motiontaa.motion writes each surface’s movement since the previous frame in UV coordinates. It reruns vertex code with history.previously to read the previous camera and other temporal fills.
Object motion All include camera motion. Object motion requires vertex code to read temporal state. Particles use velocity, and the lattice stores its turn in a history. Skinned poses keep last frame’s joints, so posed joints show their own motion.
Rows By default, , trails and text include only camera motion. A set of instances or a created with history: true gives each that moves its own motion, whether write or a moved it.
Still vertices Renderers with stationary vertices, such as a full-screen sky, use scene.without('motion'). See Passes for their .
Unwritten pixels Unwritten motion pixels retain the taa.motion clear value, and taa.written(motion) is false for them in a shader of yours. With camera and depth, the resolve reconstructs surface position from depth and applies camera motion. Otherwise those pixels stay fixed.
Depthdepth is required. Pass null for a picture drawn without depth, such as a 2D game: the resolve then reads motion at each pixel, and pixels without motion stay in place.
Without motion Omit motion when no drawing’s vertices move, as in the ray-marched jelly slider. The resolve then binds no motion texture, and the scene writes no motion target. With camera and depth, every pixel follows the camera. Without them, history stays at each pixel, which suits a still camera.
Jitter Jitter cycles through 8 subpixel offsets, or more at size. GPU copies advance it after each resolve without per-frame CPU writes. aa.offset holds the current clip-space offset for custom jitter shaders.
The resolve The resolve clamps previous colour within spread standard deviations of nearby current colours. It takes blend of the current frame and downweights bright values in both frames. With depth, each pixel uses motion from the nearest surrounding surface.
Compilingawait aa.initAsync() compiles the resolve and binds both histories to the current source, so recording binds nothing new until a source or size changes.
Resetting Call reset() after a camera cut. Resizing, region changes and enable(true) also reset history. A frame that throws before it submits the resolve leaves history as it was.
Turning off After enable(false), jitter is zero, record records nothing and output is the source, so keep calling record and keep aa as the next pass’s source.
As a source Give bloom source: aa to bloom the antialiased picture. Every post-processing source takes aa and reads its output and region at each call, because output alternates between two textures.
Recordingrecord takes the frame or an encoder. record(frame, { timestampWrites }) times the resolve under a profiler timer.
Drawing fewer pixels saves fragment work, and stretching the smaller picture to the canvas blurs it. Over a jitter cycle, TAA samples each output pixel at many positions, so it can rebuild detail finer than one drawn pixel. Draw at two thirds in the edge figure above to watch it rebuild one edge. Give it size, and it resolves a scene drawn at a lower resolution up to that size:
Creates render targets that follow a size. Replaces the whole set when the size changes. Put
targets needed only sometimes in their own set and create that set when needed. Throws for
transient targets with sampling, storage or mip levels, for multisampled targets with storage or
mip levels, and for layered targets that are multisampled, mipped or have more layers than the
device allows.
@param ― source the size it follows, such as a surface
@param ― specs a format and options per target, by name
@param ― options.resolution the fraction of each side drawn, which changes without allocating
@returns ― a set of targets you fit every frame and destroy
create(
constroot:TgpuRoot
root,
constsurface:web.Surface
surface,
{
hdr:{
readonly format:"rgba16float";
readonly sampled:true;
}
hdr:{
format:"rgba16float"
format:'rgba16float',
sampled:true
sampled:true},
motion:{
readonly format:"rg16float";
readonly sampled:true;
}
motion:{
format:"rg16float"
format:'rg16float',
sampled:true
sampled:true},
depth:{
readonly format:"depth24plus";
readonly sampled:true;
}
depth:{
format:"depth24plus"
format:'depth24plus',
sampled:true
sampled:true},
},
{
Options.resolution?: number |(()=> number)|undefined
Sets the fraction of each side to draw, capped at 1 and read at each fit(). Textures keep
the source size, so changing resolution allocates nothing. Passes use viewports for the drawn
regions, and sampling reads only those regions. Default 1.
Creates temporal antialiasing from subpixel-jittered frames. The resolve blends each frame
with history sampled where motion, or depth and camera movement, place the preceding pixel.
Without either, it samples history at the same pixel. It clamps history colour to
the local colour spread to reduce trails and weights by brightness to reduce bright-pixel
flicker. With size, it resolves a smaller source up to that size: each output pixel rebuilds
the current frame from the nine source pixels around it with Lanczos-2 weights placed by this
frame's jitter, and blends less of it where those weights add up to less. Record its single
pass after scene passes and before the final pass reads output.
@allocates ― on resize: targets for the new size and the bind groups of its passes; so does a new
source, motion, depth or reactive texture
@owns ― targets, 4 buffers, a sampler, a pipeline, 2 to 4 bind groups: two histories, each frame
written into one from the other, the settings, the region and whether to blend, the jitter and
its sequence, a group each for the frames that read either history with the source and
motion, one for depth and one for reactive
@binds ― 1 uniform: jitter, this frame's offset
@records ― record after the passes that draw the source and the motion, before what reads
output.
@param ― options.source this frame's picture, drawn through jitter, read at every record
@param ― options.motion how far each pixel's surface moved since last frame, read at every
record; without it, pixels move only with the camera
@param ― options.depth the scene's depth, for the motion of the nearest surface around each pixel
and for motion from the camera, or null
@returns ― a resolve you record every frame and destroy
create(
constroot:TgpuRoot
root,{
Options.source: Source
Provides the current linear-colour picture, drawn through jitter: a function returning a
texture, such as () => screen.textures.hdr, or a rendered picture. record reads it on
every call.
Provides the current textures. A size change replaces them.
textures.
hdr:targets.Target<{
readonly format:"rgba16float";
readonly sampled:true;
}>
hdr,
Options.region?:targets.SizeSource|undefined
Selects the source region from its top-left corner, such as regions.hdr when drawing below
full resolution. record reads it on every call. Default the region of a rendered source,
else the whole texture.
Reports each drawn region from the top-left corner of its target. Multiplies target size by
resolution and rounds up. fit() updates the same objects for the lifetime of the set.
regions.
hdr:targets.SizeSource
hdr,
Options.size?:targets.SizeSource|undefined
Resolves to this size, such as the surface, from a source drawn smaller, up to 1.5 times
larger per side. History then keeps this size, each output pixel rebuilds the current frame
from the source pixels around it, and jitter takes more phases. Scene shaders sample textures
with a mip bias of log2(render / output) - 1. Default the source region's size.
Returns the motion texture written by motion. Each vector is the preceding UV position
minus the current UV position. record reads it on every call. Default none, which moves
every pixel as camera moves depth, or keeps it in place without both.
Provides the current textures. A size change replaces them.
textures.
motion:targets.Target<{
readonly format:"rg16float";
readonly sampled:true;
}>
motion,
Options.depth: (()=>targets.Depth)|null
Returns sampled scene depth without stencil, or null for a picture drawn without depth.
Motion then follows the nearest surrounding surface to avoid smearing moving edges over the
background. record reads it on every call. Unused without motion or camera. With null,
motion is read at each pixel.
Provides the current textures. A size change replaces them.
textures.
depth:targets.Target<{
readonly format:"depth24plus";
readonly sampled:true;
}>
depth,
Options.camera?:cameras.CameraBase|undefined
Supplies the scene camera with its preceding view, such as cameras.orbit. With depth,
pixels without renderer-written motion reconstruct motion from depth and camera movement.
Without both, these pixels stay in place. Default none.
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 sampled:true;
};
readonly motion:{
readonly format:"rg16float";
readonly sampled:true;
};
readonly depth:{
readonly format:"depth24plus";
readonly sampled:true;
};
}>>
screen,
{
hdr:typeofpasses.color
hdr:
import passes
passes.
constcolor:typeofpasses.color
Marks the target that receives each renderer's colour.
color,
motion:passes.Output<unknown,{
position:d.v4f;
}>
motion:
import taa
taa.
constmotion:passes.Output<unknown,{
position:d.v4f;
}>
This output writes surface motion into an rg16float target. It stores preceding UV position
minus current UV position. It computes the preceding position by compiling renderer vertex
code with history.previously, which reads the preceding camera and values of other
temporal fills.
motion,
depth:typeofpasses.depth
depth:
import passes
passes.
constdepth:typeofpasses.depth
Marks the depth target.
depth},
{
Options.jitter?: Position |undefined
Moves clip positions for rasterisation. Outputs read the original vertex positions. Use for a
sub-pixel offset in temporal antialiasing. Default none.
@gpu
jitter:
constaa:taa.Taa
aa.
Taa.jitter: (position:d.v4f)=>d.v4f
Offsets vertices by a different fraction of a source pixel each frame so frames sample the
whole pixel together: 8 offsets in turn, or at size 8 for each output pixel a source pixel
covers, 18 at 1.5 times per side. Supply this as jitter in passes.create.
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.
Creates the final pass of a frame. It reads the source, adds glow, tone maps, grades, applies
the vignette, encodes and dithers. It draws one triangle into the caller pass.
@allocates ― on resize: a bind group for a new source or glow
@owns ― 2 buffers, a sampler, a pipeline, 2 bind groups: the settings, the regions it reads, a
group for the glow and one for each texture the source returns
@records ― record into a pass of its own on the view you give, usually the canvas's, or draw
into the caller's pass, after the bloom's record.
@param ― options.source the picture, rendered or a texture, read at every draw
@param ― options.region the part of the source that holds the picture, read at every draw
@param ― options.glow a bloom, or a glow of your own, added before tone mapping
@param ― options.exposure an adapted exposure, read on the GPU
@returns ― a final pass you draw every frame
create(
constroot:TgpuRoot
root,{
Options.format: GPUTextureFormat
Sets the output format, such as the canvas format.
format:
constsurface:web.Surface
surface.
Surface.format: GPUTextureFormat
Reports the format of its textures, which pipelines that draw into it target.
format,
Options.source: Source
Provides the picture at any size: a rendered picture, such as aa or blur, or a function
returning a texture, such as () => screen.textures.hdr. draw reads it on every call, so
the texture can be rebuilt.
@cpu
source:
constaa:taa.Taa
aa});
Output size History, aa.output and aa.region take size, so bloom, exposure and the final pass read aa at the output size. While off, output is the source in its own region.
Reconstruction Each output pixel rebuilds the frame from the nine drawn pixels around it, weighted by where this frame’s jitter placed each one. A frame whose samples land far from the pixel counts for less.
Jitter Jitter stays within a drawn pixel. It takes 8 offsets for each output pixel a drawn pixel covers: 18 at two thirds of each side.
Changing scale History keeps through changes to the region, so the scale can follow dynamicResolution. A new size starts over.
Smaller sources A source texture smaller than the output, such as one made with targets.scaled, needs no region.
Lowest scale Draw at least two thirds of each side.
Mip bias Shaders of the scene that sample mipmapped textures pass a bias of log2(drawn / output) - 1 to std.textureSampleBias, -1.58 at two thirds of each side. Without it, their textures stay as blurred as the drawn size.
Particles, additive glows and dithered fades change from frame to frame without motion that explains the change. Their surroundings vary too much for the colour clamp to reject old colours, so they leave trails. A reactive texture the size of the source sets how much history to drop at each pixel. Write it from the drawings that need it:
Creates render targets that follow a size. Replaces the whole set when the size changes. Put
targets needed only sometimes in their own set and create that set when needed. Throws for
transient targets with sampling, storage or mip levels, for multisampled targets with storage or
mip levels, and for layered targets that are multisampled, mipped or have more layers than the
device allows.
@param ― source the size it follows, such as a surface
@param ― specs a format and options per target, by name
@param ― options.resolution the fraction of each side drawn, which changes without allocating
@returns ― a set of targets you fit every frame and destroy
Creates temporal antialiasing from subpixel-jittered frames. The resolve blends each frame
with history sampled where motion, or depth and camera movement, place the preceding pixel.
Without either, it samples history at the same pixel. It clamps history colour to
the local colour spread to reduce trails and weights by brightness to reduce bright-pixel
flicker. With size, it resolves a smaller source up to that size: each output pixel rebuilds
the current frame from the nine source pixels around it with Lanczos-2 weights placed by this
frame's jitter, and blends less of it where those weights add up to less. Record its single
pass after scene passes and before the final pass reads output.
@allocates ― on resize: targets for the new size and the bind groups of its passes; so does a new
source, motion, depth or reactive texture
@owns ― targets, 4 buffers, a sampler, a pipeline, 2 to 4 bind groups: two histories, each frame
written into one from the other, the settings, the region and whether to blend, the jitter and
its sequence, a group each for the frames that read either history with the source and
motion, one for depth and one for reactive
@binds ― 1 uniform: jitter, this frame's offset
@records ― record after the passes that draw the source and the motion, before what reads
output.
@param ― options.source this frame's picture, drawn through jitter, read at every record
@param ― options.motion how far each pixel's surface moved since last frame, read at every
record; without it, pixels move only with the camera
@param ― options.depth the scene's depth, for the motion of the nearest surface around each pixel
and for motion from the camera, or null
@returns ― a resolve you record every frame and destroy
create(
constroot:TgpuRoot
root,{
Options.source: Source
Provides the current linear-colour picture, drawn through jitter: a function returning a
texture, such as () => screen.textures.hdr, or a rendered picture. record reads it on
every call.
Returns the motion texture written by motion. Each vector is the preceding UV position
minus the current UV position. record reads it on every call. Default none, which moves
every pixel as camera moves depth, or keeps it in place without both.
Returns a texture the size of the source whose red channel, from 0 to 1, takes away history
at each pixel, for translucent, dithered or particle drawings that write no motion of their
own. 0 accumulates as usual; values above 0.9 count as 0.9, so history never drops out.
record reads it on every call. Default none.
Provides the current textures. A size change replaces them.
textures.
reactive:targets.Target<{
readonly format:"r8unorm";
readonly sampled:true;
}>
reactive,
Options.depth: (()=>targets.Depth)|null
Returns sampled scene depth without stencil, or null for a picture drawn without depth.
Motion then follows the nearest surrounding surface to avoid smearing moving edges over the
background. record reads it on every call. Unused without motion or camera. With null,
motion is read at each pixel.
Provides the current textures. A size change replaces them.
textures.
depth:targets.Target<{
readonly format:"depth24plus";
readonly sampled:true;
}>
depth,
Options.camera?:cameras.CameraBase|undefined
Supplies the scene camera with its preceding view, such as cameras.orbit. With depth,
pixels without renderer-written motion reconstruct motion from depth and camera movement.
Without both, these pixels stay in place. Default none.
camera:
constview:cameras.OrbitCamera
view,
});
// How much history to drop where a drawing covers
Defines how a pass writes one target from renderer data. write takes the renderer's data at
a pixel, and its parameter type declares the fields it needs. For vertex data, supply varyings and
vary. vary runs per vertex, and its interpolated result reaches write. With previous: true, vary also receives the previous frame's vertex. Throws if vary has no varyings
schema, previous has no vary, or vary takes two parameters without previous: true.
@param ― schema what the target holds per pixel, such as d.vec2f for an rg16float target
@param ― spec write, which gives the value at a pixel, and what it clears to and carries from the
vertex
@returns ― an output to give a target in passes.create
output(
import d
d.
constf32:d.F32
export f32
A schema that represents a 32-bit float value. (equivalent to f32 in WGSL)
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 sampled:true;
};
readonly motion:{
readonly format:"rg16float";
readonly sampled:true;
};
readonly reactive:{
readonly format:"r8unorm";
readonly sampled:true;
};
readonly depth:{
readonly format:"depth24plus";
readonly sampled:true;
};
}>>
screen,
{
hdr:typeofpasses.color
hdr:
import passes
passes.
constcolor:typeofpasses.color
Marks the target that receives each renderer's colour.
color,
motion:passes.Output<unknown,{
position:d.v4f;
}>
motion:
import taa
taa.
constmotion:passes.Output<unknown,{
position:d.v4f;
}>
This output writes surface motion into an rg16float target. It stores preceding UV position
minus current UV position. It computes the preceding position by compiling renderer vertex
code with history.previously, which reads the preceding camera and values of other
temporal fills.
motion,
reactive:passes.Output<unknown, unknown>
reactive:
constfresh:passes.Output<unknown,unknown>
fresh,
depth:typeofpasses.depth
depth:
import passes
passes.
constdepth:typeofpasses.depth
Marks the depth target.
depth},
{
Options.jitter?: Position |undefined
Moves clip positions for rasterisation. Outputs read the original vertex positions. Use for a
sub-pixel offset in temporal antialiasing. Default none.
@gpu
jitter:
constaa:taa.Taa
aa.
Taa.jitter: (position:d.v4f)=>d.v4f
Offsets vertices by a different fraction of a source pixel each frame so frames sample the
whole pixel together: 8 offsets in turn, or at size 8 for each output pixel a source pixel
covers, 18 at 1.5 times per side. Supply this as jitter in passes.create.
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.
Returns a description with keys left out for a renderer that cannot write them. Opaque
drawings write each omitted output's clear. Drawings with a blend preserve the value
underneath. No varyings are carried for omitted outputs.
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.
add(
constsparks:passes.Drawing<d.WgslStruct<{
position:d.Vec4f;
}>,{
color:d.v4f;
}>
sparks);
0 accumulates as usual. Higher values take that share of history’s weight away, up to 0.9, so some history always stays and edges stay smooth.
Draw opaque drawings first. One left out with without writes 0 over what is beneath it, while a blended one keeps it.
Write what changes, such as a particle’s alpha, for soft edges.
Without reactive, the resolve binds and reads nothing more.
The jitter for passes.create, and this frame’s offset in clip space, a uniform.
aa.output, aa.region
Antialiased rgba16float image at size or the source’s, and its region, or the source while off. Read each frame because output alternates between two textures.
The kit’s model materials sample textures without a mip bias, so at size their textures stay as blurred as the drawn size.
TAA writes alpha 1, so it doesn’t suit a canvas over a page.
A renderer that leaves out motion, such as an additive glow, takes the motion of what is under it.
Moving instances, trails, text and skinned poses need their own motion to avoid dimming. Their default motion includes only the camera.
Lines thinner than one drawn pixel can lose most of their brightness, even while stationary.
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 →
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 →
rendererA renderer draws one sort of thing, such as instances or particles, by handing a pass description a drawing.Every renderer is a drawing →
instanceAn instance is one copy of a mesh with its own position, rotation, scale and material, kept as a row of a table.Instances →
tableA table is a buffer of rows with named fields, some written by the CPU and the others by kernels.Rows →
rowA row is one object's values in a buffer, such as one enemy, one particle or one light.Objects are rows in buffers →
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 →
Provides the current linear-colour picture, drawn through jitter: a function returning a texture, such as () => screen.textures.hdr, or a rendered picture.
Reads depth as reversed, 1 at the near plane and 0 at the far plane, without a camera to say so.Default the camera's cameras.reversed, or false without one.
Selects the source region from its top-left corner, such as regions.hdr when drawing below full resolution.Default the region of a rendered source, else the whole texture.
Returns a texture the size of the source whose red channel, from 0 to 1, takes away history at each pixel, for translucent, dithered or particle drawings that write no motion of their own.Default none.
Offsets vertices by a different fraction of a source pixel each frame so frames sample the whole pixel together: 8 offsets in turn, or at size 8 for each output pixel a source pixel covers, 18 at 1.5 times per side.
targets ·4 buffers ·a sampler ·a pipeline ·2 to 4 bind groups
Two histories, each frame written into one from the other, the settings, the region and whether to blend, the jitter and its sequence, a group each for the frames that read either history with the source and motion, one for depth and one for reactive.